Enumerating Semilattice Elements from a Generating Set
Daniel Borchmann TU Dresden, Institute of Algebra daniel.borchmann@mailbox.tu-dresden.de
Abstract. A generalization of the well known Next-Closure algorithm is presented, which is able to enumerate finite semilattices from a generating set. We prove the correctness of the algorithm and apply it on the computation of the intents of a formal context.
1 Introduction
Next-Closure is one of the best known algorithms in Formal Concept Analysis [8]
to compute the concepts of a formal context. In its general form it is able to efficiently enumerate the closed sets of a given closure operator on a finite set.
This generality might be a drawback concerning efficiency compared to other algorithms like Close-by-One [1,9,11]. On the other hand, the general formulation of Next-Closure widens its field of application. However, there are still applications where Next-Closure might be useful, but is not applicable, because a closure operator on a finite set is not explicitly available. One such example might be the computation of concepts of a fuzzy formal context [3]. In those cases most often an ad hoc variation of Next-Closure can be constructed. The aim of this paper is to provide a generalization of Next-Closure which covers those cases, and may even go beyond them.
As it turns out, Next-Closure is not about enumerating closed sets of a closure operator, even not on an abstract ordered set. The algorithm is merely about enumerating elements of a certain semilattice, given as an operation together with a generating set. This observation shall turn out to be quite natural.
It has to be noted that there have been prior attempts to generalize Next- Closure to a more general setting [7]. But this approach is, as far as the author can tell, not related to the one presented in this paper.
This paper is organized as follows. First of all we shall revisit the original version of Next-Closure, together with the basic definitions. Then we present our generalized version working on semilattices, together with a complete proof of its correctness. Then we show how this generalized form is indeed a generalization of the original Next-Closure. Additionally, we present another algorithm for enumerating the intents of a given formal context, which is very similar to Close-by-One. Finally, we give some outlook on further questions which might be interesting within this line of research.
c 2012 by the paper authors. CLA 2012, pp. 9–20. Copying permitted only for private and academic purposes. Volume published and copyrighted by its editors.
Local Proceedings in ISBN 978–84–695–5252–0,
Universidad de M´alaga (Dept. Matem´atica Aplicada), Spain.
2 The Next-Closure Algorithm
Before we are going to discuss our generalized form of Next-Closure, let us revisit the original version as it is given in [6,8]. To make our discussion a bit more consistent, we shall allow ourselves a minor deviation from the standard description of the algorithm, which we shall mention explicitly.
LetM be a finite set and letc:PpPq ÝÑPpPqbe a function such that a) cis idempotent, i.e.cpcpAqq “cpAqfor allAĎM,
b) cis monotone, i.e. ifAĎB, then cpAq ĎcpBqfor allA, BĎM, and c) cis extensive, i.e.AĎcpAqfor allAĎM.
The mapping cis then said to be aclosure operatoron P. A setAĎM is called closed (with respect to c)ifA“cpAq, and theimage ofcis defined as
crPpMqs:“ tcpAq |AĎMu.
Without loss of generality, let M“ t1, . . . , nufor somenPN. For two sets A, BPcrPpMqswithA‰B andiPM we say thatAislectically smaller than B at positioniif and only if
i“minpA ∆ Bq and iPB,
where A ∆ B“ pAzBq Y pBzAqdenotes thesymmetric difference ofA andB.
We shall writeAăiB ifAis lectically smaller thanB at positioni. Finally, we say thatAislectically smaller thanB, forA, BPcrPpMqs, ifA“B orAăiB for someiPM. We shall writeAĺB in this case.
It has to be noted that, in contrast to our definition, the lectic order is normally defined for all setsA, BĎM in the very same spirit as given above.
However, as we shall see, this is not necessary, which is why we have restricted our definition to closed sets only.
Now let us define forAPcrPpMqsandiPM
A‘i:“cptjPA|jăiu Y tiuq.
Then we have the following result.
Theorem 1 (Next-Closure [6]). LetAPcrPpMqs. Then the next closed set A`PcrPpMqs afterA with respect to the lectic order ĺ, if it exists, is given by
A`“A‘i with iPM being maximal withAăi A‘i.
This is the original version of Next-Closure, as it is given in [6,8]. Therein, the term “next closed set” has the obvious meaning, namely
A`“minătBPcrPpMqs |AăBu.
Our generalization now starts with the following observation: the setA‘i can be seen as the smallest closed set containing bothtjPA|jăiuandtiu, or equivalently, both cptj PA | j ăiuq and cptiuq. This means that we can rewriteA‘ias
A‘i“cptjPA|j ăiuq _cptiuq,
where X _Y is the smallest closed set containing both X, Y P crPpMqs, the supremum of X and Y, which is simply given by X _Y “ cpX YYq. This observation suggests to consider Next-Closure on abstract algebraic structures with a binary operation _with some certain properties, namely onsemi-lattices.
To do so we need a more general notion of cptiuq, since we do not necessarily deal with subsets, and a more general notion oftjPA|jăiu, which likewise might not be expressible in a more general setting. Finally, we need to find a starting point for our enumeration, which iscpHqin the original description of Next-Closure, but may vary in other cases. Luckily, all this is possible and quite natural, as we shall see in the next section.
3 Generalizing Next-Closure for Semilattices
The aim of this section is to present a generalization of the Next-Closure algorithm that works on semilattices. For this recall that a semilattice L“ pL,_q is an algebraic structure with a binary operation_which is associative, commutative and idempotent. It is well known that by
xďLy :ðñ x_y “y, px, yPLq
an order relation on L is defined in such a way that for every two elements a, bPLthe elementa_bis the least upper bound of bothaandb with respect toďL.
For the remainder of this section let L “ pL,_q be an arbitrary but fixed semilattice. Furthermore, letpxi|iPIqbe an enumeration of a finite generating settxi|iPIu ĎLofL. Finally, letďI be a total order onI.
Definition 1. Let a, bPL and letiPI. Set
∆a,b:“ tjPI| pxjďLaandxjďLbqor pxj ďLa andxj ďLbq u.
We then define
aăib :ðñ i“min∆a,b andxiďLb.
Furthermore we writeaăb if aăib for some iPI and write aďb ifa“b or aăb.
One can see the similarity of this definition to the one of the lectic order.
Here, the set ∆a,b generalizes a ∆ bandxi ďL b somehow represents the fact thatiPb, or equivalentlytiu Ďb, in the special case ofL“PpMqandiPM.
Note that if aăib andkPI withkăI i, then xk ďLa ðñ xkďLb.
This observation is quite useful and will be used in some of the proofs later on.
The first thing we want to consider now are two easy results stating thatď is a total order relation onLextendingďL.
Lemma 1. The relationăis irreflexive and transitive. Furthermore, for every two elementsa, bPLwith a‰b, it is eitheraăb orbăa.
Proof. Ifa“b, then the set∆a,b defined above is empty, therefore we cannot haveaăi afor someiPI. This shows the irreflexivity ofă. Let us now consider the transitivity ofă. For this leta, b, cPL,i, jPIand suppose thataăiband băj c. We have to show thataăc. Let us consider the following cases.
Case iăI j.We havexiďLaandxiďL bbecause ofaăib. Due toiăI j it follows that xi ďL c. Suppose that there exists kPI, k ăI i withxk ďL a and xk ďL c. Then if xk ďL b we would have xk ďL a because of k ăI i, a contradiction. But if xk ďL b, then xk ďL c because of k ăI i ăI j, again a contradiction. Thus we have shown thataăc.
Case j ăI i. We have xj ďL b, xj ďL c because of b ăj c. Due to j ăI i it follows thatxj ďL a. Now if there were a k PI, k ăI j with xk ďL aand xkďLc, then xk ďLb would implyxk ďL candxkďLbwould implyxkďLa, analogously to the first case, a contradiction. Hence such akcannot exist and aăc.
Casei“j.This cannot occur since otherwisexiďLb, because ofaăib, and xiďLb, because ofbăic, a contradiction.
Overall we have shown thataăc in any case and thereforeăis a transitive relation.
Finally leta, bPLwitha‰b. Then becausetxi|iPIuis a generating set, the set∆a,b is not empty, since otherwise a“b. Withi:“min∆a,b we either haveaăib ifxiďLbandbăi aotherwise.
Lemma 2. Leta, bPL with aďLb. Thenaďb. In particular, if aďL c and bďLc fora, b, cPL, then a_bďc.
Proof. We showxi ďL a ùñ xi ďL b for all iPI. This shows b ăa, hence aďbby Lemma 1. Now if xiďLa, then because ofaďLb we see thatxiďL b and the claim is proven.
The next step towards a general notion of Next-Closure is to provide a generalization of‘.
Definition 2. Let aPL andiPI. Then define a‘i:“ ł
jăIi xjďLa
xj_xi.
With all these definitions at hand we are now ready to formulate and prove the promised generalization. For this, we generalize the proof of Next-Closure as it is given in [8, page 67].
Lemma 3. Let a, bPLandi, jPI. Then the following statements hold:
i) aăib, aăjc, iăI j ùñ căib.
ii) aăa‘i ifxiďLa.
iii) aăib ùñ a‘iďb.
iv) aăib ùñ aăia‘i.
Proof. i) It isxiďLaand due toiăI j we getxiďLcas well. Furthermore, xi ďL b because of aăi b. Now if there would exist ak PI with kăI i such thatxk ďL c, xk ďLb, thenxkďL abecause ofkăI i andxk ďLa because of kăI iăI j, a contradiction. With the same argumentation a contradiction follows from the assumption that there exists akPI,kăI i withxkďLc, xk ďLb. In sum we have showncăib, as required.
ii) We have xi ďL a andxi ďL a‘i. Furthermore, fork P I, k ăI i and xk ďLawe have xk ďLa‘iby definition. This showsaăa‘i.
iii) Letaăkb for somekPI. ThenŽ
jăIk,xjďLaxjďLb andxkďLb, hence with Lemma 2 we geta‘kďb.
iv) Letaăib. ThenxiďLaand with (ii) we getaăa‘i. By (iii),a‘iďb.
If for k PI, k ăI i it holds that xk ďL a‘iand xk ďL a, then we also have xkďLa‘iďLb, i.e. xk ďLb, contradicting the minimality ofi.
Theorem 2 (Next-Closure for Semilattices). Let a P L. Then the next elementa`PL with respect toă, if it exists, is given by
a`“a‘i with iPI being maximal withaăia‘i.
Proof. Let
a`“minătbPL|aăbu
be the next element afterawith respect toă. Thenaăia` for someiPI and by Lemma 3.iv we getaăia‘iand with Lemma 3.iii we seea‘iďa`, hence a‘i“a`. The maximality ofi follows from Lemma 3.i.
To find the correct elementiPIsuch thata`“a‘iwe can utilize Lemma 3.ii.
Because of this result, only elementsiPI withxiďLahave to be considered, a technique which is also known for the original form of Next-Closure.
However, to make the above theorem practical for enumerating the elements of a certain semilattice, one has to start with some element, preferably the smallest element inL with respect toď. This element must also be minimal inLwith respect to ďL, by Lemma 2. Since txi | i P Iu is a generating set of L, and aďa_bfor all a, bPL, the minimal elements ofLwith respect toďL must be among the elementsxi,iPI. So to find the first element ofL with respect toď, find all minimal elements intxi|iPIuand choose the smallest element with respect toďfrom them. But because ofxi ďxj if and only ifj ăI i, one just has to take the largest indexjwith respect to ăI to find the smallest element in Lwith respect toď.
As a final remark for this section note that the settxi|iPIumust always include the_-irreducible elements ofL. These are all those elementsaPLthat cannot be represented as a join of other elements, or, equivalently,
tbPL|băL au “ H or ł
băLa
băLa.
It is also easy to see that the set of_-irreducible elements ofLis also sufficient, i. e. that it is a generating set ofL.
4 Computing the Intents of a Formal Context
We have seen an algorithm that is able to enumerate the elements of a semilattice from a given generating set. We have also claimed that this is a generalization of Next-Closure, which we want to demonstrate in this section. Furthermore, we want to give another example of an application of this algorithm, namely the computation of the intents of a given formal context.
Firstly, let us reconstruct the original Next-Closure algorithm from Theorem 2 and the corresponding definitions. For this letM be a finite set and letc be a closure operator onM“ t0, . . . , n´1u, say. We then apply Theorem 2 to the semilatticeP “ pcrPpMqs,_q. We immediately see thatďP “ Ďand thatăi is the usual lectic order onP. Then the set
tcptiuq |iPMu Y tcpHq u
is a finite generating set ofP and we can define xi :“cptiuqandxn :“cpHq, i.e.I“ t0, . . . , nu. For a closed setAĎM andiPI then follows
A‘i“ ł
jăi xjĎA
xi_xi
“cp ď
jăi xjĎA
xjq _xi
“cpď
tcptjuq |jăi, jPAuq _cptiuq
“cptj |jăi, jPAuq _cptiuq
“cptj |jăi, jPAu Y tiuq
which is the original definition of‘for Next-Closure. Furthermore, it isA‘n“A sincecpHq ĎA for each closed setA. We therefore do not need to considerxn
when looking for the next closed set, and indeed, the only reason whyxn“cpHq has been included is that it is the smallest closed set inP. All in all, we see that Next-Closure is a special case of Theorem 2.
However, for a closure operator con a finite setM it seems more natural to consider the semilatticeP “ pcrPpMqs,Xq, because the intersection of two closed sets ofc again yields a closed set ofc. One sees thatďP “ Ě. As a generating
set we take the set ofX-irreducible elementstXi|iPGufor some index setG.
LetA, B PcrPpMqsand letăG be a linear ordering onG. ThenAăB if and only if there existsiPGsuch that
i“mintj PG| pXiĚA, XiĞBqorpXi ĞA, XiĚBq u and XiĚB and‘is just given by
A‘i“ č
jăGi XjĚA
XjXXi.
Now note that ‘ does not need the closure operatorc anymore. This means that if the computation of c is very costly and theX-irreducible elements (or a superset thereof) is known, this approach might be much more efficient. In general, however, it is not known how to efficiently determine theX-irreducible closed sets ofc. But if c is given as the ¨2 operator of a formal context, these irreducible elements can be determined quickly [8]. We shall describe this idea in more detail.
LetGand M be two finite sets and letJ ĎGˆM. We then call the triple K :“ pG, M, Jq a formal context, G the objects of the formal context and M theattributes of the formal context. Forg PGandmPM we writeg J m for pg, mq PJ and say that objectg has attributem.
LetAĎGandBĎM. We then define thederivationsofA andB to be A1:“ tmPM | @gPA:g J mu
B1:“ tgPG| @mPB:g J mu.
Then the¨2 operator is just the twofold derivation of a given set of attributes. It turns out that this is indeed a closure operator, and that every closure operator can be represented as a¨2 operator of a suitable formal context [4,8]. The closed sets of¨2, i.e. all setsBĎM withB“B2, are called theintentsofKand shall be denoted by IntpKq. It is clear from the previous remarks that pIntpKq,Xq is a semilattice.
The advantage of representing a closure operator is that the X-irreducible elements of pIntpKq,Xq can be directly read off from the format context. As discussed in [8], the set
t tgu1 |gPGu
contains the irreducible elements we are looking for, exceptM(note that the order relation onpIntpKq,Xq isĚ.) Furthermore, it is possible to omit certain objects g fromKwithout changing IntpKq. Every objectgPGcan be omitted fromK for which the settgu1 is either equal toM or can be represented as a proper intersection of other setstg1u1, . . . ,tgnu1 for some elementsg1, . . . , gnPG. It is also clear that if there exist two distinct objectsg1 andg2 withtg1u1“ tg2u1, that we can remove one of them without changing IntpKq. A formal context for which no such objects exist is called object clarified andobject reduced. If K“ pG, M, Jqis an object clarified and object reduced formal context, then the
Listing 1.1.Compute the Next Intent of a Formal Context
0 define next-intent(K“ pG, M, Jq,A)
1 for gPG, descending
2 i f tgu1ĞA then
3 let (B := A‘g)
4 i f @hPG, hăGg,thu1ĞA:thu1ĞB then
5 return B
6 end i f
7 end let
8 end i f
9 end for
10 return nil
11 end
sett tgu1|gPGuis exactly the set ofX-irreducible intents ofK, except for the setM.
The algorithm described above now takes the following form when applied to the semilatticepIntpKq,Xq. As index set we choose the setGof object of the given formal context, ordered byăG. For every objectgPGwe setxg:“ tgu1. Then the settxg|gPGuis a generating set of the semilatticepIntpKqztMu,Xq, which we want to enumerate (since we get the setM for free). ForAbeing an intent ofKandgPGwe have
A‘g:“ č
thu1ĚA hăGg
thu1X tgu1
and as the first intent we take M. For an intentAĎM of Kwe then have to find the maximal objectgPG(with respect toăG) such thatAăgA‘g. This is equivalent tog being maximal withtgu1 ĞAand@hPG, hăG g :thu1Ě A ðñ thu1ĚA‘g. However, the direction “ùñ” is clear, hence we only have to ensure
@hPG, hăGg:thu1ĞA ùñ thu1ĞA‘g.
All these considerations yield the algorithm shown in Listing 1.1. Of course, the derivations of the formtgu1 should not be computed every time they are needed but rather stored somewhere for reuse.
Let us simplify Listing 1.1 a bit further. IfAis an intent ofK, then forgPG it is true that
tgu1ĞA ðñ gRA1. This is because
tgu1ĚA ùñ tgu2ĎA1 ùñ gPA1
Listing 1.2.Simplified version of Listing 1.1
0 define next-intent(K“ pG, M, Jq,A)
1 for gPG, descending
2 i f gRA1 then
3 let (B := A‘g)
4 i f B1XGgĎA1XGg then
5 return B
6 end i f
7 end let
8 end i f
9 end for
10 return nil
11 end
and
gPA1 ùñ tgu ĎA1 ùñ tgu1ĚA2“A,
and thereforetgu1 ĚA ðñ gPA1, i. e.tgu1ĞA ðñ gRA1. Using this, we can simplify the condition
@hPG, hăGg,thu1ĞA:thu1 ĞB to
@hPG, hăGg:hPB1 ùñ hPA1
or equivalently toB1XGgĎA1XGg, whereGg:“ thPG|hăG gu. This leads to the algorithm of Listing 1.2.
Curiously enough, this algorithm is now very similar to Close-by-One. To make this similarity more apparent, let us give a brief description of the algorithm Close-by-One. In contrast to Next-Closure, which enumerates the intents of the formal contextK, Close-by-One enumerates theformal concepts ofK. These are pairspC, Dqof setsCĎG, DĎM such thatC1 “D andD1“C. The set of all formal concepts ofKis denoted byBpKq. The formal conceptsBpKqofKcan be ordered by
pC1, D1q ď pC2, D2q ðñ C1ĎC2p ðñ D2ĎD1q.
It turns out that the setpBpKq,ďq forms a(complete) lattice, i. e. an ordered set such that for each set of formal concepts there exists a smallest upper and a largest lower bound. This lattice is also called theconcept latticeofK.
Close-by-One now performs a depth-first search in this lattice to compute all formal concepts ofK. Following the description of [10], the main part of the work is done by the function generate-from, as it is described in Listing 1.3.
To simplify the description of this function, we again assume that the set M of
Listing 1.3.Close-by-One [10]
0 define generate-from(K“ pG, M, Jq,pC, Dq,ℓ)
1 output pC, Dq
2
3 i f D“M or ℓą |M| then
4 return
5 end i f
6
7 for mP tℓ, . . . , nu, ascending
8 i f mRD then
9 let (E := CX tmu1,
10 F := E1)
11 i f FXMmĎDXMm then
12 generate-from(pE, Fq,m`1)
13 end i f
14 end let
15 end i f
16 end for
17 end
18
19 define all-concepts(K“ pG, M, Jq)
20 generate-from(K,pH1,H2q, 1)
21 end
attributes ofKis just the setM “ t1, . . . , nu. Furthermore, ifmPM, we define Mm:“ t1, . . . , m´1u.
We can now spot some similarities between the functions next-intentfrom Listing 1.2 and generate-from. The most striking similarity to note is the occurrence of the same tests in both functions: “B1XGgĎA1XGg” in line 4 of Listing 1.2, and “FXMmĎDXMm” in line 11 of Listing 1.3. If we substitute the definitions of the involved variables, these tests get the following form:
next-intent: pAX tgu1q1XGgĎA1XGg generate-from:pCX tmu1q1XMmĎC1XMm
So except that we consider sets of objects in the functionnext-intentand sets of attributes in the functiongenerate-from, both test conditions are the same.
Still, the functions next-intent andgenerate-from are very different in how they compute the next intent and formal concept, respectively. While next-intent computes for a given intent just a new one,generate-from per- forms a depth-first search and enumerateall formal concepts ofK.
5 Conclusion
We have seen a natural generalization of the Next-Closure algorithm to enumerate elements of a semilattice from a generating set. We have proven the algorithm to
be correct and applied it to the standard task of computing the intents of a given formal context, yielding a another algorithm to accomplish this. This algorithm turned out to have a lot of similarity to Close-by-One.
There are still some interesting ideas one might want to look at.
Firstly, a variation of the original Next-Closure algorithm is able to compute the canonical base of a formal context, a very compact representation of its impli- cational knowledge. It would be interesting to know whether the generalization given in this paper gives more insight into the computation, and therefore into the nature of the canonical base. This is, however, quite a vague idea.
Secondly, the algorithm discussed above to compute the intents of a formal context enumerates them in a certain order, which might or might not be a lectic one. Understanding this order relation might be fruitful, especially with respect to the complexity results obtained recently which consider enumerating pseudo-intentsof a formal context in lectic order [5].
Thirdly, there exists a variant of the Next-Closure algorithm that is able to compute intents of a formal contextup to symmetry[8, Theorem 51]. Given a set Γ ofautomorphismsof a formal context, this variant is able to compute for each orbit of intents under Γ exactly one representative. It would be interesting to know whether we can find a variant of our generalized Next-Closure algorithm that accomplishes the same thing.
Finally, and more technically, it might be interesting to look for other ap- plications of our general algorithm. As already mentioned in the introduction, the enumeration of fuzzy concepts of a fuzzy formal context might be worth investigating (and it might be interesting comparing it to [2]).
Acknowledgments
The author is grateful for the useful comments of the anonymous reviewers, especially for pointing out the similarity of Listing 1.1 to Close-by-One, which the author had overlooked.
References
1. Simon Andrews. In-Close, a fast algorithm for computing formal concepts. In Sebas- tian Rudolph, Frithjof Dau, and Sergei O. Kuznetsov, editors,ICCS Supplementary Proceedings, Moscow, 2009.
2. Radim Belohlávek, Bernard De Baets, Jan Outrata, and Vilém Vychodil. Computing the Lattice of All Fixpoints of a Fuzzy Closure Operator. IEEE T. Fuzzy Systems, 18(3):546–557, 2010.
3. Radim Belohlávek and Vilém Vychodil. Attribute Implications in a Fuzzy Setting.
In Rokia Missaoui and Jürg Schmid, editors,ICFCA, volume 3874 ofLecture Notes in Computer Science, pages 45–60. Springer, 2006.
4. Daniel Borchmann. Decomposing Finite Closure Operators by Attribute Explo- ration. InICFCA 2011, Supplementary Proceedings, 2011.
5. Felix Distel. Hardness of Enumerating Pseudo-intents in the Lectic Order. In Léonard Kwuida and Baris Sertkaya, editors,ICFCA, volume 5986 ofLecture Notes in Computer Science, pages 124–137. Springer, 2010.
6. Bernhard Ganter. Two basic algorithms in concept analysis. FB4-Preprint Nr. 831, 1984.
7. Bernhard Ganter and Klaus Reuter. Finding all closed sets: A general approach.
Order, 8(3):283–290, 1991.
8. Bernhard Ganter and Rudolph Wille. Formal Concept Analysis: Mathematical Foundations. Springer, Berlin-Heidelberg, 1999.
9. Sergei O. Kuznetsov. A fast algorithm for computing all intersections of objects in a finite semi-lattice. Automatic Documentation and Mathematical Linguistics, 27:11–21, 1993.
10. Jan Outrata and Vilém Vychodil. Fast algorithm for computing fixpoints of galois connections induced by object-attribute relational data. Inf. Sci., 185(1):114–127, 2012.
11. Vilém Vychodil, Petr Krajča, and Jan Outrata. Advances in algorithms based on CbO. In Marzena Kryszkiewicz and Sergei Obiedkov, editors,Concept Lattices and Their Application, pages 325–337, 2010.