Translating between Horn Representations and their Characteristic Models

Characteristic models are an alternative, model based, representation for Horn expressions. It has been shown that these two representations are incomparable and each has its advantages over the other. It is therefore natural to ask what is the cost of translating, back and forth, between these representations. Interestingly, the same translation questions arise in database theory, where it has applications to the design of relational databases. This paper studies the computational complexity of these problems. Our main result is that the two translation problems are equivalent under polynomial reductions, and that they are equivalent to the corresponding decision problem. Namely, translating is equivalent to deciding whether a given set of models is the set of characteristic models for a given Horn expression. We also relate these problems to the hypergraph transversal problem, a well known problem which is related to other applications in AI and for which no polynomial time algorithm is known. It is shown that in general our translation problems are at least as hard as the hypergraph transversal problem, and in a special case they are equivalent to it.


Introduction
The traditional form of representing knowledge in AI is through logical formulas (McCarthy, 1958;McCarthy & Hayes, 1969), where all the logical conclusions of a given formula are assumed to be accessible to an agent.Recently, an alternative way of capturing such information has been developed (Kautz, Kearns, & Selman, 1995;Khardon & Roth, 1994).Instead of using a logical formula, the knowledge representation is composed of a particular subset of its models, the set of characteristic models.This set retains all the information about the formula, and is useful for various reasoning tasks.In particular, using model evaluation with the set of characteristic models, one can deduce whether another formula, a query presented to an agent, is implied by the knowledge or not.While characteristic models exist for arbitrary propositional formulas, in this paper we limit our attention to logical formulas which are in Horn form and to their representation as characteristic models.
The characteristic models of Horn formulas have been shown to be useful.There is a linear time deduction algorithm using this set, and abduction can be performed in polynomial time, while using formulas it is NP-Hard (Kautz et al., 1995).Furthermore, an algorithm for default reasoning using characteristic models has been developed, for cases where formula based algorithms are not known (Khardon & Roth, 1995).Hence, the question arises, whether one can e ciently translate a Horn formula into its set of characteristic models c 1995 AI Access Foundation and Morgan Kaufmann Publishers.All rights reserved.and then use this set for the reasoning task.We denote this translation problem by CCM (for Computing Characteristic Models).
On the other hand, given a set of assignments, it might be desirable to nd the underlying structure behind this set of models.This is the case when one is trying to learn the structure of the world using a set of examples.This problem has been studied before under the name Structure Identi cation (Dechter & Pearl, 1992;Kautz et al., 1995;Kavvadias, Papadimitriou, & Sideri, 1993).Technically, the problem seeks an e cient translation from a set of characteristic models into a Horn expression that explains it.We denote this translation problem by SID (for Structure Identi cation).
Interestingly, the same constructs appear in the theory of relational databases.As shown in a companion paper (Khardon, Mannila, & Roth, 1995), there is a correspondence between Horn expressions and Functional Dependencies, and a correspondence between characteristic models and an Armstrong relation.The equivalent question of translating between functional dependencies and Armstrong relations has been studied before (Beeri, Dowd, Fagin, & Statman, 1984;Mannila & Raiha, 1986;Eiter & Gottlob, 1991;Gottlob & Libkin, 1990) and is relevant for the design of relational databases (Mannila & Raiha, 1986).While this paper does not discuss the problems in the database domain, some of the results presented here can be alternatively derived from previous results in database theory using the above mentioned equivalence.(We identify those precisely, later on.)However, this paper makes these results more accessible without resorting to any results in database theory, and with simpler proofs.On the other hand some new results are presented, which resolve a question which was open both in AI and in the database domain.

An Example
Let us introduce the problems in question through an example.Suppose the world has 4 attributes denoted a; b; c; d, each taking a value in f0; 1g to denote whether it is \on" or \o ", and our knowledge is given by the following constraints: W = (bc !d)(cd !b)(bc !a): Then W is a Horn expression and it is normally used to decide whether certain constrains are implied by it or not.For example W j = (cd !a), and W 6 j = (bd !a), where the symbol j = stands for implication.This is normally performed by deriving a proof for the constraint in question.If no such proof exists then implication does not hold.In our example we would notice that (cd !b), and therefore (cd !bc !a).As for (bd !a), we would fail to nd a proof and therefore conclude that it is not implied by W. This general approach is called theorem proving, and is e cient for Horn expressions (Dowling & Gallier, 1984).
An alternative approach is to check the implication relation by model checking.Implication is de ned as follows: W j = if every model of W is also a model of (where x 2 f0; 1g n is a model of an expression f if f is evaluated to \truth" on x).So to decide whether W j = we can simply use all the models of W, and check, one by one, whether any of them does not satisfy .In our example W has 11 models: models(W) = f0000; 0001; 0010; 0100; 0101; 1000; 1001; 1010; 1100; 1101; 1111g (where the assignments denote the values assigned to abcd correspondingly), and we would have to test on every one of them.Unfortunately, in general the number of models may be very large, exponential in the number of variables, and therefore this procedure will not be e cient.
The question arises therefore, whether there is a small subset of models which still guarantees correct results when used with the model checking procedure.Such a subset is called the set of characteristic models of W and its existence has been proved (Kautz et al., 1995;Khardon & Roth, 1994).In our example this set is: char(W) = f0010; 0101; 1001; 1010; 1100; 1101; 1111g; so it includes 7 out of the 11 models of W. Model checking with this set is guaranteed to produce correct results for any which is a Horn expression, and using a slightly more complicated algorithm one can answer correctly for every (Kautz et al., 1995).In our example, it is easy to check that (cd !a) is evaluated to \truth" on all the assignments in char(W) and that (bd !a) is falsi ed by 0101.
The utility of these representations, Horn expressions and characteristic models, is not comparable.Each of these representations has its advantages over the other.First, the size of these representations is incomparable.There are short Horn expressions for which the set of characteristic models is of exponential size, and vice versa, there are also exponential size Horn expressions for which the set of characteristic models is small (Kautz et al., 1995).The representations also di er in the services which they support.On one hand, Horn expressions are more comprehensible.On the other hand characteristic models are advantageous in that they allow for e cient algorithms for abduction and default reasoning.In this paper we are asking how hard it is to translate between these representations, so as to enjoy the bene ts of both.

Overview of the Paper
In this paper we study the complexity of the translation problems CCM and SID.For these problems, the output may be exponentially larger than the input.Therefore, it is appropriate to ask whether there are algorithms which can perform the above tasks in time which is polynomial in both the input size and the output size.These are called output polynomial algorithms.
Before starting our investigation we note that it has been shown (Kautz et al., 1995) that using the set of characteristic models one can answer abduction queries related to H in polynomial time, while given the formula H it is NP-Hard to perform abduction (Selman & Levesque, 1990).This however does not imply that computing the set of characteristic models is NP-Hard since the construction in the proof yields a Horn formula whose set of characteristic models is of exponential size.
Our main result says that CCM and SID are equivalent to each other, and are also equivalent to the corresponding decision problem.The problem of Characteristic Models Identi cation (CMI), is the problem of deciding, given a Horn expression H and a set of models G, whether G = char(H).We show that CCM, SID, and CMI are equivalent under polynomial reductions.Namely, the translation problems are solvable in polynomial time if and only if the decision problem is solvable in polynomial time.These are new results which have immediate corollaries in the database domain.
We then show a close relationship between these problems and the Hypergraph Transversal Problem (HTR).Given a hypergraph G a transversal of its edges is a set of nodes which touches every edge in the graph.In the HTR problem one is given a hypergraph as an input, and is required to compute the set of minimal transversals of its edges.
The HTR problem has a lot of equivalent manifestations which appear in various branches of computer science.Examples in AI include computing abductive diagnoses (Reiter, 1987), enumerating prime implicants in ATMS (Reiter & De Kleer, 1987), and Horn approximations (Kavvadias et al., 1993) which are closely related to characteristic models.Other areas include database theory (Mannila & Raiha, 1986), Boolean complexity, and distributed systems (Eiter & Gottlob, 1991).A comprehensive study of these problems is presented by Eiter and Gottlob (1994).HTR is also equivalent to the problem of dualization of monotone Boolean expressions, which is the form in which we present it here.This problem, requires translation between the CNF and DNF representations of monotone functions.
The complexity of the HTR problem has been studied before (Fredman & Khachiyan, 1994;Eiter & Gottlob, 1994;Kavvadias et al., 1993) and is still an open question.On one hand a class of problems which are \HTR complete" has been de ned and studied (Eiter & Gottlob, 1994).This class includes many problems from various application areas which are equivalent to HTR (under polynomial reductions).On the other hand the problem is probably not NP-Complete.Recently, Fredman and Khachiyan (1994) have presented a sub-exponential n O(logn) time algorithm for the HTR problem.
We rst show that the problem CCM is at least as hard as HTR.By that we mean that if there is an output polynomial algorithm for CCM then there is an output polynomial algorithm for HTR.This has been stated as an open problem by Kavvadias et. al. (1993), who proved a similar hardness result for SID.Both hardness results can be alternatively derived by combining previous results in database theory (Eiter & Gottlob, 1994;Bioch & Ibaraki, 1993) and its relation to our problems (Khardon et al., 1995).
We then consider two relaxations of these translation problems.The rst is considering redundant Horn expressions which contain all the Horn prime implicates for a given expression.The output of SID is therefore altered to be the set of all prime implicates, and similarly the input of CCM includes all the prime implicates instead of a minimal subset.It is shown that in this special case, SID, CCM, and HTR are equivalent under polynomial reductions.Therefore, the algorithm presented by Fredman and Khachiyan (1994) can be used to solve CCM, and SID in time n O(logn) .This result can be alternatively derived from the results on functional dependencies in MAK form (Eiter & Gottlob, 1991).We show however that our argument generalizes to the larger family of k-quasi Horn expressions.
The second relaxation is the problem of computing all the prime implicants for a given Horn expression.This is a relaxation of CCM since using the prime implicants one can compute the characteristic models.Interestingly, the algorithm for HTR (Fredman & Khachiyan, 1994) can be adapted to this problem, resulting an algorithm with time complexity n O(log 2 n) .
It is shown, however, that both relaxations do not help in solving the general cases of CCM and SID due to exponential gaps in the size of the corresponding representations.
Lastly, we consider a related problem, denoted EOC, which is a minor modi cation of CCM and SID.This problem is shown to be co-NP-Complete.This serves to highlight some of the di culty in nding the exact complexity of our problems.A variant of this result, has already appeared in the database literature (Gottlob & Libkin, 1990).Our results are summarized in Figure 1, where a hierarchy of problems is depicted.The problem EOC is co-NP-Complete.The problem CMI is a special case of EOC, and is equivalent to SID and CCM.The problem HTR is a special case of CMI and is equivalent to SID and CCM under the restriction that the Horn expression is represented by the set of all prime implicates.
The rest of the paper is organized as follows.Section 2 de nes characteristic models, describes some of their properties, and formally de nes the problems in question.Section 3 discusses the relation between CCM,SID and the corresponding decision problem.Section 4 discusses the relation to the HTR problem.We rst establish the hardness result, and then consider the two relaxations mentioned above.Section 5 shows that EOC is co-NP-Hard, and Section 6 concludes with a summary.

Preliminaries
This section includes the basic de nitions, and introduces several previous results which are used in the paper.
We consider Boolean functions f : f0; 1g n !f0; 1g.The elements in the set fx 1 ; : : :; x n g are called variables.Assignments in f0; 1g n are denoted by x; y; z, and weight(x) denotes the number of 1 bits in the assignment x.A literal is either a variable x i (called a positive literal) or its negation x i (a negative literal).A clause is a disjunction of literals, and a CNF formula is a conjunction of clauses.For example (x 1 _x 2 ) ^(x 3 _ x 1 _ x 4 ) is a CNF formula with two clauses.A term is a conjunction of literals, and a DNF formula is a disjunction of terms.For example (x 1 ^x2 ) _ (x 3 ^x1 ^x4 ) is a DNF formula with two terms.A CNF formula is Horn if every clause in it has at most one positive literal.A formula is monotone if all the literals that appear in it are positive.The size of CNF and DNF representations is, respectively, the number of clauses and the number of terms in the representation.We denote by jDNF(f)j the size of the smallest DNF representation for f.
An assignment x 2 f0; 1g n satis es f if f(x) = 1.Such an assignment x is also called a model of f.By \f implies g", denoted f j = g, we mean that every model of f is also a model of g.Throughout the paper, when no confusion can arise, we identify a Boolean function f with the set of its models, namely f 1 (1).Observe that the connective \implies" (j =) used between Boolean functions is equivalent to the connective \subset or equal" ( ) used for subsets of f0; 1g n .That is, f j = g if and only if f g.
A term t is an implicant of a function f, if t j = f.A term t is a prime implicant of a function f, if t is an implicant of f and the conjunction of any proper subset of the literals in t is not an implicant of f.
A clause d is an implicate of a function f, if f j = d.A clause d is a prime implicate of a function f, if d is an implicate of f and the disjunction of any proper subset of the literals in d is not an implicate of f.
It is well known that, a minimal DNF representation of f is a disjunction of some of its prime implicants.A minimal CNF representation of f is a conjunction of some of its prime implicates.
If f is monotone, then it has a unique minimal DNF representation (using all the prime implicants), and a unique minimal CNF representation (using all its prime implicates).
For u; v 2 f0; 1g n , we de ne the intersection of u and v to be the assignment z 2 f0; 1g n such that z i = 1 if and only if u i = 1 and v i = 1 (i.e., the bitwise logical-and of u and v.).
For a set of assignments S, x = intersect(S) is the assignment we get by intersecting all the assignments in S. We say that S is redundant if there exists x 2 S and S 0 S such that x 6 2 S 0 and x = intersect(S 0 ).Otherwise S is non-redundant.
The closure of S f0; 1g n , denoted closure(S), is de ned as the smallest set containing S that is closed under intersection.
Let H be a Horn expression.The set of the Horn characteristic models of H, denoted here char(H) is de ned as the set of models of H that are not the intersection of other models of H.Note that char(H) is non-redundant.Formally, char(H) = fu 2 H j u 6 2 closure(H n fug) g: (1) For example, char(f1101; 1110; 0101; 0100g) = f1101; 1110; 0101g.
It is well known that the set of models of Horn expressions is closed under intersection.This result is due to McKinsey (1943), who proved it for a certain class of rst order sentences.Alfred Horn (1951) considered a more general class of sentences.(Lemma 7 by Horn (1951) deals with the propositional case.Dechter and Pearl (1992) present another proof for the propositional case.)Moreover, since characteristic models capture all the information about the closure, they also capture all the information about the Horn expression.

Monotone Theory and Characteristic Models
The monotone theory was introduced by Bshouty (1993), and was later used for a theory for model-based reasoning (Khardon & Roth, 1994).This section explores the relations between the monotone theory and characteristic models.
De nition 1 (Order) We denote by the usual partial order on the lattice f0; 1g n , the one induced by the order 0 < 1.That is, for x; y 2 f0; 1g n , x y if and only if 8i; x i y i .For an assignment b 2 f0; 1g n we de ne x b y if and only if x b y b (Here is the bitwise addition modulo 2).We say that x > y if and only if x y and x 6 = y.
Intuitively, if b i = 0 then the order relation on the ith bit is the normal order; if b i = 1, the order relation is reversed and we have that 1 < b i 0. For example 0101 < 1111 0100, and 0101 6 < 1111 0110.We now de ne: The monotone extension of z 2 f0; 1g n with respect to b: M b (z) = fx j x b zg: The monotone extension of f with respect to b: M b (f) = fx j x b z; for some z 2 fg: The set of minimal assignments of f with respect to b: min b (f) = fz j z 2 f; such that 8y 2 f; z 6 > b yg: For example M 1111 (0101) = f0101; 0001; 0100; 0000g; and M 1111 (1100) = f1100; 0100; 1000; 0000g: Let f = bc(a _ d)(a _ d), then in the set notation f = f1100; 0101g, and M 1111 (f) = f0101; 0001; 0100; 0000; 1100; 1000g.The set min 1111 (f) = f1100; 0101g, and the set min 0001 (f) = f0101g.
Clearly, for every assignment b 2 f0; 1g n , f M b (f).Moreover, if b 6 2 f, then b 6 2 M b (f) (since b is the smallest assignment with respect to the order b ).Therefore: The question is if we can nd a small set of negative examples, and use it to represent f as above.De nition 2 (Basis) A set B is a basis for f if f = V b2B M b (f).B is a basis for a class of functions F if it is a basis for all the functions in F.
Using this de nition, we get an alternative representation for functions (2) It is known that the set B H = fu 2 f0; 1g n j weight(u) n 1g, is a basis for any Horn CNF function.For example consider the Horn expression W = (bc !d)(cd !b)(bc !a) discussed in the introduction.Recall that the satisfying assignments of W are: models(W) = f0000; 0001; 0010; 0100; 0101; 1000; 1001; 1010; 1100; 1101; 1111g: We have to compute the sets min b (W) for b 2 B H , where B H = f1111; 1110; 1101; 1011; 0111g.Note that if b satis es f then min b (f) = fbg, and M b (f) 1 (that is, 8x, M b (f)(x) = 1).Therefore, min 1111 (W) = f1111g, and min 1101 (W) = f1101g.One way to compute the sets of minimal assignments is by drawing the corresponding lattices and noting the relations there.Figure 2 shows the lattice with respect to b = 0111.The satisfying assignments of W are marked in bold face.The minimal assignments are underlined, and some of the order relations, which show that the rest of the assignments are not minimal, are drawn.To compute M b (W) we have to add any assignment which is above the minimal assignments.This is marked by the dotted lines which show that 1011 and 1110 are in M 0111 (W).Using the gure we observe that min 0111 (W) = f1111; 0101; 0010g.The other sets are min 1110 (W) = f1111; 1100; 1010g, and min 1011 (W) = f1111; 1001; 1010g.
It is known that the size of the basis for a function f is bounded by the size of its CNF representation, and that for every b the size of min b (f) is bounded by the size of its DNF representation.
For any function f and set of assignments B let: The following theorem gives an alternative way to de ne char(H).
Continuing the above example with the function W = (bc !d)(cd !b)(bc !a), we conclude that char(W) = f0010; 0101; 1001; 1010; 1100; 1101; 1111g.As the following theorem shows the set of characteristic models can be used to answer deduction queries.
It is useful to have the DNF representation of a function.If f is given in its DNF representation then it is easy to compute the set min b (f), for any b.Each term in the DNF representation can contribute at most one assignment, min b (t), where the variables that appear in the term are xed and the others are set to their minimal value.This is true since from every other satisfying assignment of the term we can \walk down the lattice" towards this assignment, on a path composed of satisfying assignments.For example, the minimal assignment for the term t = x 1 x 3 , with respect to the basis element b = 0011, is min 0011 (t) = f1001g.The assignment 1100 which also satis es t is not minimal since 1001 < 0011 1101 < 0011 1100.Further, once we have one assignment from each term, it is easy make sure that the set is non-redundant by checking which of the assignments generated is in the intersection of the others.We would use this algorithm later in some of our reductions.
We say that a function is b-monotone if it is monotone according to the order relation b .Namely, if whenever f(x) = 1 and y b x then f(y) = 1.Notice that if we rename the variable x i by its negation, for each i such that b i = 1 (i.e.where the order relation is reversed), then f becomes monotone.Therefore, b-monotone functions enjoy similar properties.For example, they have unique minimal DNF and CNF representations.Another property is that the minimal assignment which corresponds to every term is indeed part of the set min b (f).
Claim 1 (Khardon & Roth, 1994) For any b-monotone function f, there is a 1-1 correspondence between the prime implicants of f and the set min b (f).Namely: (1) for every term t in the minimal DNF representation for f, the assignment min b (t) is in min b (f).
We would also use the notion of a least upper bound of a Boolean function (Selman & Kautz, 1991), which can sometimes be characterized by the monotone theory.
De nition 3 (Least Upper-bound) Let F; G be classes of Boolean functions.Given f 2 F we say that g 2 G is a G-least upper bound of f if and only if f g and there is no f 0 2 G such that f f 0 g.Theorem 4 (Khardon & Roth, 1994) Let f be any Boolean function and G a class of all Boolean functions with basis B. Then, f B lub de ned as is the G-least upper bound of f.
For the class of Horn expressions we have two ways to express the least upper bound.
One using the monotone theory, and one using the closure operator: Theorem 5 (Dechter & Pearl, 1992;Kautz et al., 1995;Khardon & Roth, 1994) Let f : f0; 1g n !f0; 1g be a Boolean function.Then f B H lub = closure(f), and char(f B H lub ) f.For example consider the function f The function f satis es all the assignments as W above except for 0001.However, intersect(f0101; 1001g) = 0001, and therefore f B H lub = W.

The Computational Problems
This section includes de nitions for all the problems discussed in this paper.Let H be a CNF expression in Horn form, and let char(H) be its set of characteristic models.

Polynomial Time Algorithms and Reductions
As mentioned above we need to de ne algorithms that are polynomial with respect to their output.There is more than one way to give such a de nition.(A discussion of this issue is given by Eiter and Gottlob (1994).)We use the weakest 1 of those which is called an output polynomial algorithm.
When the output of a problem P is uniquely de ned, we say that an algorithm A is an output polynomial algorithm for P if it solves P correctly in time which is polynomial in the size of its input and output.This is the case with HTR, and CCM.
When the output of a problem P is not uniquely de ned, we consider the shortest permissible output O(I) for input I.We say that an algorithm A is an output polynomial algorithm for P if it solves P correctly in time which is polynomial in the size of its input I and the size of O(I).We note that for SID the output is not uniquely de ned since there is no unique minimal representation for Horn functions.
We de ne polynomial reductions with respect to an oracle (i.e.we use Turing reducibility (Garey & Johnson, 1979)).A problem P1 is polynomially reducible to a problem P2 if there is an output polynomial algorithm that solves P1 when given access to (1) an output polynomial subroutine for P2, and (2) a polynomial bound 2 on the running time of the subroutine.

Translating is Equivalent to Deciding
In this section we show that the problems CCM, SID, CMI, and CMIC are equivalent under polynomial reductions.Namely, both translation problems are solvable in polynomial time if and only if the corresponding decision problem CMI is solvable in polynomial time.
Theorem 6 The problems CCM,SID,CMI, and CMIC are equivalent under polynomial reductions.
Proof: The proof is established in a series of lemmas.In particular we show that CMIC CMI SID CMIC, and that CMI CCM CMIC, where denotes \is polynomially reducible to", in Lemma 1, Lemma 2, Lemma 3, Lemma 4, and Lemma 5 respectively.
Lemma 1 The problem CMIC is polynomially reducible to the problem CMI.
Before presenting the proof consider how a similar result is achieved for the satis ability problem (Garey & Johnson, 1979).Namely, how a decision procedure for satis ability can be used to construct an algorithm that nds a satisfying assignment if one exists.Suppose 1.Other related notions which we do not use here are \enumeration with polynomial delay" and \enumeration with incremental polynomial delay" (Eiter & Gottlob, 1994).These require that the algorithm will compute the elements of its output one at a time, and restrict the time delay between consecutive outputs.Incremental polynomial delay allows the delay to depend on the problem size and on the number of elements computed so far.Polynomial delay is stricter in that it requires dependence only on the problem size.Both of these notions are stricter than output polynomial algorithms since the latter may wait a long time before computing its rst output.Unfortunately, most of our reductions yield output polynomial algorithms, and we cannot guarantee that the stronger notions hold.2. That is, a polynomial in the dimension of the problem (the number of variables), the input size, and the output size.
we have a formula C, and that we know that it is satis able.(We used the decision procedure to nd that out.)Our task is to nd a satisfying assignment for it.What we do is substitute x 1 = 0 into C yielding a formula C 0 with n 1 variables.The formula C 0 is satis able if and only if C has a satisfying assignment in which x i = 0. We run the decision procedure on C 0 .If the answer is Yes then we know that C has a satisfying assignment in which x i = 0.If the answer is No then since C is satis able, it must have a satisfying assignment in which x 1 = 1.In either case we found a substitution for x 1 which guarantees the existence of a satisfying assignment.All we have to do is to recurse with this procedure on C 0 .An example can clarify this a bit more.Suppose we have the expression C = (a_c)(b_c) which is satis able.To nd a satisfying assignment we substitute a = 0 to get C 0 = (c)(b_c), and run the decision procedure on C 0 .The answer is Yes, and therefore we continue with C 0 .We next substitute b = 0 to get C 00 = cc.We run the decision procedure again, and the answer is No. Therefore we conclude that we must substitute b = 1 instead of b = 0.This yields C 01 = c.We then continue to nd that c must be assigned 1 and altogether we nd the satisfying assignment abc = 011.
We would like to use the same trick here.However, G is given as a set of models and we cannot perform this substitution procedure as easily3 .Nevertheless, as the proof shows something similar can be done.
Proof: First observe that we have a solver for CMI.Therefore if the answer is Yes we have no problem, we can simply answer Yes.A problem arises in the case where the answer is No.In this case CMI is happy with saying No, but CMIC must provide a counter example.
Formally, we get H; G as input to CMIC and an algorithm A to solve CMI.We run A on H; G as an input, and if A replies Yes we reply Yes.Otherwise we know that there exits an x 2 char(H) n G.We need to nd such a model and return it as the output of CMIC.
Consider rst the easier task of nding x 2 H nclosure(G); the assignment x is a witness for the fact H 6 j = closure(G).
Recall the substitution trick from above, and observe that for x i = 1 a similar substitution works.For H we simply perform the substitution to get an expression H, and for G we remove any z 2 G in which z i = 0 to get the set G. We claim that there is a witness for H; G with x i = 1 if and only if there is a witness for H; G.This follows from the fact that x 2 closure(G) and x i = 1 if and only if x 2 closure( G).To see that, let x 2 closure(G), such that x i = 1; if x = intersect(S), and y 2 S then y i = 1, and therefore x 2 closure( G).Also if x 2 closure( G) then x 2 closure(G).Therefore, if there is a witness x with x i = 1 then we can detect this fact by presenting A with H; G as input (on which it will say No).This however does not work for x i = 0.In this case an element in the closure requires at least one element in S with y i = 0, but we have no information on the other elements.Therefore we can not perform the recursion in the case where substitution of x i = 0 is required.
We circumvent this problem using the following iterative procedure.In each stage we try to turn one more variable to 1.For all i, we make the experiment described above of substituting x i = 1.If the answer is No, for some i, we can proceed to the next stage, just as before (ignoring tests for other values of i).If the answer is Yes for all i, then we know that for each x i that did not receive a value so far, there is no witness with x i = 1, so the only possible witness is the one assigning 0 to all the variables.We return the witness x 2 f0; 1g n arrived at, by the above substitutions, as the counter example of CMIC.
From the construction it is clear that x 2 H n closure(G), but the requirement of CMIC is that x 2 char(H) n G.We claim that this stronger condition holds.Suppose not, and let S char(H) be such that x = intersect(S).Then clearly S is not a subset of G or otherwise x 2 closure(G).Let y 2 S n G, then since x = intersect(S), we get x < 0 n y.Namely, if x i = 1 then y i = 1.But this is a contradiction, since in the last run of the algorithm A for CMI, it was concluded that no more variables could be set to 1, while still maintaining a witness.
We exemplify the proof using the function W = (bc !d)(cd !b)(bc !a) presented in the introduction.Recall that char(W) = f0010; 0101; 1001; 1010; 1100; 1101; 1111g, and suppose that so far we found G = f0010; 1001; 1010; 1100; 1101; 1111g.That is, all but the model 0101.We run CMI on W; G and, since G does not include all the characteristic models, it answers No.In order to nd the counter example we make 4 separate substitutions, one for each variable substituted to 1.
Consider the substitution with b = 1.This yields W = (c !d)(c !a), and G = f1s00; 1s01; 1s11g, where we use s to mark that the variable b was substituted.We run CMI on W; G and it nds out that there is a counter example (the assignment 0s01 is in W but not in closure( G)), and therefore it answers No.That means we can continue our algorithm with b = 1.We forget all the information from the other substitutions (that were not considered in detail) and continue to the next step.
In the next step we substitute 1 to each of a; c; d.Consider rst the substitution for a.This yields W = (c !d) and G = fss00; ss01; ss11g.Running CMI on this pair we get the answer Yes.Namely W = closure( G).Consider now the substitution for d.This yields W = (c !a) and G = f1s0s; 1s1sg.Running CMI on this pair we get the answer No (since 0s0s is a counter example).We can therefore recurse on this value.
In the next iteration both substitutions for a and for c, yield the answer Yes, and therefore we substitute 0 to both to get the nal counter example abcd = 0101.
Using this example it is easy to see that one can improve the running time of the reduction by simply remembering the attributes for which we received the answer Yes.These attributes will have to get the value 0 in the end.In this way we can scan the variables one by one, and recurse on the rst that yields the answer No.This requires only n calls to CMI.
Lemma 2 The problem CMI is polynomially reducible to the problem SID.
Proof: We are given an output polynomial time algorithm A for SID, and a polynomial bound on its running time (that is, a polynomial in the number of variables n, the input size, and the output size).Given H; G as input to CMI, we run A on G until it stops and outputs H 0 or until it exceeds its time bound (with respect to the size of H).In the rst case we check whether H = H 0 (which can be done in polynomial time (Dowling & Gallier, 1984)) and answer accordingly.In the second case we know that the real Horn expression which corresponds to G is larger than H and therefore we answer No.
The proof of the next lemma draws on previous results in computational learning theory.
In this framework a function f : f0; 1g n !f0; 1g is hidden from a learner that has to reproduce it by accessing certain \oracles".A membership query allows the learner to ask for the value of the function on a certain point.
De nition 4 A membership query oracle for a function f : f0; 1g n !f0; 1g, denoted MQ(f), is an oracle that when presented with x 2 f0; 1g n returns f(x).
An equivalence query allows the learner to nd out whether a hypothesis he has is equivalent to f or not.In case it is not equivalent, the learner is supplied with a counter example.
De nition 5 An equivalence query oracle for a function f : f0; 1g n !f0; 1g, denoted EQ(f), is an oracle that when presented with a hypothesis h : f0; 1g n !f0; 1g, returns Yes if f h.Otherwise it returns No and a counter example x such that f(x) 6 = h(x).
We use a result that has been obtained in this framework.
Theorem 7 (Angluin, Frazier, & Pitt, 1992) There is an algorithm A, that when given access to MQ(f) and EQ(f), where f is a hidden Horn expression, runs in time polynomial in the number of variables and in the size of f, and outputs a Horn expression H which is equivalent to f.
The hypothesis h, in the algorithm's accesses to EQ(f), is always a Horn expression.
Lemma 3 The problem SID is polynomially reducible to the problem CMIC.
Proof: We are given G as input to SID, and a polynomial time algorithm C for CMIC.
Our algorithm will run the algorithm A from Theorem 7 and answer the MQ and EQ queries that A presents.Given x 2 f0; 1g n for MQ the algorithm tests whether x 2 closure(G).This can be done by testing whether x is equal to the intersection of all elements y in G such that y x.
Given a Horn expression h for EQ (the theorem guarantees that the hypothesis is a Horn expression), we have to test whether h closure(G).We rst test whether closure(G) h, which is equivalent to closure(G) j = h.Theorem 5 together with Theorem 3 imply that if the answer is No, then for some x 2 G, h(x) = 0.Such an x is a counter example for the equivalence query, and the test can be performed simply by evaluating h on all the assignments in G.
If closure(G) j = h, namely all the assignments in G satisfy h, we present h; G as input to the algorithm C for the problem CMIC.The input to CMIC is legal.C may answer Yes, meaning char(h) G, which implies h closure(G).In this case we answer Yes to the equivalence query.Otherwise C says No and supplies a counter example x 2 char(h) n G. Since G h we get x 2 hnclosure(G) and therefore we can pass x on as a counter example to the equivalence query.
We next consider the problem CCM: Lemma 4 The problem CMI is polynomially reducible to the problem CCM.Proof: We are given an output polynomial algorithm C for CCM, and a polynomial bound on its running time (that is, a polynomial in the number of variables n, the input size, and the output size).Given H; G as input to CMI, we run C on H until it stops and outputs G 0 or until it exceeds its time bound (with respect to the size of G).In the rst case we compare G and G 0 and answer accordingly.In the second case we know that the set of characteristic models of H is larger than G and therefore we answer No.
Lemma 5 The problem CCM is polynomially reducible to the problem CMIC.Proof: Given H as input for CCM, an algorithm for CMIC can be used repeatedly to produce the elements of char(H).
We start with G = ;.In each iteration we run CMIC on H; G to get a new characteristic model which we add to G. Once we nd all the characteristic models CMIC will answer Yes.
(In fact, if CMIC is polynomial in its input size then we get an \incremental polynomial algorithm" (Eiter & Gottlob, 1994) which is even stronger than \output polynomial" as required here.)

The Relation to Hypergraph Transversals
In this section we establish the relation to the hypergraph transversal problem.We rst show that our problems are at least as hard as HTR.We then consider two relaxations of SID and CCM.The rst relaxation considers redundant representation for Horn expressions, which includes all the prime implicates.The second relaxation considers computing prime implicants instead of characteristic models.Both of these relaxations enjoy sub-exponential algorithms.It is shown, however, that the relaxations do not help in the general case, as a result of exponential gap in the size of the corresponding representations.

The Reduction to HTR
The problem HTR is de ned as computing a DNF representation for a monotone function given in its CNF form.It is easy to observe that this is equivalent to computing a CNF representation for a monotone function given in its DNF form.(We can simply exchange the _ and ^operations to get one problem from the other).We can therefore assume that the input for HTR is given as either a DNF or a CNF.Another useful observation is that renaming the variables does not change the problem.Therefore if we rename every variable as its negation (namely, replace every x i with x i ), we get the equivalent problem of translating between functions which are monotone with respect to the order relation 1 n.We call such functions anti-monotone.This is useful since anti-monotone functions have CNF representations in which all variables are negated, which is a special case of Horn expressions.Having these observations, the next two theorems follow almost immediately from the de nitions, given the correspondence between minimal elements and prime implicants described in Claim 1.The following result has been stated as an open problem by Kavvadias et. al. (1993).
Theorem 8 The problem HTR is polynomially reducible to the problem CCM.Proof: Let A be an algorithm for the problem CCM.We construct an algorithm B for the problem HTR.We may assume that the input is an anti-monotone CNF, C, and we want to compute its anti-monotone DNF representation.
The basic idea is that using Claim 1 we know how to compute the DNF from min 1 n(C), and that the latter is a subset of the characteristic models.So all we need to do is let A compute the characteristic models, identify the set min 1 n(C), and compute the DNF.
More formally, the algorithm B runs A to compute = char(C) = min B H (C), and computes the set 1 n = fz 2 j 8y 2 ; z 6 < 1 n yg.Namely the elements of which are minimal with respect to the order relation b = 1 n .It then computes the anti-monotone DNF expression D = _ z2 1 n ^zi =0 x i , which it outputs.
The correctness of the algorithm follows from Claim 1 which guarantees that the computation of the DNF from the set of characteristic models is correct.
As for the time complexity we observe, using Claim 1, that is not considerably larger than the size of the DNF.This is true since for all b, jDNF(f)j = jmin 1 n(f )j jmin b (f)j, and jB H j = n + 1.
To exemplify the above reduction, suppose that we have only three variables a; b; c, and that the input is C = (a _ b)(b _ c).(The satisfying assignments are 000; 001; 010; 100; 101, and the required DNF expression is a c _ b.)The algorithm A will compute the set of characteristic models char(C) = f101; 010; 100; 001g, from that we nd that min 1 n(C) = f101; 010g.The term which corresponds to 101 is b, and the term which corresponds to 010 is a c and indeed we get the right DNF expression.
Using the monotone theory one can give a simple proof for the following theorem, which has already been proved by Kavvadias et. al. (1993).
Theorem 9 (Kavvadias et al., 1993) The problem HTR is polynomially reducible to the problem SID.
We note that both theorems can be deduced by combining results in database theory (Eiter & Gottlob, 1994, 1991;Bioch & Ibaraki, 1993) and using the above mentioned equivalence with problems in database theory (Khardon et al., 1995).

Enumerating Prime Implicates
Having obtained the hardness results in the previous sub-section, a natural question is whether CCM, and SID are as easy as HTR.This would help settle the exact complexity of the problems discussed, and more importantly would imply a sub-exponential algorithm for the problem.While no such reduction has been found, we show here that it holds in a special case.We show, however, that the solution obtained in this way may need exponential time in the general case.
This result has already been obtained in the database domain (Eiter & Gottlob, 1991), where restrictions of functional dependencies to be in MAK form is discussed.Our argument, however, can be generalized to richer languages, and in particular holds for the family of k-quasi Horn expressions de ned below.
In particular we relax the problems so as to use the largest Horn expression for a function instead of using a small Horn expression.In this case the problem SID amounts to computing all the (Horn) prime implicates of the function identi ed by .For CCM we have to compute the set of characteristic models given the set of all prime implicates rather than a small expression.
We would use the following example to illustrate the notions in this sub-section.Con- The satisfying assignments of W are W = f0000; 0001; 0100; 0110; 1100; 1110g, and the characteristic models are char(W) = f0001; 0110; 1100; 1110g.One can verify that W j = (c _ d)(a _ d), and that these are the only additional Horn prime implicates of W.
For CCM, this section asks whether it is easier to compute the characteristic models starting with the equivalent expression W = (a !b)(c !b)(b_d)(c_d)(a_d).For SID the question is whether it is easier to output the whole set rather than just a minimal subset.These are relaxations of the problems since, an algorithm for SID is allowed more time to compute its output, and CCM is given more information and more time for its computation.
Let f be a Horn expression, then using the monotone theory representation (Equation ( 2)) we know that f = ^b2B H M b (f): (3) Recall that B H = fu 2 f0; 1g n j weight(u) n 1g, and denote by b (i) , 1 i n, the assignment with x i set to zero and all other bits set to 1, and by b (0) the assignment 1 n .In our example b (0) = 1111, and b (1) = 0111.Let D i be the set of clauses that are falsi ed by b (i) , and let G i denote the language of all CNF expressions with clauses from D i .In our example, with four variables a; b; c; d, clauses in D 1 may have b; c; d as negative literals and a as a positive literal.That is, (a _ b) 6 2 D 1 , but (a _ b) 2 D 1 and (b _ c) 2 D 1 .
Theorem 4 implies that M b (i) (f) is equal to the least upper bound of f in G i .Namely, the intersection of all clauses in D i which are implied by f.De ne PI(f; i) to be the set of prime implicates of f with respect to b (i) .Formally: PI(f; i) = fd 2 D i jf j = d and 8d 0 d; f 6 j = d 0 g: Using this notation we get: (4) Going back to the example W, we have: PI(W; 4) = true.Note that the partition of the prime implicates of f is not disjoint.In particular, the anti-monotone prime implicates (except for x 1 _ x 2 _ : : : _ x n if it is a prime implicate) appear in several PI(f; i) sets.Equation (3) tells us that we can decompose the function into n + 1, b (i) -monotone functions.Equation (4) tells us how to decompose the clauses of the function, and the monotone theory tells us how to decompose the characteristic models.These observations lead to the following theorem: Theorem 10 The problem CCM, when the input is given as the set of all Horn prime implicates, is polynomially equivalent to HTR.
Proof: First observe that the reduction in Theorem 8 uses an anti-monotone function, which has a unique Horn representation.Namely the smallest and the largest representations are the same in this case.This implies that the problem remains as hard as HTR in this special case.
For the other direction, we rst partition the input into the sets PI(f; i), and then use a procedure for HTR in order to translate each set to a DNF representation.Then using Claim 1 we translate the DNF expression to the set of minimal assignments.The crucial point is that we have DNF representations for the functions M b (i) (f) rather than for f.This implies that each term in these DNF representations is represented as an element in char(f) and therefore the reduction is polynomial.(We may get some of the elements in char(f) more than once, but at most n times, which is still polynomial.) In our example, we get the following DNF expressions and their translation into assignments: Theorem 11 The problem SID, when the output required is all Horn prime implicates, is polynomially equivalent to HTR.
Proof: The proof is similar to the proof of the previous theorem.The hardness follows from Theorem 9.
For the other direction, assume we get as input a set , and an algorithm A for HTR.We rst partition into sets i according to minimality with respect to b (i) .(Note that the sets are not disjoint.)Then we use Claim 1 to transform each i into a DNF expression for the function M b (i) (f).For each such DNF expression we run the procedure A to compute its CNF representation.By Equation (3), the intersection, with respect to i, of these CNF expressions is the Horn expression we need.
In the example, we simply start with the sets i and use the same equations as above going in the other direction.From the above two theorems we get the following corollary.
Corollary 1 The problems CCM and SID, when the Horn expression is represented as the set of all Horn prime implicates, are polynomially equivalent, and are polynomially equivalent to HTR. the set of characteristic models for f (Khardon & Roth, 1994).The generalized versions of CCM and SID, when restricted to hold all prime implicates are still equivalent to HTR.

Enumerating Prime Implicants
As mentioned above, given a DNF representation for f we can easily compute the set of characteristic models.One might therefore try to solve CCM by rst translating the Horn expression into a DNF expression and then computing the characteristic models from this set.Another possible relaxation is to rst compute all the prime implicants of the function and then to extract a DNF representation from it.We consider this problem here.Namely, we consider the problem of enumerating all the prime implicants of a Horn expression, and its application for the solution of CCM.
While we have not found a general reduction from this problem to HTR, a simple adaption of the algorithm for HTR (Fredman & Khachiyan, 1994) yields an incremental n O(log 2 n) algorithm for this problem.However, as we discuss below, enumeration of prime implicants of a Horn expression is not su cient for solving CCM.The problem in such an application is an exponential gap in the sizes of these representations.
For completeness we sketch the main ideas of the enumeration algorithm here.Let H be a Horn expression, and let D be the DNF expression composed of the prime implicants enumerated so far.The algorithm nds an assignment x which satis es H and does not satisfy D. Using x it is easy to nd a new prime implicant of H.The algorithm to nd x uses the following combinatorial fact (Fredman & Khachiyan, 1994): either there is a variable x i that appears in H ^D with high frequency, or the expression H ^D has \a lot" of satisfying assignments.In the rst case, one can recursively solve two sub-problems arrived at by substituting x i = 0, and x i = 1 in the expressions H and D. In the second case it is easy to nd an assignment x (e.g. by sampling).The solution of the recursion yields the stated time bound.For complete details we refer the reader to the article by Fredman and Khachiyan (1994).While the analysis there is specialized for monotone functions it is easy to extend (the rst part of) it for Horn expressions 4 .
Lifting the Restriction: Denote by #PIs(f) the number of prime implicants of f.While the representations (1) Prime Implicants (PIs), (2) DNF representation, and (3) Characteristic models, satisfy the inequalities #PIs(f) jDNF(f)j jchar(f)j=n, each of the inequalities may allow for an exponential gap.The function f 1 = (x 1 _ x 2 : : : _ x p n 1 _ x p n ) ^: : : ^(x n p n+1 _ x n p n+2 _ : : : _ x n 1 _ x n ) (Khardon & Roth, 1994) shows a gap between (2) and (3).The function f 2 = x 1 x 2 : : :x m _ x 1 y 1 _ x 2 y 2 _ : : : _ x m y m (Aizenstein & Pitt, 1995) shows a gap between (1) and ( 2).(To observe that, notice the similarity between f 2 and the dual of the function from the previous sub-section.)Both functions are Horn (for f 2 by multiplying out we see that every clause for f is Horn,4.One caveat that we have to tackle is enumerating prime implicants after D is already equivalent to H. This can be done using \consensus" operations, which can generate all the prime implicants (Aizenstein & Pitt, 1995) although its Horn expression is large) and both have a small set of characteristic models.These examples show that enumeration of prime implicants may be an ine cient way for producing the characteristic models for some functions.

A Related Problem
In this section we show that a related problem, which is a minor variant of CCM and SID, is co-NP-Complete.Recall the de nition of EOC: EOC: Entailment of Closure Input: a Horn CNF H, a set G of assignments.
Output: Yes if and only if H j = closure(G).
The important di erence between CMI and EOC is that the set G is not required to include only satisfying assignments of H.This enables the following reduction for EOC, while the complexity of CMI is still open.A similar result in the database domain has been obtained by Gottlob and Libkin (1990).
Theorem 12 The decision problem EOC is co-NP-Complete.Proof: The problem is trivially in co-NP (guess an assignment x and say \No" if x 2 H n closure(G)).
To show its hardness we reduce co-Monotone 3-SAT to EOC.Monotone 3-SAT (Garey & Johnson, 1979) is the problem of satis ability of CNF formulas in which in every clause (has 3 literals and) either all the literals are positive (we call these clauses monotone) or all the literals are negated (we call such clauses anti-monotone).Let f = M ^A an instance of Monotone 3-SAT where M denotes a conjunction of monotone clauses and A is a conjunction of anti-monotone clauses.We translate it to the instance of EOC: H = A and = b2B H min b (M).First we claim that the reduction is polynomial.Note that since M is a monotone CNF, M is a DNF formula in which all the variables are negated, and can therefore be written as an anti-monotone CNF formula.This implies that M is Horn, but we have it in a DNF representation.Further computing is easy given the DNF representation of M, and its size is bounded by (n + 1) times the number of clauses in M.
We now claim that f is satis able if and only if H 6 j = closure( ).Assume rst that f is satis able, and let x 2 A ^M.This implies that x 2 H and x 6 2 M. Since M is Horn, and the models of Horn functions are closed under intersection (Theorem 1) we get that x 6 2 closure(M), and since M x 6 2 closure( ).Therefore, H 6 j = closure( ).
For the other direction assume H 6 j = closure( ), and let x be an assignment such that x 2 H and x 6 2 closure( ).We get that x 2 A, and since by Theorem 1 and Theorem 2 M = closure( ) we have x 6 2 M. So, x 2 A ^M and f is satis able.The satisfying assignments of M are 0000; 0001; 0100, and = char(M) = f0001; 0100g.Now consider the assignment x = 1000 which satis es f.Clearly, x satis es H, and one can check that it is not in the closure of .

Conclusions
Horn expressions and characteristic models are two alternative representations for the same information and none of the two dominates the other in the computational services it can support.The same representations occur in database theory where they have a role in the design of relational databases.A natural question is whether we can translate back and forth between these representations so as to enjoy the bene ts of both worlds.In this paper we have studied the computational complexity of these problems.
Our main result is that the two translation problems CCM, and SID, are equivalent to each other (under polynomial reductions), and that they are equivalent to the corresponding decision problem CMI.Namely, translating in either direction is equivalent to deciding whether a given set of models is the set of characteristic models for a given Horn expression.
We have also shown a close relation between our problems and the hypergraph transversal problem HTR.This is a translation problem which is related to many applications in computer science and in particular to AI.We have shown that in general CCM, and SID are at least as hard as HTR, and that in a special case CCM, SID, and HTR are equivalent.
We exhibited examples which show that simple algorithms for enumerating prime implicants cannot guarantee e cient solution for CCM, and similarly enumerating prime implicates may not be e cient for SID.Lastly, we discussed the problem EOC, a minor modi cation of CMI, which is co-NP-Complete.The complexity hierarchy of the problems discussed is depicted in Figure 1.
Some of the results presented in this paper can be obtained from previous results in database theory, using the equivalence between Armstrong relations and characteristic models reported in a companion paper (Khardon et al., 1995).However, our proofs and exposition make these results much more accessible.
The exact complexity of CMI, and that of HTR are left as open problems.While HTR has a sub-exponential algorithm, the problems CMI might still be co-NP-Hard.

Figure 1 :
Figure 1: Summary of Complexity Results
The condition is equivalent to H j = closure(G), and essentially also to G = char(H).
The translation problems considered are: CCM: Computing Characteristic Models Input: a Horn CNF H. Output: the set char(H).SID: Structure Identi cation (Computing Horn Expressions) Input: a set of assignments .Output: a Horn CNF H, such that = char(H).HTR: Hypergraph Transversals (Dualization of Monotone Expressions) Input: a monotone CNF expression C. Output: a monotone DNF expression D, such that C D. The decision problems discussed: CMI: Characteristic Models Identi cation Input: a Horn CNF H, and a set G of satisfying assignments of H. Output: Yes i char(H) G. Note: Input: a Horn CNF H, a set G of satisfying assignments of H. Output: If Char(H) G then output Yes.Otherwise, output No and supply a counter example x 2 Char(H) n G.