computing weighted solutions in asp: representation ... -...

35
Noname manuscript No. (will be inserted by the editor) Computing Weighted Solutions in ASP: Representation-Based Method vs. Search-Based Method Duygu Cakmak · Esra Erdem · Halit Erdogan Received: date / Accepted: date Abstract For some problems with too many solutions, one way to obtain the more desirable solutions is to assign each solution a weight that characterizes its importance quantitatively, and then compute the solutions whose weights are over (resp. below) a given threshold. This paper studies computing weighted solutions for a given computational problem, in the context of Answer Set Programming (ASP). In particular, we investigate two sorts of methods for computing weighted solutions: one method suggests modifying the ASP rep- resentation of the problem to compute weighted solutions using an existing ASP solver and the other suggests modifying the search algorithm of the answer set solver to com- pute weighted solutions incrementally. The applicability of these methods are shown on two sorts of problems: reconstructing weighted phylogenies (for Indo-European languages and for Quercus species) and finding weighted plans (for Blocks World planning problems). In the experiments with the representation-based method, the answer set solver CLASP is used and weight functions are represented in ASP. For the search-based method, the algorithm of CLASP is modified (the modified solver is called CLASP- W) and weight functions are im- plemented in C++. For phylogenies, two weight functions are introduced by incorporating domain-specific information about groupings of species; one of them cannot be represented in ASP due to some mathematical functions not supported by the ASP solvers. For plans, we define a weight function that characterizes the total cost of executing actions in a plan. In these experiments the following are observed. With weight measures that can be represented in ASP, the search-based method outperforms the representation-based method in terms of computational efficiency (both time and space). With weight functions that cannot be repre- sented in ASP, the search-based method provides a tool for computing weighted solutions in ASP. The search-based method can be applied to different domains, without modifying the algorithm of CLASP- W; in that sense, the search-based method is modular and can be useful to other ASP applications. With either method, plausible phylogenies among many can be found without computing all phylogenies and requiring historical linguists to go over them manually, and less costly plans can be found without computing all plans; in that sense, our methods contribute to phylogenetics and AI planning studies as well. Keywords weighted solutions, answer set programming, weighted phylogenies, weighted plans Faculty of Engineering and Natural Sciences, Sabancı University, Istanbul, Turkey E-mail: {duygucakmak,esraerdem,halit}@sabanciuniv.edu

Upload: others

Post on 04-Sep-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

Noname manuscript No.(will be inserted by the editor)

Computing Weighted Solutions in ASP:Representation-Based Method vs. Search-Based Method

Duygu Cakmak · Esra Erdem · Halit Erdogan

Received: date / Accepted: date

Abstract For some problems with too many solutions, one way to obtain the more desirablesolutions is to assign each solution a weight that characterizes its importance quantitatively,and then compute the solutions whose weights are over (resp. below) a given threshold.This paper studies computing weighted solutions for a given computational problem, inthe context of Answer Set Programming (ASP). In particular, we investigate two sorts ofmethods for computing weighted solutions: one method suggests modifying the ASP rep-resentation of the problem to compute weighted solutions using an existing ASP solverand the other suggests modifying the search algorithm of the answer set solver to com-pute weighted solutions incrementally. The applicability of these methods are shown on twosorts of problems: reconstructing weighted phylogenies (for Indo-European languages andfor Quercus species) and finding weighted plans (for Blocks World planning problems). Inthe experiments with the representation-based method, the answer set solver CLASP is usedand weight functions are represented in ASP. For the search-based method, the algorithm ofCLASP is modified (the modified solver is called CLASP-W) and weight functions are im-plemented in C++. For phylogenies, two weight functions are introduced by incorporatingdomain-specific information about groupings of species; one of them cannot be representedin ASP due to some mathematical functions not supported by the ASP solvers. For plans,we define a weight function that characterizes the total cost of executing actions in a plan. Inthese experiments the following are observed. With weight measures that can be representedin ASP, the search-based method outperforms the representation-based method in terms ofcomputational efficiency (both time and space). With weight functions that cannot be repre-sented in ASP, the search-based method provides a tool for computing weighted solutions inASP. The search-based method can be applied to different domains, without modifying thealgorithm of CLASP-W; in that sense, the search-based method is modular and can be usefulto other ASP applications. With either method, plausible phylogenies among many can befound without computing all phylogenies and requiring historical linguists to go over themmanually, and less costly plans can be found without computing all plans; in that sense, ourmethods contribute to phylogenetics and AI planning studies as well.

Keywords weighted solutions, answer set programming, weighted phylogenies, weightedplans

Faculty of Engineering and Natural Sciences, Sabancı University, Istanbul, TurkeyE-mail: {duygucakmak,esraerdem,halit}@sabanciuniv.edu

Page 2: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

2

1 Introduction

Answer Set Programming (ASP) [21] is a declarative programming paradigm oriented to-wards solving combinatorial search problems. In ASP, a combinatorial search problem isrepresented as an ASP program whose models (called “answer sets”) correspond to the so-lutions. The answer sets for a given ASP program can be computed by special systemscalled answer set solvers, such as CLASP [17]. ASP has an expressive formalism that allowsnegation, aggregates, recursive definitions, etc. and efficiency of its solvers is under con-tinuous improvement. Due to these advantages, ASP has been used to solve such problemsin a wide-range of knowledge-intensive applications from different fields, such as productconfiguration [32], planning [20], multi-agent planning [34], phylogeny reconstruction [4],developing a decision support system for a space shuttle [26], systems biology [35].

Generally such combinatorial search problems have too many solutions. Moreover, dueto auxiliary predicates, the correspondence between the answer sets and the solutions maynot be one-to-one; there may be many answer sets that denote the same solution. For suchproblems, one way to obtain more desirable solutions is to assign weights to solutions, andthen compute the distinct solutions whose weights are over (resp. below) a threshold. Forinstance, in planning, if each action of a robot is assigned a weight proportional to the lengthof the trajectory to-be-traveled or the energy consumed by the robot, then finding a plan oflower weight might be more desirable. In phylogenetics, consider the problem of recon-structing phylogenies (i.e., computing leaf-labeled trees, called phylogenies, to model theevolutionary history of a set of species). If each phylogeny is assigned a weight that charac-terizes the expected groupings with respect to some archeological evidence, then finding aphylogeny of weight over some threshold might be more desirable. In puzzle generation, wecan define the weight of a puzzle instance by means of some difficulty measure, and thengenerate difficult puzzles whose weights are over a given value.

Motivated by such problems that play an important role in real-world applications, westudy problems related to computing weighted solutions in ASP, investigate computationalmethods to solve them using the state-of-the-art answer set solvers, compare these methodsexperimentally, and show their usefulness and effectiveness in phylogeny reconstruction ap-plied to two real datasets, Indo-European languages [28] and Quercus species (oak trees) [1],and in planning applied to Blocks World. In particular, we investigate computational meth-ods of two sorts:

Representation-based methods The idea is to modify the ASP representation of the prob-lem by explicitly defining the weight measure and adding weight constraints, and tocompute weighted solutions using an existing ASP solver.

Search-based methods These methods do not modify the ASP representation of the prob-lem, but define the weight function externally (e.g., as a C++ program) and modify thesearch algorithm of the answer set solver to compute weighted solutions incrementallyin the spirit of branch-and-bound.

We apply these methods to two real-world problems: reconstructing weighted phylo-genies (for Indo-European languages and for Quercus species) and computing weightedplans (for Blocks World planning problems). In our experiments, we use the answer setsolver CLASP with the representation-based methods; and we modify the search algorithmof CLASP for the search-based method. The modified version of CLASP is called CLASP-W.1

In the representation-based method, the given weight function is represented in ASP; in thesearch-based method however it is implemented in C++ in a separate file.

1 http://krr.sabanciuniv.edu/projects/SimilarDiverseSolnsInASP/

Page 3: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

3

For phylogenies, we introduce two novel weight functions by incorporating some domain-specific information about simple (resp. hierarchical) groupings. The weight function thatincorporates information about hierarchical groupings cannot be represented in ASP due tosome mathematical functions not supported by the ASP solvers. The other weight functionthat incorporates information about simple groupings can be represented in ASP. For plans,we define a weight function that characterizes the total cost of executing actions in a plan;this function can be represented in ASP as well.

In these experiments, we observe the following about the representation-based methodand the search-based method:

– With weight measures that can be represented in ASP, the search-based method outper-forms the representation-based method in terms of computational efficiency (both timeand space).

– With weight functions that cannot be represented in ASP, the search-based method pro-vides a tool for computing weighted solutions in ASP.

– The search-based method can be applied to different domains, without modifying thealgorithm of CLASP-W; in that sense, the search-based method is modular.

– With either method, more desirable solutions can be found without computing all of thesolutions.

These experimental studies also illustrate the significance of our contributions both fromthe point of view of ASP and from the point of view of phylogenetics:

– There is no answer set solver that can compute weighted solutions incrementally usinga branch-and-bound method, where the weight function is defined externally in C++. Inthat sense, CLASP-W provides a tool for ASP to compute weighted solutions, in partic-ular, when the weight function cannot be represented in ASP. Note that since the weightfunction is defined in a separate file, CLASP-W does not require any problem/function-specific modifications.

– Reconstructing phylogenies for a given set of taxonomic units (e.g., species, languages)is important for various research such as historical linguistics, zoology, anthropology,archeology, etc.. For example, a phylogeny of languages may help scientists to betterunderstand human migrations [36]. For a given set of taxonomic units, some existingphylogenetic systems, like that of [4], generate too many phylogenies that explain theevolutionary relationships between the given taxonomic units. In such cases, to pick themost plausible ones, experts need to go over each one of these phylogenies manually andin detail. There is no phylogenetic system that can help experts to order phylogenies withrespect to a plausibility measure that includes also some domain-specific information.In that sense, our methods contribute to phylogenetics studies as well.

The rest of the paper is organized as follows. Section 2 briefly explains Answer Set Pro-gramming (ASP) with some examples. Section 3 precisely describes the decision problemsrelated to computing weighted solutions in ASP. Section 4 describes the representation-based method and the search-based method; in particular, it explains in detail how the searchalgorithm of CLASP is modified to turn CLASP into CLASP-W. Section 5 defines the weightedphylogeny reconstruction problem, and analyzes its computational complexity. Sections 6and 7 describe the application of the representation-based method and the search-basedmethod to infer phylogenies for Indo-European languages and Quercus species respectively.These sections introduce the two novel weight functions that take into account the com-patibility criterion for reconstructing phylogenies as well as some domain-specific informa-tion provided by the experts, and summarize the results of experiments using these weight

Page 4: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

4

functions. Section 8 describes the application of the representation-based and the search-based methods to compute weighted plans for Blocks World planning problems. Section 10discusses related work; in particular, based on the methods of [11] for computing simi-lar (diverse) solutions, it proposes an extension of our methods to compute similar/diverseweighted solutions. Section 11 concludes.

This paper extends [7,8] substantially by a detailed discussion on the representation-based method and the search-based method for computing weighted solutions. It includesrelated theorems and their proofs. It extends the discussion on related work, in conjunctionwith alternative representation-based methods and similar computational problems (e.g.,computing similar/diverse solutions). It extends the discussion on experimental results, byconsidering different weight measures on a different dataset (Quercus species). Also, it in-cludes a new set of experiments in a different domain, AI planning.

2 Answer Set Programming

We study computing weighted solutions in the context of Answer Set Programming (ASP)[21], a new declarative programming paradigm where the idea is to represent a combinatorialsearch problem as a “program” whose models (called “answer sets” [18]) correspond to thesolutions. Therefore, before we proceed discussing our methods for computing weightedsolutions in ASP, let us present the syntax of the kind of programs considered in this paper,and define the concept of an answer set for such programs.2

Programs The syntax of formulas, rules and programs is defined as follows. Formulas areformed from propositional atoms and 0-place connectives > and ⊥ using negation (writtenas not), conjunction (written as a comma) and disjunction (written as a semicolon).

A rule is an expression of the form

F ← G (1)

where F is an atom or ⊥, and G is a formula; F is called the head and G is called the bodyof the rule. A rule of the form F ← > will be identified with the formula F . A rule of theform ⊥ ← F (called a constraint) will be abbreviated as← F .

A (normal nested) program is a finite set of rules. If bodies of all rules in a program areof the form

A1, . . . , Am, not Am+1, . . . , not An

then the program is a normal program. A program is positive if it does not contain anynegation.

Answer Sets To define the concept of an answer set for a program, let us first define thesatisfaction relation and the reduct of a program.

The satisfaction relation X |= F between a set X of atoms and a formula F is definedrecursively, as follows:

– for an atom A, X |= A if A ∈ X– X |= >– X 6|= ⊥

2 Answer sets are defined for programs of a more general form that may contain classical negation ¬ anddisjunction [19] and nested expressions [22] in heads of rules as well.

Page 5: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

5

– X |= (F,G) if X |= F and X |= G

– X |= (F ;G) if X |= F or X |= G

– X |= not F if X 6|= F .

We say that X satisfies a program Π (symbolically, X |= Π) if, for every rule F ← G in Π ,X |= F whenever X |= G.

The reduct FX of a formula F with respect to a set X of atoms is defined recursively,as follows:

– if F is an atom or a 0-place connective then FX = F

– (F,G)X = FX , GX

– (F ;G)X = FX ;GX

– (not F )X =

{⊥ if X |= F

> otherwise

The reduct ΠX of a program Π with respect to X is the set of rules

FX ← GX

for all rules F ← G in Π .Let us first define the answer set for a program Π that does not contain negation. We say

that X is an answer set for Π if X is minimal among the sets of atoms that satisfy Π . Forinstance, the set {p} is the answer set for the program consisting of the single rule

p← . (2)

Now consider a program Π that may contain negation. A set X of atoms is an answerset for Π if it is the answer set for the reduct ΠX . For instance, the reduct of the program

p← not not p (3)

relative to {p} is (2). Since {p} is the answer set for (2), {p} is an answer set for program(3). Similarly, {} is an answer set for program (3) as well.

Representing a Problem in ASP The idea of ASP [21] is to represent a computational prob-lem as a program whose answer sets correspond to the solutions of the problem, and to findthe answer sets for that program using an answer set solver.

When we represent a problem in ASP, two kinds of rules play an important role: thosethat “generate” many answer sets corresponding to “possible solutions”, and those that canbe used to “eliminate” the answer sets that do not correspond to solutions. Rules (3) are ofthe former kind: they generate the answer sets {p} and {}. Constraints are of the latter kind.For instance, adding the constraint

← p

to program (3) eliminates the answer sets for the program that contain p.In ASP, we use special constructs of the form

l ≤ {R1 = w1, . . . , Rm = wm} ≤ u (4)

(called weight constraints) where each Ri is an atom or an atom preceded by not, l and uare nonnegative integers denoting a “lower bound” and an “upper bound”, and each wi is anonnegative integer denoting a weight [30]. The expressions l ≤ and ≤ u can be dropped if

Page 6: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

6

we do not want to put such bounds (i.e., l = 0 and u = ∞). When each wi is 1, a weightconstraint is called a cardinality constraint and denoted as follows:

l ≤ {R1, . . . , Rm} ≤ u. (5)

Programs using these constructs can be viewed as abbreviations for normal nested programsdue to [16]. For instance, the rule

{p} ←

stands for program (3). The constraint

← 2 ≤ {p, q, r}

stands for the constraints← p, q

← p, r

← q, r.

The rule1 ≤ {a = 2} ≤ 2← 1 ≤ {not a = 3, not b = 2} ≤ 4

stands for the program

a← (not a; not b), not (not a, not b).

Expressions (4) (resp. (5)) describe the subsets of the set {R1, . . . , Rm} whose weights(resp. cardinalities) are at least l and at most u. Such expressions can be used, for instance,in constraints to eliminate some answer sets. For instance, adding the constraint

← 4 ≤ {p = 3, q = 2, r = 1}

to a program eliminates the answer sets X for that program such that the sum of the weightsof atoms in {p, q, r} ∩X is greater than or equal to 4. Adding the constraint

← 2 ≤ {p, q, r}

to a program eliminates the answer sets X for that program such that the cardinality of{p, q, r} ∩X is greater than or equal to 2.

Example: Representing the Clique Problem in ASP Consider, for instance, the use of thegenerate-and-test representation methodology above to represent the clique problem in ASP.The goal is to find a clique of size c in a given graph (V,E). A solution can be described bya set of atoms of the form clique(v) such that v ∈ V . A solution is a set X of c vertices inV satisfying the following condition:

Every two different vertices in X are connected by an edge in E.

Suppose that V = {v1, . . . , vn}. Then a set X of c vertices can be “generated” by the rule

c ≤ {clique(v1), . . . , clique(vn)} ≤ c. (6)

We “test” the connectedness condition above by the following constraints:

← clique(v), clique(u), not edge(v, u), not edge(u, v) (u, v ∈ V, u 6= v) (7)

where edges (u, v) in E are described by atoms of the form edge(u, v). Every answer set forthe program (6) ∪ (7) describes a solution to the clique problem.

Page 7: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

7

Finding a Solution using an Answer Set Solver Once we represent a computational problemas a program whose answer sets correspond to solutions of the problem, we can use ananswer set solver to compute the solutions of the problem. To present a program to ananswer set solver, like CLASP, we need to make some syntactic modifications.

The syntax of the input language of CLASP is more limited in some ways than the class ofprograms defined above, but it includes many useful special cases. For instance, the head of arule can be a cardinality expression and the body can contain weight/cardinality constraintsbut the sign ≤ is dropped; also in weight constraints, the curly brackets are replaced bysquare brackets. In the input language of CLASP, ← is replaced by :-, and each rule isfollowed by a period.

A group of rules that follow a pattern can be often described in a compact way using“(schematic) variables”. Variables must be capitalized. For instance, the program Πn

pi ← not pi+1 (1 ≤ i ≤ n)

can be presented to CLASP as follows:

index(1..n).p(I) :- not p(I+1), index(I).

Here index is a “domain predicate” used to describe the range of variable I.Variables can be also used “locally” to describe the list of formulas in a cardinality

expression. For instance, the rule

1 ≤ {p1, . . . , pn} ≤ 1

can be represented to CLASP as follows

index(1..n).1{p(I):index(I)}1.

The program (6) ∪ (7) describing the clique problem can be presented to CLASP asfollows:

c{clique(X):vertex(X)}c.:- clique(X), clique(Y), vertex(X), vertex(Y), X!=Y,

not edge(X,Y), not edge(Y,X).

where the vertices and edges of the given graph are described by atoms of the form vertex(X)and edge(X,Y) respectively. Assuming that vertices are labeled by numbers, we can as-sign a weight to each clique by adding the labels of the vertices, and ensure that only cliquesof weight less than w are generated, by the following constraint:

:- w[clique(X):vertex(X)=X].

CLASP finds an answer set for such a program in two stages: first it gets rid of theschematic variables using a “grounder”, like LPARSE, and then it finds an answer set for theground program as outlined in Algorithm 1.

Page 8: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

8

3 Weighted Solutions

We are interested in the following sorts of computational problems for computing weightedsolutions:

AT LEAST (resp. AT MOST) w-WEIGHTED SOLUTION: Given an ASP program P thatformulates a computational problem P , a weight measure ω that maps a solution for Pto a nonnegative integer, and a nonnegative integer w, decide whether a solution S existsfor P such that ω(S) ≥ w (resp. ω(S) ≤ w).

For instance, suppose that P describes the phylogeny reconstruction problem for Indo-European languages, and that ω describes the total weight of the characters compatible withthe to-be-constructed phylogeny and takes into account some domain-specific information.Then finding phylogenies whose weights are at least 45 is an instance of the problem above.

Due to [37], a normal nested program P can be further transformed into a normal pro-gram P ′ (by introducing new atoms) such that the set of answer sets for P is the same asthe set of answer sets for P ′ modulo the new atoms; and this transformation can be done inpolynomial time. Based on this result, we assume that the ASP program P that representsa computational problem P is a normal program. We assume that each answer set for Pcharacterizes a solution for P , and extracting a solution from an answer set is polynomial.Supposing that deciding ω(S) ≤ w (resp. ω(S) ≥ w) for a givenw is in NP, we can concludethat:

Proposition 1 AT LEAST (resp. AT MOST) w-WEIGHTED SOLUTION is NP-complete.

4 Computing Weighted Solutions

We study two sorts of methods, representation-based and search-based, for computing atleast/most w-weighted solutions of a given problem P , given an ASP program P , a weightmeasure ω that maps a solution to a nonnegative integer, and a nonnegative integer w.

4.1 Representation-Based Methods

The idea behind the representation-based methods (shown in Figure 1) is

– to modify the ASP representation P of the problem by adding a definition of the weightmeasure ω as an ASP program W and a representation of the weight constraints as anASP program C, and

– to find at least/most w-weighted solutions by computing answer sets for the ASP pro-gram P ∪W ∪ C using an existing ASP solver like CLASP.

In some problems (e.g., finding a shorter plan), we do not have to define the weight of asolution explicitly; we can simply use aggregates (e.g., sum, count, times) as part of weightconstraints in the sense of [31,33,15]. However, many real-world applications (like planningor phylogeny reconstruction mentioned in the introduction) may need sophisticated weightmeasures due to the nature of the domain-specific information, and thus require an explicitASP definition of the weight of a solution. In our experiments, we consider both sorts ofrepresentations.

Page 9: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

9

w

Solve.lp (P): (Computes a solution to the problem)

Weight.lp (W): (Computes the weight of a solution)

Constraint.lp (C): (Eliminates the solutions whose weight is above/below w)

w-weighted solutions

CLASP

Fig. 1 Representation-based method: computing at most/least w-weighted solutions.

w

w-weighted solutions

Solve.lp (P): (Computes a solution to the problem)

Weight.cpp (Computes an upper bound for the weight of any completion of a partial solution)

CLASP-NK

Fig. 2 Search-based method: computing at most/least w-weighted solutions.

4.2 Search-Based Methods

Search-based methods (as illustrated in Figure 2) do not modify the ASP representation ofthe problem, nor define the weight measure as an ASP program. The idea is

– to define the weight function externally as a C++ program, and– to modify the search algorithm of an existing answer set solver like CLASP to compute

solutions whose weights are over (resp. below) a given threshold.

There is no answer set solver that can compute weighted solutions in such a way.In our studies, we consider the ASP solver CLASP, and modify its search algorithm

in such a way that it computes weighted solutions incrementally in the spirit of a branch-and-bound algorithm. Before describing these modifications, let us first describe CLASP’salgorithm.

CLASP does a conflict-driven DPLL-like [9] branch-and-bound search to find an answerset for the program: at each level, it does propagation followed by backtracking or selectionof new literals according to the current conflicts. A rough working principle of CLASP is

Page 10: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

10

Algorithm 1 CLASPInput: An ASP program ΠOutput: An answer set A for ΠA← ∅ // current assignment of literals5← ∅ // set of conflictswhile No Answer Set Found do

// propagate according to the current assignment and conflicts; update the current assignmentPROPAGATION(Π,A,5)if There is a conflict in the current assignment then

RESOLVE-CONFLICT(Π,A,5) // learn and update the conflict set and do backtrackingelse

if Current assignment does not yield an answer set thenSELECT(Π,A,5) // select a literal to continue search

elsereturn A

end ifend if

end while

Algorithm 2 CLASP-WInput: An ASP program Π and a nonnegative integer wOutput: An answer set for Π , that describes an at least (resp. at most) w-weighted solutionA← ∅ // current assignment of literals5← ∅ // set of conflictswhile A does not represent an answer set do

// propagate according to the current assignment and conflicts;update the current assignmentPROPAGATION(Π,A,5)// compute an upper (resp. lower) bound for the weight of a solution that contains Aweight← WEIGHT-ANALYZE(A)// if the upper bound weight is less than the desired weight value w// then no need to continue search to find an at least w-weighted solutionif There is a conflict in propagation OR weight < w then

RESOLVE-CONFLICT (Π,A,5) // learn and update the conflict set and do backtrackingend ifif Current assignment does not yield an answer set then

SELECT(Π,A,5) // select a literal to continue searchelse

return Aend if

end whilereturn false

shown in Algorithm 1. As can be seen, CLASP goes through three main steps to find ananswer set. In the PROPAGATION step, it decides the literals that have to be included in theanswer set due to the current assignment and conflicts. In the RESOLVE-CONFLICT step,it tries to resolve the conflicts encountered in the previous step. If there is a conflict, thenCLASP learns it and does backtracking to an appropriate level. If there are no conflicts andthe currently selected literals do not represent an answer set, in SELECT, CLASP selects anew literal (based on some heuristics) to continue search.

We modify CLASP’s algorithm to compute at least (resp. at most) w-weighted solu-tions, as shown in Algorithm 2; the parts in red denote these modifications. The new algo-rithm is called CLASP-W. Note that, compared to CLASP, CLASP-W has an additional proce-dure called WEIGHT-ANALYZE; therefore, in order to use CLASP-W, the WEIGHT-ANALYZE

function needs to be implemented according to the weight measure of the specific domain.

Page 11: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

11

The WEIGHT-ANALYZE function is called at each step of the search; therefore, it shouldbe able to identify the partial solution characterized by the currently selected literals, and es-timate the weight of a complete solution constructed on the partial solution. Since a partialsolution may extend to many complete solutions, the WEIGHT-ANALYZE function computesan upper bound (resp. a lower bound) for the weight of a solution that extends the currentpartial solution. Computing an exact upper bound (resp. a lower bound) might be hard andinefficient; therefore, one may be interested in implementing a heuristic function that ap-proximates the upper bound (resp. lower bound) for the weight of a solution. To guaranteecompleteness, the heuristic function shall be admissible. In other words, the upper bound(resp. lower bound) computed by the heuristic function shall be greater (resp. less) than orequal to the exact upper bound (resp. lower bound). If this is not the case, then we have arisk of missing a solution.

Once the WEIGHT-ANALYZE function is defined to estimate the weight of a solution,we can check whether the estimated weight is less (resp. greater) than the given weightthreshold w. If the upper bound (resp. the lower bound) computed by the heuristic functionis already less (resp. greater) than the given weight threshold w, then there is no solutionthat can be characterized by any extension of the current assignment of literals and that hasa weight greater (resp. smaller) than w. Therefore, the current assignment of literals can beset as conflict. CLASP learns this particular assignment of literals that leads to a conflict andnever selects this set of literals in the further stages of the search. In this way, it eliminatesredundancy in search.

5 Weighted Phylogeny Reconstruction Problem

The evolutionary relations between species (or “taxonomic units”) based on their sharedtraits can be modeled as a phylogeny—a tree whose leaves represent the species, internalvertices represent their ancestors and edges in between represent the relationships betweenthem. The problem of phylogeny reconstruction asks for “plausible” phylogenies for a givenset of taxonomic units. The plausibility of phylogenies can be evaluated with respect todomain-specific information (e.g., biological evidence, archeological evidence, historicallinguistics) provided by the experts.

There have been various studies to compute plausible phylogenies (cf. [4]). We considera character-based cladistics approach with respect to the compatibility criterion, as in [4].This approach describes each taxonomic unit with a set of “characters”—traits that everytaxonomic unit can instantiate in a variety of ways. The taxonomic units that instantiate thecharacter in the same way are assigned the same “state” of that character. Once the stateof every character for every taxonomic unit is described, phylogenies can be inferred usingthe “compatibility” criterion: the goal is to find a phylogeny with a small number of incom-patible characters. The problem of reconstructing a phylogeny with at most c incompatiblecharacters (let us call this problem as c-CP) is NP-hard [10].

While reconstructing phylogenies, some characters may give more information than theothers. For instance, to model the evolutionary history of a family of languages, morpholog-ical/phonological characters are more informative than lexical characters. In order to em-phasize the role of such characters in reconstructing a phylogeny, we can define the conceptof a weighted phylogeny.

Before defining weighted phylogenies, let us define a phylogeny. A phylogeny for aset of taxonomic units is a finite rooted binary tree 〈V, E〉 along with two finite sets Iand S and a function f from L x I to S, where L is the set of leaves of the tree. The set L

Page 12: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

12

represents the given taxonomic units, whereas the set V describes their ancestral units andthe set E describes the genetic relationships between them. The elements of I represent,intuitively, qualitative characters, and elements of S are possible states of these characters.The function f “labels” every leaf v by mapping every index i to the state f(v, i) of thecorresponding character in that taxonomic unit. A character i ∈ I is said to be compatiblewith a phylogeny (V,E, L, I, S, f) if there exist a function g : V × i→ S such that

– For every leaf v of the phylogeny, g(v, i) = f(v, i)

– For every s ∈ S if the setVis = {x ∈ V : g(x, i) = s}is nonempty, then the digraph 〈V, E〉 has a subgraph with the set Vis of vertices that isa rooted tree.

A weighted phylogeny is a phylogeny (V,E, L, I, S, f) along with a weight function ωthat maps every character i ∈ I to a nonnegative integer. The weight of a phylogeny canbe defined in various ways with respect to ω; for instance, we can define the weight ofa phylogeny (weight(V,E, L, I, S, f)) as the sum of the weights of all characters that arecompatible with that phylogeny.

We are interested in computing weighted phylogenies for a given set of taxonomic units,and thus the following decision problem:

AT LEAST w-WEIGHTED c-COMPATIBLE PHYLOGENIES (wc-WCP): Given three setsL, I, S, a function f from L× I to S, a function ω from I to nonnegative integers, andtwo nonnegative integers w and c, decide the existence of a phylogeny (V,E, L, I, S, f)

with at most c incompatible characters and whose weight is at least w.

Suppose that deciding weight(V,E, L, I, S, f) ≥ w is in NP. Then, we can concludethat:

Proposition 2 wc-WCP is NP-complete.

In addition to solving an optimization problem to find phylogenies with the minimumnumber of incompatible characters and maximum weight, based on our experts’ feedback,we are interested in solving a decision problem to find phylogenies with a small number ofincompatible characters and a large weight. The reason is that some computed phylogeniesthat are “almost optimal” can be identified as plausible by the experts even though they donot have minimum number of incompatible characters or maximum weight. For example,in [5], for Indo-European languages, some phylogenies computed with 17 or 18 incompati-ble characters are identified as plausible, even though the minimum number of incompatiblecharacters for the dataset is 16. In addition, in [7], the phylogenies with the weights over45 are identified as plausible, even though the maximum weight of the computed phyloge-nies is 65. Based on this motivation, we can decide for the thresholds as follows: first wecompute a phylogeny with the minimum number of compatible characters (since our ap-proach to phylogenetics is based on the compatibility criterion) by increasing the value ofc one by one starting from 0 until a phylogeny is computed. Since there may be plausiblephylogenies “close” to the optimal one in terms of the number of incompatible characters,we also compute phylogenies with a “small” number of incompatible characters by furtherincreasing the value of c by some units depending on the number of phylogenies computedso far. Similarly, we can decide for the value of the threshold w for weight.

Page 13: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

13

6 Computing Weighted Phylogenies for Indo-European Languages

We can compute weighted phylogenies for the family of Indo-European languages describedin [4], using the representation-based method or the search-based method described in Sec-tion 4. Before we show the applicability of these methods, let us define the weight Φ of acharacter for languages, and the weight of a phylogeny (V,E, L, I, S, f) for Indo-Europeanlanguages.

6.1 Weight of a Phylogeny for Indo-European

As discussed in [4], out of all given characters and character states, only informative char-acters3 and their essential states4 play a role in reconstructing phylogenies. Therefore, weconsider informative characters and their essential states only, while reconstructing phylo-genies for Indo-European languages. We observe that some informative characters have lessnumber of essential states whereas some have many; the ones with many essential states givemore information as to how the languages are related to each other. Based on this domain-specific information, we define the weight Φ of an informative character i ∈ I with respectto a phylogeny (V,E, L, I, S, f), as the number of languages that are mapped to an essentialstate for that character:

ΦL,I,S,f (i) = |{l ∈ L : f(i, l) = s, i is informative, s is essential}| (8)

In the following, we drop the subscript from ΦL,I,S,f when L, I, S, f are clear from thecontext.

We then define the weight of a phylogeny (V,E, L, I, S, f) for Indo-European languagessimply as the sum of the weights of informative characters that are compatible with thatphylogeny:

weight(V,E, L, I, S, f) =∑

i∈I,i is compatible

Φ(i) (9)

To get more plausible phylogenies, we also incorporate further domain-specific information.It was told us by historical linguist Don Ringe that it is least likely that Greco-Armenian(GA) languages are siblings with Balto-Slavic (BS) languages. Similarly, but not as leastlikely as GA and BS, is the grouping of GA with Germanic (GE) languages. If the to-be-reconstructed phylogenies have such odd groupings of languages, we deduct some amountfrom the total weight of the phylogeny making sure that the weight of a phylogeny is notnegative.

6.2 The Representation-Based Method

The representation-based method (Section 4, Figure 1) suggests describing the weight of aphylogeny as an ASP program W , the weight constraints as an ASP program C, and thencompute weighted phylogenies by means of computing answer sets for the program P ∪W ∪ C where P is a program that describes phylogeny reconstruction. We describe ASPprograms in the language of LPARSE [30]. We take P as the phylogeny program of [4].

3 A character is informative if it has at least 2 essential states.4 For a phylogeny (V,E, L, I, S, f), a state s ∈ S is essential with respect to a character j ∈ I if there

exist two different leaves l1 and l2 in L such that f(l1, j) = f(l2, j) = s.

Page 14: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

14

We describe the weight of a phylogeny (as defined in the previous section) as an ASPprogramW in four parts, as follows. Suppose that PW and W denote phylogeny weights, ICdenotes an informative character, CW denotes a character weight, and C denotes a character.First we describe the weight CW of an informative character IC as in (8):

weightOfChar(IC,CW) :-CW{leaf(V):f(V,IC,S):essential_state(IC,S)}CW,charWeight(CW).

In the second part, first we define the sum of the weights of characters compatible withthe to-be-reconstructed phylogeny, as in (9):

totalWeightOfChars(PW) :- addCharWeights(PW,C), maxChar(C).

addCharWeights(PW,1) :- compatible(1), weightOfChar(1,PW).addCharWeights(0,1) :- not compatible(1).

addCharWeights(PW+CW,C) :- compatible(C),weightOfChar(C,CW), addCharWeights(PW,C-1).

addCharWeights(PW,C) :- not compatible(C),addCharWeights(PW,C-1).

Observe in the third and the fifth rules that the incompatible characters do not contribute tothe weight of a phylogeny.

In the third part, we take into account the domain-specific information discussed inthe previous section. For instance, it is least likely that Greco-Armenian (GA) languagesbe siblings with Balto-Slavic (BS) languages. Therefore, we deduct some amount, say 30,from the weight of a phylogeny if it groups GA and BS as siblings. For Indo-European,historical linguist Don Ringe identified 4 odd groupings. We define the sum W of deductionsdue to all these odd groupings as follows:

totalDeductions(W) :- addDeductions(W,4).addDeductions(W,1) :- oddGroup(1,W).addDeductions(W+PW,G+1) :- oddGroup(G+1,PW), addDeductions(W,G).

Finally, in the fourth part, we define the weight of a phylogeny by subtracting the totaldeductions of odd groupings from the total weights of characters:

weightOfPhylogeny(PW-W) :- totalWeightOfChars(PW),totalDeductions(W).

We describe the weight constraints, to ensure that the weight of the phylogeny is larger thanw, as another ASP program C as follows:

:- weightOfPhylogeny(W), W<w.

Since LPARSE and CLASP support weight constraints [24], note that we can also modelthe weight measure using weight constraints instead of recursive definitions. There are twosummations in the weight definition: totalDeductions and totalWeightOfChars.Total deductions can be defined using weight constraints as follows:

totalDeductions(DW) :-DW[oddGroup(G,D): group(G): oddGroupWeight(D)=D]DW,phylogenyWeight(DW).

Page 15: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

15

In addition, total weight of characters can be defined as follows:

totalWeightOfCharacters(PW) :-PW[weightOfCompatibleCharacter(K,CW):

informative_character(K): charWeight(CW)=CW]PW.weightOfCompatibleCharacter(IC,CW) :-

weightOfChar(IC,CW), compatible(IC).

We also consider this representation of the weight function (with aggregates) in our experi-ments.

6.3 The Search-Based Method

The search-based method (Section 4, Fig 2) suggests defining the weight measure in C++(in a separate file) and uses it with CLASP-W (the modified version of CLASP that computesweighted solutions).

As discussed in Section 4, we need to define and implement a heuristic function to esti-mate the upper bound for the weight of a phylogeny from a partial phylogeny. To guaranteecompleteness, the heuristic function should be admissible. Since the weight of a phylogenyis defined over the weights of incompatible characters, we can define the heuristic functionas follows with respect to the set I of informative characters and the partially constructedanswer set A:

UBΦ(A, I) =∑i∈I

Φ(i)−∑

i∈I,incompatible(i)∈A

Φ(i)

Proposition 3 UBΦ is admissible.

In our experiments, we implement this heuristic function in C++, and use it with CLASP-W.We do not have to modify the search algorithm of CLASP-W to be able to use this weightfunction in the computations.

6.4 Experimental Results

We apply the computational methods described above (i.e., the representation-based meth-ods and the search-based method) to weighted phylogeny reconstruction for Indo-Europeanlanguages. In our experiments, we consider [4]’s ASP encoding of the phylogeny recon-struction program.

All experimental results reported below are for a workstation with a 3.00GHz Intel Xeon5160 Dual-Core Processor and 4GB RAM, running Red Hat Enterprise Linux (Version 4.3);in these experiments LPARSE v.1.0.17 is used as the grounder and CLASP v.1.3.1 is used asthe answer set solver.

We use the dataset assembled by Don Ringe and Ann Taylor [28]. As in [4], to computeweighted phylogenies, we considere the language groups Balto-Slavic (BS), Italo- Celtic(IC), Greco-Armenian (GA), Anatolian (AN), Tocharian (TO), Indo-Iranian (IIR), Germanic(GE), and the language Albanian (AL). While computing phylogenies, we also take intoaccount some domain-specific information about these languages.

Due to the nature of the domain-specific information about simple groupings, we con-sider the weight measure defined in Section 6.2. Recall that this weight function can be

Page 16: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

16

Table 1 The representation-based methods vs. the search-based method: computing an at least w-weightedphylogeny with at most c incompatible characters for Indo-European languages.

c w method time program size memory size(CPU sec.s) (MB)

16 45 representation-based 15.52 # of atoms: 79229 369(with recursive definitions) # of rules: 1585419representation-based 2.08 # of atoms: 7982 22(with aggregates) # of rules: 98245search-based 1.34 # of atoms: 3744 22

# of rules: 5521917 45 representation-based 15.32 # of atoms: 79229 369

(with recursive definitions) # of rules: 1585419representation-based 1.97 # of atoms: 7982 22(with aggregates) # of rules: 98245search-based 1.30 # of atoms: 3744 22

# of rules: 5521918 45 representation-based 15.47 # of atoms: 79229 369

(with recursive definitions) # of rules: 1585419representation-based 1.92 # of atoms: 7982 22(with aggregates) # of rules: 98245search-based 1.10 # of atoms: 3744 22

# of rules: 55219

Table 2 The representation-based methods vs. the search-based method: computing all at least w-weightedphylogenies with at most c incompatible characters for Indo-European languages.

c w # of phylogenies method time memory size(CPU sec.s) (MB)

16 45 1 representation-based 14.49 369(with recursive definitions)representation-based 5.46 38(with aggregates)search-based 3.67 22

17 45 8 representation-based 126.06 369(with recursive definitions)representation-based 20.41 38(with aggregates)search-based 17 22

18 45 14 representation-based 210.32 369(with recursive definitions)representation-based 33.93 38(with aggregates)search-based 22.35 22

defined in ASP in two ways: iteratively using recursive rules, and using aggregates. There-fore, in our experiments we consider both representation-based methods and compare themwith the search-based method.

According to the results of [4], the phylogenies identified as plausible have 16, 17 or 18incompatible characters. Among those plausible phylogenies, the one with the lowest weighthas weight of 45. Therefore, in our experiments we consider c = 16, 17, 18 and w = 45.

Comparison of the methods Let us first consider computing an at least w-weighted phy-logeny with at most c incompatible characters. For each problem and for each method,

Page 17: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

17

Table 1 presents the computation time, the size of the ground program, and the maximumsize of the memory used in computation. For instance, let us consider computing a phy-logeny with at most 17 incompatible characters, and whose weight is at least 45. With therepresentation-method with recursive definitions, CLASP takes 15.32 CPU sec.s to computesuch a phylogeny; the ground program has 79229 atoms and 1585419 rules; the computationof the phylogeny consumes 369 MB of memory. With the other representation-based method(with aggregates), CLASP takes 1.97 CPU sec.s to compute such a phylogeny; the groundprogram has 7982 atoms and 98245 rules; the computation of the phylogeny consumes 22MB of memory. On the other hand, with the search-based method, CLASP-W takes 1.30 CPUsec.s to compute such a phylogeny; the ground program has 3744 atoms and 55219 rules;the computation of the phylogeny consumes 22 MB of memory.

Observe in Table 1 that in terms of both computation time and the memory used, thesearch-based method performs much better than the representation-based method with re-cursive definitions, and slightly better than the representation-based method with aggre-gates. The representation of the weight measure plays an important role in the computa-tional efficiency of these methods in terms the time and memory. The representation-basedmethod with recursive definitions results in larger programs and higher memory consump-tion; whereas the representation-based method with aggregates has a more compact encod-ing of the weight measure, it results in smaller programs and low memory consumption. Onthe other, the search-based method deals with the time consuming computation of weightsof phylogenies, not at the ASP representation level but at the search level: it does not requirean ASP representation of the weight function but requires a modification of the solver toguide the search to obtain a plausible phylogeny.

Now let us examine the results of our experiments (Table 2) for computing all of thephylogenies with at least w weight and with at most c incompatible characters. The re-sults are similar with those of the previous batch of experiments for computing a weightedphylogeny: the search-based method and the representation-based method with aggregatesoutperforms the representation-based method with recursive definitions. For instance, let usconsider the problem of computing all phylogenies with at most 17 incompatible characters,and whose weight is at least 45. With our representation-based method with recursive defi-nitions, CLASP takes 126 CPU sec.s to compute all 8 phylogenies. With the representation-based method with aggregates, CLASP takes 20 CPU sec.s, whereas, with the search-basedmethod, CLASP-W takes 17 CPU sec.s to compute them.

Effectiveness of the methods In [4], after computing all 45 phylogenies, the authors exam-ine them manually and identify 34 of them as plausible (1 with 16 incompatible characters,7 with 17 incompatible characters, 6 with 18 incompatible characters, 3 with 19 incom-patible characters, 17 with 20 incompatible characters). With the weight measure definedin Section 6, and the representation/search-based methods described above for computingweighted phylogenies, we can automatically compute all plausible phylogenies with at most18 incompatible characters. These results show the effectiveness of not only our methods(since we do not have to compute all phylogenies) but also the domain-specific weight func-tion (since we do compute the most plausible phylogenies).

7 Computing Weighted Phylogenies for Quercus

We present another example to show the inapplicability/applicability of our methods, with adifferent weight function and for a different dataset (i.e., Quercus species).

Page 18: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

18

The domain-specific information given about groupings of Quercus species is hierarchi-cal: both the expected groupings of species and further groupings of these subgroupings arespecified. To take into account such domain-specific information about hierarchical group-ings, we define a novel general weight function that can be used also for reconstructingweighted phylogenies for the genus Quercus. However, this weight function involves math-ematical operations which can not be expressed in the input language of CLASP; for thatreason, the representation-based method cannot be applied to compute weighted phyloge-nies for Quercus using this weight function. Fortunately, we can apply the search-basedmethod.

Before we show the applicability of the search based method, let us define the weight ϕof a vertex, and the weight of a phylogeny (V,E, L, I, S, f) for genus Quercus.

7.1 Weight of a Phylogeny for Quercus

Specific to Quercus dataset, biologist Yasin Bakis, who also gathered the data which isdescribed in [1], provided some domain-specific information about the expected groupingsof the species and expected classes of these groupings. According to this information, aphylogeny is preferable if these species are closer to each other in the tree. Therefore, wedefine a weight measure to reflect such domain-specific information as follows.

The weight of a phylogeny (V,E, L, I, S, f) is the sum of the weights of all verticesexcept its root r:

weight(V,E, L, I, S, f) =∑

v∈V/{r}

ϕ(v). (10)

where the weight ϕ(v) of a vertex v is defined as follows:

1. We label the leaves with their class information.2. We propagate the labels of the leaves up to the root and we label each internal vertex

with the labels of its children.3. We assign a weight to each vertex by comparing its labels with those of its sibling. To be

able to compare the labeling of the vertices, we define the contribution ς(c, v) of a vertexv with respect to a label c as follows. Let sibling(v) denote the sibling of the vertex v,and let label(v) denote the labels of the vertex v.

ς(c, v) =

0 if c 6∈ label(sibling(v)) or

|label(v)| = the total number of classes,1

|label(v)| otherwise(11)

The weight ϕ(v) of a vertex v is then the minimum of the following two values: themaximum value maxContr(v) of the contributions ς(c, v) over its labels c, and the max-imum value maxContr(sibling(v)) of the contribution ς(c′, sibling(v)) over its sibling’slabels c′:

ϕ(v) = min(maxContr(v),maxContr(sibling(v))). (12)

Consider, for instance, the phylogeny in Figure 3. The leaves are labeled with respect tothe following class information: the leaves A and B are expected to be grouped in the sameclass, so they are labeled by C1; there is no information as to how C and D are expected to

Page 19: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

19

C1 C1 C2 C3

C1C2,C3

A B C D

Fig. 3 A phylogeny with class labels.

be grouped, so we label them by C2 and C3 respectively. Then we propagate these labels totheir ancestors. We compute the weights of the vertices as follows. Since

maxContr(A) = ς(C1, A) = 1

maxContr(B) = ς(C1, B) = 1

maxContr(v) = ς(c, v) = 0 (v 6= A,B, c 6= C1)

ϕ(A) = 1, ϕ(B) = 1, and ϕ(v) = 0 for all other vertices different from A and B. Then theweight of the phylogeny is 2.

7.2 The Search-Based Method

Similar to 6.3, a heuristic function is needed to estimate the upper bound for the weightof a phylogeny from a partial phylogeny. To guarantee completeness, admissibility of theheuristic function is required. Since the weight of a phylogeny is defined over the weights ofvertices, we can define the heuristic function as follows with respect to the set V of verticesand the partially constructed answer set that characterizes a partial phylogeny X:

UBϕ(X,V ) =∑v∈V

ϕ′X(v) (13)

where ϕ′X(v) is defined as follows:

ϕ′X(v) =

1 if labelX(v) = ∅

or v does not have a sibling in Xor labelX(siblingX(v)) = ∅

minCX(v) otherwise

(14)

and minCX(v) is defined as follows:

minCX(v) = min(maxContrX(v),maxContrX(siblingX(v))). (15)

Proposition 4 UBϕ is admissible.

Page 20: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

20

Consider, for instance, an answer set that describes the partial phylogenyX that consistsof all the nodes and the edges of the phylogeny shown in Figure 3, except for the three edgesthat connect A and B to the root; so the parent E of A and B is disconnected in this partialphylogeny. Since A, B, E, and the ancestors of C and D do not have sisters, for each onev of them, ϕ′

X(v) = 1. Therefore, the estimated total weight of the phylogeny is 5. Notethat this partial tree has three completions: one is shown in Figure 3, and the other twoare (A, (B, (C,D))) and (B, (A, (C,D))) in Newick format where the sister subtrees areenclosed by parentheses. Recall that the weight of the first phylogeny is 2; the weights ofthe other two phylogenies are 0. Therefore, UBϕ does not underestimate the weight functionweight.

In our experiments, we implement the heuristic function UBϕ in C++ in a separatefile, and use it with CLASP-W. As in our experiments with Indo-European, we do not haveto modify the search algorithm of CLASP-W to be able to use this weight function in thecomputations.

7.3 Experimental Results

We apply the search-based method to compute weighted phylogenies for Quercus species.In our experiments, we consider the ASP encoding of the phylogeny reconstruction programin [4].

We use the dataset assembled by Yasin Bakis [1] to compute weighted phylogeniesfor Quercus species. The dataset consists of 47 Quercus populations from different partsof Turkey. In addition, we consider some domain-specific information about the expectedgroupings of these populations, and further classification of these groupings.

According to our earlier experiments with Quercus, the minimum number of charactersincompatible with a phylogeny is 9. Since it is useful in phylogenetics to compute solutions“close” to the optimal one. Considering the weights of the plausible phylogenies, in ourexperiments we set c = 9, 10, 12 and w = 18, 13, 13 respectively as thresholds.

Due to the nature of the domain-specific information about hierarchical groupings, weconsider the weight measure defined in Section 7.1. Recall that this weight function cannot be defined in ASP due to mathematical functions not supported by the ASP solvers.Therefore, we can not apply the representation-based methods for reconstructing weightedphylogenies for Quercus.

Our experiments with Quercus species are interesting to illustrate the usefulness of thesearch-based method. From the point of view of ASP, it provides a modular tool for com-puting weighted solutions: neither the ASP formulation of the problem nor the search algo-rithm of CLASP-W needs problem/function-specific modifications. From the point of view ofphylogenetics, it provides a useful tool for computing more plausible phylogenies (withoutcomputing all of them) and thus analyzing phylogenies.

8 Computing Weighted Plans

In order to show the applicability and effectiveness of our methods to other domains, weextend our experiments to planning problems. The weight of a plan can be specified as the“cost” of executing that plan. For instance, in the Blocks World domain, moving heavierblocks may require more energy, and thus these actions can be considered more costly; thenplans with smaller weights can be viewed as more desirable.

Page 21: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

21

In these experiments, we study the following instance of AT MOST w-WEIGHTED SO-LUTION:

AT MOST w-WEIGHTED PLAN: Given an ASP program P that formulates a planningproblem P , a weight measure ω that maps a plan for P to a nonnegative integer, and anonnegative integer w, decide whether a solution S exists for P such that ω(S) ≤ w.

We consider a plan as a sequence of actions, where each action is a set of primitiveactions. Let act(P, i) be a function that returns the ith action of the plan P . We define theweight of a plan P with the help of a cost function ζ from primitive actions to nonnegativeintegers, as follows:

ψ(P ) =

|P |∑i=1

∑a∈act(P,i)

ζ(a).

We take P as the ASP formulation of the Blocks World presented in [13] to computea plan of length at most l. We apply both the representation-based method and the search-based method to solving planning problems with this domain description.

8.1 The Representation-Based Method

The representation-based method (Section 4, Figure 1) suggests describing the weight of aplan as an ASP programW , the weight constraints as an ASP program C, and then computeweighted plans by means of computing answer sets for the program P ∪W ∪ C.

We define the weight of a plan as an ASP programW as follows. Suppose that the cost Cof moving a block B to a location L is defined by atoms of the form actionCost(B,L,C).Then the total cost TAC of a concurrent action executed at time step T by an atom of theform timeActionCost(T,TAC), can be defined by summing up the costs C of everyprimitive action moveop(B,L,T) executed at time step T:

timeActionCost(T,TAC) :-TAC[moveop(B,L,T):time(T):block(B):location(L):

actionCost(B,L,C)=C]TAC,time(T), totalCostDomain(TAC).

Then the total cost TC of a plan (i.e., the weight of a plan) is the sum of the costs of itsconcurrent actions:

totalcost(TC) :-TC[timeActionCost(T,C):time(T):totalCostDomain(C)=C]TC,totalCostDomain(TC).

Note that the weight function is defined using aggregates rather than recursive definitions.The constraint on the weight of a plan (i.e., the total cost of a plan is at most c) then can

be expressed in C as follows:

:- totalcost(TC), totalCostDomain(TC), TC>c.

Page 22: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

22

Fig. 4 A Blocks World planning problem instance.

8.2 The Search-Based Method

The search-based method (Section 4, Figure 2) suggests defining the weight measure in C++(in a separate file) and uses it with CLASP-W (the modified version of CLASP that computesweighted solutions).

As discussed in Section 4, we need to define and implement a heuristic function to esti-mate a lower bound for the weight of a plan from a partial plan. To guarantee completenessof our method, the heuristic function should be admissible.

Before we define the heuristic function used in our experiments, let us define partialplans characterized by partial functions. We say that Pp is a partial plan if act(Pp, i) is apartial function, that is, for some i, act(Pp, i) is not defined. A plan P is a completion of apartial plan Pp if act(P, i) extends act(Pp, i).

Let D(Pp) = {i | ∃a s.t act(Pp, i) = a} be the set of all the indices that act(Pp, i) isdefined. In order to compute at most w-weighted plans using CLASP-W, we need to define alower bound for the weight of any completion of a partial plan. Given a partial plan Pp, wedefine a lower bound for the weight of any completion of Pp as follows:

LBψ(Pp) =∑

i∈D(Pp)

∑a∈act(Pp,i)

ζ(a)

Proposition 5 LBψ is admissible.

In our experiments, we implement this heuristic function in C++, in a separate file, anduse it with CLASP-W. We do not have to modify the search algorithm of CLASP-W to be ableto use this weight function in the computations.

8.3 Experimental Results

We show the applicability and effectiveness of our methods on planning, with the BlocksWorld planning problems. In our experiments, we use the ASP formulation of the noncon-current Blocks World as in [13] to compute a plan of length at most l, together with an ASPdescription of the planning problem instance shown in Figure 4.

Suppose that the blocks labeled 7, ..., 12 are heavier than the others; and that carrying aheavy block costs more. Also, suppose that we do prefer plans where blocks are not moved

Page 23: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

23

onto the table very often; therefore, we can assign a high cost to actions that move a blockonto the table. With these motivations, we can define a cost function ζ from primitive actionsto nonnegative integers as follows:

ζ(a) =

2 if a = moveop(b,Table) for some block b1 if a = moveop(b,l) for some block b = 1, 2, ..., 6 and l = 1, 2, ..., 12

3 if a = moveop(b,l) for some block b = 7, 8, ..., 12 and l = 1, 2, ..., 12

(16)

The results of some experiments to find weighted plans of length less than l = 15, 16, 17

for the planning problem shown in Figure 4 is summarized in Table 3. Observe that, in termsof both computation time and the memory used, the search-based method performs muchbetter than the representation-based method. For instance, consider computing a plan whoselength is at most 17 and whose weight is at most 30. With the representation-method, CLASP

takes 262.78 CPU sec.s to compute such a plan; whereas, with the search-based method,CLASP-W takes 20.82 CPU sec.s to compute such a plan. With the representation-method,the computation of the plan consumes 59 MB of memory; whereas, with the search-method,the computation of the plan consumes 35 MB of memory.

We also perform some experiments with a modified ASP formulation of the BlocksWorld, that allows concurrency of two actions. For that, we replace the noconcurrency con-straints

:- 2{moveop(B,L,T):block(B):location(L)},time(T).

in the ASP program P by the constraints

:- 3{moveop(B,L,T):block(B):location(L)},time(T).

Table 4 summarizes the results of these experiments, where we compute plans of lengthless than l = 8, 9, 10 for the planning problem shown in Figure 4. The results are sim-ilar with those of the previous batch of experiments for computing a weighted plan: thesearch-based method outperforms the representation-based method. For instance, considercomputing a plan whose length is at most 10 and whose weight is at most 30. With therepresentation-method, CLASP takes 583.34 CPU sec.s to compute such a plan; whereas,with the search-based method, CLASP-W takes 16.26 CPU sec.s to compute such a plan.With the representation-method, the computation of the plan consumes 46 MB of memory;whereas, with the search-method, the computation of the plan consumes 26 MB of memory.

9 On Estimating Lower/Upper Bounds for Weight Functions

To be able to use the search-based method more effectively, we need to find a heuristic func-tion to estimate an upper/lower bound for the weight function. To ensure completeness, theheuristic function should be admissible. Finding such an admissible heuristic is challengingin general. Fortunately, the weight functions we consider in our experiments have a nicestructure to exploit: each weight function ω for a solution is defined as the sum of someauxiliary function ω′ over some components of the solution that characterize the solution;and these auxiliary functions can be computed without knowing the complete solution.

For instance, in our experiments with Indo-European languages, the weight of a phy-logeny is defined as the sum of the weights of the characters that are compatible with thephylogeny; and we do not need to know the whole phylogeny to compute the weight of a

Page 24: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

24

Table 3 The representation-based method vs. the search-based method: computing an at most w-weightedplan whose length is at most l (with no concurrency).

l w method time program size memory size(CPU sec.s) (MB)

15 30 representation-based 33.63 # of atoms: 10564 45# of rules: 75518

search-based 5.51 # of atoms: 8218 33# of rules: 73157

16 30 representation-based 55.49 # of atoms: 11358 55# of rules: 80373

search-based 14.91 # of atoms: 8712 34# of rules: 77709

17 30 representation-based 262.78 # of atoms: 12170 59# of rules: 85246

search-based 20.82 # of atoms: 9206 35# of rules: 82261

Table 4 The representation-based method vs. the search-based method: computing an at most w-weightedplan whose length is at most l (possibly with concurrent execution of two primitive actions).

l w method time program size memory size(CPU sec.s) (MB)

8 30 representation-based 4.75 # of atoms: 6230 34# of rules: 42781

search-based 1.58 # of atoms: 4760 16# of rules: 41293

9 30 representation-based 206.78 # of atoms: 7069 38# of rules: 47684

search-based 73.03 # of atoms: 5254 25# of rules: 45845

10 30 representation-based 583.34 # of atoms: 7944 46# of rules: 52623

search-based 16.26 # of atoms: 5748 26# of rules: 50397

character. In our experiments with Quercus species, the weight function is defined as thesum of the weights of its vertices; and we do not need to know the whole phylogeny tocompute the weight of a vertex. Similarly, the weight of a plan is defined as the sum of thecosts of its actions; and we do not need to know the whole plan to find the cost of an action.

Such “additive composability” of these weight functions ω in terms of auxiliary func-tions ω′ allows us to define heuristic functions by considering partial solutions. For instance,suppose that, as in our experiments with Quercus species (resp. Blocks World), the problemasks for an at least (resp. at most) w-weighted solution and we need an upper bound (resp. alower bound) to estimate the weight of a solution from a partial solution. Then we can findsuch an upper bound (resp. a lower bound) by adding the sum of the weights ω′(x) of allcomponents x included in the partial solution (and thus in the solution), to the maximum(resp. minimum) value of the sum of the weights ω′(y) of all components y that are not yetknown to be included in the solution.

Alternatively, we can estimate an upper/lower bound by considering the componentsthat are found to be not-part-of a solution. Suppose that, as in phylogeny reconstruction forIndo-European languages, the problem asks for an at least w-weighted solution and we needan upper bound to estimate the weight of a solution from a set of components found to benot-part-of the solution. Then we can find such an upper bound by subtracting the sum of

Page 25: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

25

the weights ω′(x) of all components x that are found to be not-part-of the solution, from themaximum value of ω.

10 Related Work

Computing weighted solutions can be considered as a method to compute preferred solu-tions. In that sense, our studies are related to computing preferred answer sets which hasbeen studied extensively. For instance, one way to describe preferences is to prioritize therules in the program [12,29]. With this approach, the rules of the program are ranked ac-cording to some preference relation; the answer sets which are described by higher rankedrules are selected as the preferred answer sets. Similar to prioritized programs, [2] and [3]propose several methods for describing preferences of answer sets via preferences over lit-erals. The idea is to have a ranking over the literals in the head of the rules; the answer setswhich consist of higher-ranked literals are presented as more preferred ones. Another ap-proach to represent preferences is to assign weights to weak constraints [6] or literals [25].The idea is to assign weights to rules or literals, then the answer sets whose total weight isabove some threshold are considered to be more preferred. In [27], the authors take a simi-lar approach by assigning weights to rules; the idea here is to compute the answer sets thatsatisfy a subset of the rules whose weight is maximum. Although these techniques mightbe effective in describing some simple weight measures, in general they are not suitable fordescribing more complex weight measures (e.g., weight of a phylogeny) that require explicitdefinitions.

Another line of work that is related is computation of similar/diverse solutions [11] withrespect to a given distance function. In [11], the authors propose defining a distance functionto measure the similarity/diversity of solutions, and present a method for integrating thisdistance measure in CLASP to compute n k-similar (resp. diverse) solutions (i.e., n solutionswhose distance is less (resp. greater) than or equal to k). They call this modified version ofCLASP as CLASP-NK. Note that AT LEAST (resp. AT MOST) w-WEIGHTED SOLUTION canbe solved using CLASP-NK of [11] by defining the distance function in terms of the givenweight function ω. However, in general, we cannot compute n k-similar (resp. diverse) atleast (resp. most) w-weighted solutions in this way. To be able to solve all four variationsof n k-SIMILAR (resp. k-DIVERSE) AT LEAST (resp. AT MOST) w-WEIGHTED SOLUTIONS

using CLASP-NK, we need to define four different distance functions (rather than a genericdistance function) in terms of the given distance function∆ and the given weight function ω.On the other hand, we can extend the applicability of our methods and the methods of [11],by considering more general problems as follows:

n k-SIMILAR (resp. k-DIVERSE) AT LEAST (resp. AT MOST) w-WEIGHTED SOLU-TIONS: Given an ASP program P that formulates a computational problem P , a weightmeasure ω that maps a solution for P to a nonnegative integer, a distance measure∆ thatmaps a set of solutions to a nonnegative integer, nonnegative integers w and k, decidewhether a set S of n solutions for P exists such that ∆(S) ≤ k (resp. ∆(S) ≥ k) andfor each s ∈ S, ω(s) ≥ w (resp. ω(s) ≤ w).

In fact, we introduce a search-based method for computing n k-similar (resp. k-diverse) atleast (resp. at most) w-weighted solutions in ASP, and implement this method by modifyingthe search algorithm CLASP-W as in Algorithm 3; the parts in blue denote these modifi-cations. The modified version is called CLASP-NKW. We apply the search-based method

Page 26: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

26

Algorithm 3 CLASP-NKWInput: An ASP program Π and nonnegative integers w, n and kOutput: A set of n k-similar at least w-weighted solutionsA← ∅ // current assignment of literals5← ∅ // set of conflictsX ← ∅ // previously computed answer setswhile |X| < n do

PROPAGATION(Π,A,5)weight← WEIGHT-ANALYZE(A) // Related to CLASP-Wdistance← DISTANCE-ANALYZE(A,X) // Related to CLASP-NKif (There is a conflict in propagation) OR (weight < w) OR (distance > k) then

RESOLVE-CONFLICT (Π,A,5)end ifif Current assignment does not yield an answer set then

SELECT(Π,A,5)else

return X ← X ∪Aend if

end whilereturn X

for computing similar/diverse weighted solutions to reconstructing phylogenies for Indo-European languages using CLASP-NKW. In these batch of experiments, we consider thenodal distance (as in [11]) to measure the similarity/diversity of a set of phylogenies. Forinstance, we compute 2 12-similar and at least 45-weighted phylogenies using CLASP-NKW;the computation takes 2.3 CPU sec.s. Likewise, we compute 2 24-diverse and at least 45-weighted phylogenies using CLASP-NKW; the computation takes 2.7 CPU sec.s. The resultsof our experiments comply with the groupings of [4]: the similar phylogenies computed byCLASP-NKW are in the same group; the diverse phylogenies are in different groups.

11 Conclusion

We have studied problems related to computing weighted solutions in ASP, investigatedcomputational methods to solve them using the state-of-the-art answer set solvers, comparedthese methods experimentally, and showed their usefulness and effectiveness in phylogenyreconstruction applied to two real datasets, Indo-European languages and Quercus species,and in AI planning applied to Blocks World.

In particular, we have investigated two sorts of methods for computing weighted so-lutions: one method suggests modifying the ASP representation of the problem to computeweighted solutions using an existing ASP solver and the other suggests modifying the searchalgorithm of the answer set solver to compute weighted solutions incrementally. In our ex-periments, we have used the answer set solver CLASP with the representation-based method;and we have modified the search algorithm of CLASP and called it CLASP-W for the search-based method. In the representation-based method, a given weight function is represented inASP; in the search-based method however it is implemented in C++.

In our experiments, we have observed the following:

– In terms of computational efficiency (time and space), the search-based method outper-forms the representation-based method (Sections 6.4 and 8.3). This is mainly due totwo reasons: in the search-based method, the weight function is not explicitly defined

Page 27: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

27

in ASP, and thus the program size is smaller; the search algorithm of the ASP solver ismodified to prevent redundant search, and thus the search space is smaller as well.

– The representation-based methods may be preferable if the weight function can be de-fined concisely in ASP. On the other hand, some weight measures, which involve math-ematical functions (e.g., division, logarithm) over real numbers, cannot be representedin ASP; in such cases the search-based method provides a useful tool for computingweighted solutions in ASP, as seen in Section 7.1.

– The performance of a representation-based method can be improved by utilizing theconstructs supported by the particular answer set solver. For instance, if the answer setsolver supports aggregates then it may be more advantageous to use aggregates insteadof a recursive definition while defining the weight function, as shown in Section 6.2.

– For the search-based methods, one needs to construct a heuristic function to estimatethe weight of a complete solution from a partial solution; to guarantee completeness, theheuristic function should be admissible. For some cases, for instance, when weightedsolutions are computed quite often as part of a real-world application (e.g., considercomputation of weighted phylogenies integrated as part of a phylogenetics system likePHYLO-ASP [14]), it may worth constructing an (admissible) heuristic function.

– In the search-based method, the weight function is defined in C++ in a separate file. Thisallows us to use CLASP-W easily with different weight measures, without modifying itssearch algorithm.

Based on the promising experimental results in phylogenetics, we have extended oursearch-based method to be able to compare weighted solutions; for that we have modifiedCLASP-W in the spirit of [11]. The modified version of CLASP-W is called CLASP-NKW.In this way, given a weight measure ω for a phylogeny and a distance measure ∆ for a setof phylogenies (both as C++ programs, in separate files), we can compute similar/diverseweighted phylogenies.

Our methods for computing (similar/diverse) weighted solutions, and the solvers CLASP-W

and CLASP-NKW provide useful tools for analyzing/comparing solutions in ASP. In ASP,there are many appealing applications. For example, one can use CLASP-W to compute morepreferred products in a product configuration problem [32]. In planning [20], one can be in-terested in assigning weights to actions. Then, it might be desirable to compute plans whosetotal action weight is less than some threshold. We can use CLASP-W for such an applica-tion by defining an appropriate weight measure and an (admissible) heuristic function forthe weight measure.

Our methods can be useful to some application domains as well, such as phylogenetics.In phylogenetics, there is no software system that has utilities for analyzing/comparing phy-logenies; in that sense, our search-based methods (including the weight/distance measures)allow experts to automatically analyze phylogenies.

Acknowledgments

Thanks to anonymous reviewers for their useful suggestions to improve the paper. This workhas been supported by TUBITAK Grant 107E229.

References

1. Y. Bakıs. Morphometric Analysis of Oak (Quercus L.) Acorns in Turkey. PhD thesis, Abant Izzet BaysalUniversity, 2005.

Page 28: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

28

2. G. Brewka, I. Niemela, and M. Truszczynski. Answer set optimization. In Proc. of IJCAI, pages 867–872, 2003.

3. Gerhard Brewka. Logic programming with ordered disjunction. In Proc. of AAAI, pages 100–105, 2002.4. D. R. Brooks, E. Erdem, S. T. Erdogan, J. W. Minett, and D. Ringe. Inferring phylogenetic trees using

answer set programming. Journal of Automated Reasoning, 39(4):471–511, 2007.5. D. R. Brooks, E. Erdem, J. W. Minett, and D. Ringe. Character-based cladistics and answer set program-

ming. In Proc. of PADL, pages 37–51, 2005.6. F. Buccafurri, N. Leone, and P. Rullo. Strong and weak constraints in disjunctive datalog. In Proc. of

LPNMR, pages 2–17, 1997.7. D. Cakmak, E. Erdem, and H. Erdogan. Computing weighted solutions in answer set programming. In

Proc. of LPNMR, pages 416–422, 2009.8. D. Cakmak, H. Erdogan, and E. Erdem. Computing weighted solutions in ASP: Representation-based

method vs. search-based method. In Proc. of RCRA Workshop on Experimental Evaluation of Algorithmsfor Solving Problems with Combinatorial Explosion, 2010.

9. M. Davis, G. Logemann, and D. Loveland. A machine program for theorem-proving. Communicationsof the ACM, 5:394–397, 1962.

10. W. H. E. Day and D. Sankoff. Computational complexity of inferring phylogenies by compatibility.Systematic Zoology, 35(2):224–229, 1986.

11. T. Eiter, E. Erdem, H. Erdogan, and M. Fink. Finding similar or diverse solutions in answer set program-ming. In Proc. of ICLP, 2009.

12. T. Eiter, W. Faber, N. Leone, and G. Pfeifer. Computing preferred and weakly preferred answer sets bymeta interpretation in answer set programming. In Proc. of ASP Workshop, 2001.

13. E. Erdem. Theory and applications of answer set programming. PhD thesis, Department of ComputerSciences, University of Texas at Austin, 2002.

14. Esra Erdem. Phylo-asp: Phylogenetic systematics with answer set programming. In Proc. of LPNMR,pages 567–572, 2009.

15. W. Faber, G., N. Leone, T. Dell’Armi, and G. Ielpa. Design and implementation of aggregate functionsin the dlv system. Theory and Practice of Logic Programming, 8(5-6):545–580, 2008.

16. Paolo Ferraris and Vladimir Lifschitz. Weight constraints as nested expressions. Theory and Practice ofLogic Programming, 5:45–74, 2005.

17. M. Gebser, B. Kaufmann, A. Neumann, and T. Schaub. Conflict-driven answer set solving. In Proc. ofIJCAI, pages 386–392, 2007.

18. M. Gelfond and V. Lifschitz. The stable model semantics for logic programming. In Proc. of ICLP,pages 1070–1080. MIT Press, 1988.

19. Michael Gelfond and Vladimir Lifschitz. Classical negation in logic programs and disjunctive databases.New Generation Computing, 9:365–385, 1991.

20. V. Lifschitz. Action languages, answer sets and planning. In The Logic Programming Paradigm: a25-Year Perspective, pages 357–373. Springer Verlag, 1999.

21. V. Lifschitz. What is answer set programming? In Proc. of AAAI, 2008.22. Vladimir Lifschitz, Lappoon R. Tang, and Hudson Turner. Nested expressions in logic programs. Annals

of Mathematics and Artificial Intelligence, 25:369–389, 1999.23. Luay Nakhleh. Phylogenetic networks. PhD thesis, 2004.24. Ilkka Niemela and Patrik Simons. Extending the smodels system with cardinality and weight constraints.

pages 491–521, 2001.25. D. V. Nieuwenborgh, S. Heymans, and D. Vermeir. Weighted answer sets and applications in intelligence

analysis. In Proc. of LPAR, pages 169–183, 2004.26. M. Nogueira, M. Balduccini, M. Gelfond, R. Watson, and M. Barry. An a-prolog decision support system

for the space shuttle. In Proc. of PADL, pages 169–183, 2001.27. E. Oikarinen and M. Jarvisalo. Max-ASP: Maximum satisfiability of answer set programs. In Proc. of

LPNMR, pages 236–249, 2009.28. D. Ringe, T. Warnow, and A. Taylor. Indo-European and computational cladistics. Transactions of the

Philological Society, 100(1):59–129, 2002.29. C. Sakama and K. Inoue. Prioritized logic programming and its application to commonsense reasoning.

Artificial Intelligence, 123(1-2):185–222, 2000.30. P. Simons, I. Niemela, and T. Soininen. Extending and implementing the stable model semantics. Artifi-

cial Intelligence, 138:181–234, 2002.31. P. Simons and T. Soininen. Stable model semantics of weight constraint rules. In Proc. of LPNMR, pages

317–331, 1999.32. Timo Soininen and Ilkka Niemela. Developing a declarative rule language for applications in product

configuration. In Proc. of PADL, pages 305–319, 1998.

Page 29: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

29

33. T. C. Son and E. Pontelli. A constructive semantic characterization of aggregates in answer set program-ming. Theory and Practice of Logic Programming, 7(3):355–375, 2007.

34. T.C. Son, E. Pontelli, and C. Sakama. Logic programming for multiagent planning with negotiation. InProc. of ICLP, pages 99–114, 2009.

35. Nam Tran and Chitta Baral. Reasoning about triggered actions in ansprolog and its application to molec-ular interactions in cells. In Proc. of KR, pages 554–564, 2004.

36. J. P. White and J. F. O’Connell. A Prehistory of Australia, New Guinea, and Sahul. Academic, 1982.37. Jia-Huai You, Li-Yan Yuan, and Mingyi Zhang. On the equivalence between answer sets and models of

completion for nested logic programs. In Proc. of IJCAI, pages 859–864, 2003.

Appendix

A Proof of Proposition 1

Proposition 1 AT LEAST (resp. AT MOST) w-WEIGHTED SOLUTION is NP-complete.

Proof Membership follows from the fact that we can not only guess a candidate solution S but also a witnessfor ω(S) ≤ w (resp. ω(S) ≥ w), and check in polynomial time whether ω(S) ≤ w (resp. ω(S) ≥ w).For hardness, we can reduce the answer set existence for normal propositional programs, which is an NP-complete problem, to this problem: take ω(S) = 1 for every S and w = 0.

B Proof of Proposition 2

Proposition 2 wc-WCP is NP-complete.

Proof Membership follows from the fact that we can not only guess a candidate tree (V,E) but also checkin polynomial time whether weight(V,E, L, I, S, f) ≥ w and whether the phylogeny has at most c incom-patible characters [23, Theorem 17]. For hardness, we can reduce c-CP to wc-WCP by taking ω(i) = 1 forevery i ∈ I .

C Proof of Proposition 3

Proposition 3 UBΦ is admissible.

Proof We want to show that UBΦ(A, I) never underestimates the weight function weight(P ), for everycomplete phylogeny P that extends A.

Take any complete phylogeny P that extends A. Let ICP be the characters that are incompatible withP ; and let ICA be the characters that are incompatible with A.

The weight of P is:

weight(P ) =∑

i∈I,i is compatible

Φ(i) =∑i∈I

Φ(i)−∑

i∈I,i∈ICP

Φ(i).

On the other hand, since P is a completion of A, ICA ⊆ ICP , and thus∑i∈I,i∈ICA

Φ(i) ≤∑

i∈I,i∈ICP

Φ(i).

Then ∑i∈I

Φ(i)−∑

i∈I,i∈ICP

Φ(i) ≤∑i∈I

Φ(i)−∑

i∈I,i∈ICA

Φ(i).

Therefore, weight(P ) ≤ UBΦ(A, I).

Page 30: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

30

D Proof of Proposition 4

Proposition 4 UBϕ is admissible.

We need the following definitions, notation, and lemmas to prove Proposition 4.Let P be a phylogeny (V,E, L, I, S, f). We say that a phylogeny X = (VX , EX , LX , IX , SX , fX)

is contained in P (denoted X ⊆ P ) if VX ⊆ V , EX ⊆ E, LX ⊆ L, IX ⊆ I , SX ⊆ S, f |LX= fX .

Let X = (VX , EX , LX , IX , SX , fX) and Y = (VY , EY , LY , IY , SY , fY ) be two partial phyloge-nies contained in P . We say that X is label-contained in Y (denoted X ⊆l Y ) if

– X ⊆ Y ,– for every v ∈ V , labelX(v) ⊆ labelY (v).

In the following lemmas, let P1 (with vertices VP1) and P2 (with vertices VP2

) be two partial phyloge-nies of P such that P1 ⊆l P2 and |EP2

\ EP1| ≤ 1.

Lemma 1 For every vertex v ∈ V , if labelP1 (v) = ∅ or v is not in VP1 , then ϕ′P1

(v) ≥ ϕ′P2

(v).

Lemma 2 For every vertex v ∈ V , if v does not have a sibling in P1 or labelP1(siblingP1

(v)) = ∅ thenϕ′P1

(v) ≥ ϕ′P2

(v).

Lemma 3 For every partial phylogeny P1 of P and for every vertex v ∈ V , if

(i) labelP1(v) 6= ∅,

(ii) labelP1 (siblingP1 (v)) 6= ∅,(iii) labelP1

(v) ∩ labelP1(siblingP1

(v)) = ∅,then ϕ′

P1(v) = 0.

Lemma 4 For every vertex v ∈ V , if

(i) labelP1(v) 6= ∅,

(ii) labelP1(siblingP1

(v)) 6= ∅,(iii) labelP1 (v) ∩ labelP1 (siblingP1 (v)) 6= ∅.ϕ′P1

(v) ≥ ϕ′P2

(v).

Lemma 5 For every vertex v ∈ V , if

(i) labelP1 (v) 6= ∅,(ii) labelP1 (siblingP1 (v)) 6= ∅,

(iii) labelP2(v) ∩ labelP2

(siblingP2(v)) = ∅.

then ϕ′P1

(v) = ϕ′P2

(v) = 0.

Lemma 6 For every vertex v ∈ V , if

(i) labelP1(v) 6= ∅,

(ii) labelP1(siblingP1

(v)) 6= ∅,(iii) labelP1 (v) ∩ labelP1 (siblingP1 (v)) = ∅,(iv) labelP2 (v) ∩ labelP2 (siblingP2 (v)) 6= ∅.(v) EP2

= EP1

then there exists a label Z ∈ labelP2(siblingP2

(v)) such that

(a) Z ∈ (labelP2(v) ∩ labelP2

(siblingP2(v)),

(b) Z 6∈ labelP1 (v),(c) Z ∈ labelP1

(siblingP1(v)),

(d) for some leaf child vc of v, Z ∈ labelP2(vc).

Lemma 7 For every vertex v ∈ V , if

(i) labelP1(v) 6= ∅,

(ii) labelP1(siblingP1

(v)) 6= ∅,(iii) labelP1

(v) ∩ labelP1(siblingP1

(v)) = ∅,(iv) labelP2 (v) ∩ labelP2 (siblingP2 (v)) 6= ∅,(v) EP2

6= EP1.

then

Page 31: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

31

(a) there exists an edge (v, vc) ∈ EP2 but not in EP1 and,(b) there exists a label Z ∈ labelP2

(siblingP2(v)) such that,

(b1) Z ∈ (labelP2(v) ∩ labelP2

(siblingP2(v))

(b2) Z ∈ labelP1(siblingP1

(v)),(b3) Z 6∈ labelP1

(v),(b4) for some child vc of v, Z ∈ labelP2 (vc).

Lemma 8 For every vertex v ∈ V , if(i) labelP1 (v) 6= ∅,

(ii) labelP1(siblingP1

(v)) 6= ∅,(iii) labelP1

(v) ∩ labelP1(siblingP1

(v)) = ∅,(iv) labelP2 (v) ∩ labelP2 (siblingP2 (v)) 6= ∅then the following hold:(a) ϕ′

P2(v) ≥ ϕ′

P1(v),

(b) There exists a child vc of v, ϕ′P2

(vc) ≤ ϕ′P1

(vc),(c) (ϕ′

P1(vc)− ϕ′

P2(vc))− (ϕ′

P2(v)− ϕ′

P1(v)) ≥ 0.

Lemma 9 UBϕ(P2, V ) ≤ UBϕ(P1, V ).

Lemma 10 weight(P ) = UBϕ(P, V ).

Proof (Proposition 4) We want to show that, for any partial phylogenyP0 ofP ,UBϕ(P0, V ) ≥ weight(P ).For any partial phylogeny P0, there is a sequence of partial phylogenies P0, P1, ..., Pk be partial phy-

logenies of P , such that P0 ⊆l P1 ⊆l ... ⊆l Pk = P .Due to Lemmas 9, ∀i(0 ≤ i ≤ k)UBϕ(Pi, V ) ≥ UBϕ(Pi+1, V ). Then,UBϕ(P0, V ) ≥ UBϕ(P, V )

as well. By Lemma 10, UBϕ(P0, V ) ≥ weight(P ). Therefore, UBϕ is admissible.

Proof (Lemma 1) Take any vertex v ∈ V . Assume that labelP1 (v) = ∅ or v is not in VP1 . Then by thedefinition of ϕ′

P1, ϕ′

P1(v) = 1. Since 1 is the maximum value of ϕ′

W for every partial phylogeny W ,ϕ′P1

(v) ≥ ϕ′P2

(v).

Proof (Lemma 2) Take any vertex v ∈ V . Assume that v does not have a sibling inP1 or labelP1 (siblingP1 (v)) =∅. Then by the definition of ϕ′

P1, ϕ′P1

(v) = 1. Since 1 is the maximum value of ϕ′W for anyW , ϕ′

P1(v) ≥

ϕ′P2

(v).

Proof (Lemma 3) Take any v ∈ V . Assume (i)–(iii). Due to (i) and (ii),

ϕ′P1

(v) = minCP1(v) = min(maxContrP1

(v),maxContrP1(siblingP1

(v))).

Due to (iii), since v and siblingP1 (v) do not share a label in P1,

∀l ∈ labelP1(v), ςP1

(l, v) = 0

and∀l ∈ labelP1

(siblingP1(v)), ς(l, siblingP1

(v)) = 0.

That ismaxContrP1 (v) = 0 andmaxContrP1 (siblingP1 (v)) = 0.

Therefore, ϕ′P1

(v) = 0.

Proof (Lemma 4) Take any v ∈ V . Assume that (i), (ii) and (iii) hold for v. Observe that the maximumvalue that |labelP1

(v)| can take is the total number of classes due to the definition of labels via propagation.Consider two cases:

Case 1: |labelP1(v)| = the total number of classesDue to (i) and (ii) and the propagation of labels described in the definition of label,

ϕ′P2

(v) = minCP2(v)

= min(maxContrP2 (v),maxContrP2 (siblingP2 (v))).

Due to propagation of labels described in the definition of label, |labelP2(v)| = the total number ofclasses. Then, due to the definition of ςP2 , ϕ′

P2(v) = maxContrP2 = 0. Since 0 is the minimum

value of ϕ′W for any partial phylogeny W , ϕ′

P1(v) ≥ ϕ′

P2(v).

Page 32: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

32

Case 2: |labelP1(v)| < the total number of classesDue to (i) and (ii),

ϕ′P1

(v) = minCP1(v)

= min(maxContrP1 (v),maxContrP1 (siblingP1 (v))).= min( 1

|labelP1(v)| ,

1|siblingP1

((v))| )

Due to (i) and (ii) and the propagation of labels described in the definition of label,

ϕ′P2

(v) = minCP2(v)

= min(maxContrP2(v),maxContrP2

(siblingP2(v))).

Due toP1 ⊆l P2, since |labelP1(v)| ≤ |labelP2

(v)| and |labelP1(siblingP1

(v))| ≤ |labelP2(siblingP2

(v))|,ϕ′P1

(v) ≥ ϕ′P2

(v).

Proof (Lemma 5) Take any v ∈ V . Assume that (i), (ii), (iii) hold.Since labelP2

(v) ∩ labelP2(siblingP2

(v)) = ∅ and P1 ⊆l P2,

labelP1 (v) ∩ labelP1 (siblingP1 (v)) = ∅.

Then, due to (i), (ii), and by Lemma 3, ςP1(l, v) = 0.

Since P1 ⊆l P2, for every v ∈ V , labelP1(v) ⊆ labelP2

(v). Then, due to (i) and (ii), labelP2(v) 6= ∅,

labelP2(siblingP2

(v)) 6= ∅. Then, due to (i) and by Lemma 3, ςP2(l, v) = 0.

Therefore, ϕ′P1

(v) = 0 and ϕ′P2

(v) = 0.

Proof (Lemma 6) Take any v ∈ V . Assume that (i), (ii), (iii),(iv) and (v) hold for v. Due to (iv), (a) holds.Due to (iii) and P1 ⊆l P2, (b) holds. Due to P1 ⊆l P2, (c) holds. Due to (iv) and the propagation of labelsdescribed in the definition of label, (d) holds.

Proof (Lemma 7) Take any v ∈ V . Assume that (i), (ii), (iii),(iv) and (v) hold for v. Due to (v), (a) holds.Due to (iv), (b1) holds. Due to P1 ⊆l P2, (b2) holds. Due to P1 ⊆l P2, (iii) and (iv), (b3) holds. Due to (iv)and the propagation of labels described in the definition of label, (b4) holds.

Proof (Lemma 8)Take any v ∈ V . Assume that (i), (ii), (iii) and (iv) hold for v.

(a) ϕ′P2

(v) ≥ ϕ′P1

(v).Due to Lemma 3, ϕ′

P1(v) = 0. Since 0 is the minimum value of ϕ′

Z for every partial phylogeny Z,ϕ′P2

(v) ≥ ϕ′P1

(v).(b) There exists a child vc of v, ϕ′

P2(vc) ≤ ϕ′

P1(vc).

Consider two cases:Case 1: [EP2

= EP1](Figure 5) Due to Lemma 6, there exists a label Z 6∈ labelP1

(v) and Z ∈labelP2

(v) and there is a leaf-child vc of v such that Z ∈ label(vc) due to propagation of la-bels described in the definition of label. Since Z 6∈ labelP1 (v), there is no child v′c of v such thatZ ∈ labelP1

(v′c); therefore, Z 6∈ labelP1(vc). Since vc is a leaf, then labelP1

(vc) = ∅. Thenby Lemma 1, ϕP1 (vc) = 1. Since 1 is the maximum value of ϕW for every partial phylogeny W ,ϕ′P2

(vc) ≤ ϕ′P1

(vc).Case 2: [EP2 6= EP1 ] (Figure 6) Due to Lemma 7, since edge (v, vc) 6∈ EP1 , vc 6∈ VP1 . Then by

Lemma 1, ϕP1(vc) = 1. Since 1 is the maximum value of ϕW for every partial phylogeny W ,

ϕ′P2

(vc) ≤ ϕ′P1

(vc).

(c) (ϕ′P1

(vc)− ϕ′P2

(vc))− (ϕ′P2

(v)− ϕ′P1

(v)) ≥ 0.Consider two cases:

Case 1: [EP2= EP1

] (Figure 5)Since (i), (ii) and (iii) hold, then by Lemma 3, ϕ′

P1(v) = 0.

Let us consider the case when ∀v ∈ V , (ϕ′P2

(v) − ϕ′P1

(v)) is maximum. Since (i) and (ii) hold,then labelP2 (v) 6= ∅, labelP2 (siblingP2 (v)) 6= ∅ and

ϕ′P2

(v) = minCP1 (v)

= min(maxContrP1(v),maxContrP1

(siblingP1(v))).

Page 33: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

33

v

siblingP1(v)

vc

Z

A

A

P1

v

Z

A, Z

P2

siblingP2(v)

siblingP1(vc) vcA

siblingP1(vc)

Fig. 5 Case 1 of the proof of Lemma 8.

v

siblingP1(v)Z

A

A

P1

v

vc

A, Z

Z

P2

siblingP1(vc)

Z

ZAsiblingP1(v)siblingP1(vc)

Fig. 6 Case 2 of the proof of Lemma 8.

Since (i), (iii) and (iv) hold, we know that one of v or siblingP2(v) has at least 2 labels in P2 and

the other one has at least 1 label in P1. (Note that Z ∈ labelP2(v) ∩ labelP2

(siblingP2(v)).)

Since by Lemma 6, Z 6∈ labelP1(v), Z ∈ labelP2

(vc), Z is also in labelP2(v); then we know

that v has at least 2 labels and siblingP2(v) has at least 1 label in P2. Therefore,

ϕ′P2

(v) = min( 1|labelP2

(v)| ,1

|labelP2(siblingP2

(v))| )

= min( 12, 1) = 1

2.

(Observe that if the number of labels of v or sibling(v) is greater than 2, ϕ′P2

(v) is smaller). Sincethe maximum value of ϕ′

P2is 1

2and the value of ϕ′

P1is 0, ϕ′

P2(v)− ϕ′

P1(v) ≤ 1

2.

Let us consider the case when ϕ′P1

(vc) − ϕ′P2

(vc) is minimum. Since Z ∈ labelP2(v), there

should be a leaf l ∈ VP2such that Z ∈ label(l). Let vc = l. Since Z 6∈ labelP1

(v), There is

Page 34: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

34

no child vd of v such that Z ∈ labelP1 (vd); therefore, Z 6∈ labelP1 (vc). Since vc is a leaf, theneither vc 6∈ V or labelP1

(vc) = ∅. Then by Lemma 1, ϕP1(vc) = 1. Since Z 6∈ labelP1(v), and

∃C ∈ labelP1(v); C ∈ labelP1

(sibling(vc))( Because C should be propagated from its childsibling(vc) to v.). Since Z 6= C, and the condition (iii), by Lemma 3, ϕP1

(vc) = 0. Since thevalue of ϕP1

(vc) is 1 and the value of ϕP1(vc) is 0, ϕ′

P1(vc)− ϕ′

P2(vc) = 1.

Since ϕ′P2

(v)−ϕ′P1

(v) ≤ 12

and ϕ′P1

(vc)−ϕ′P2

(vc) = 1, (ϕ′P1

(vc)−ϕ′P2

(vc))−(ϕ′P2

(v)−ϕ′P1

(v)) > 0.Case 2: [EP2

6= EP1] (Figure 6) Since (i), (ii) and (iii) hold, then by Lemma3, ϕ′

P1(v) = 0.

Let us consider the case when (ϕ′P2

(v) − ϕ′P1

(v)) is maximum. Due to (i),(ii), and P1 ⊆l P2,labelP2 (v) 6= ∅, labelP2 (siblingP2 (v)) 6= ∅ and

ϕ′P2

(v) = minCP1 (v)

= min(maxContrP1(v),maxContrP1

(siblingP1(v))).

Due to (i) and P1 ⊆l P2, v has at least one label A in P2. Due to Lemma 7, v has another label Zin P2. Due to Lemma 7 and P1 ⊆l P2, Z is also a label of siblingP2

(v). We know that v has atleast 2 labels and siblingP2 (v) has at least 1 label in P2. Therefore,

ϕ′P2

(v) = min(1

|labelP2(v)|

,1

|labelP2(siblingP2

(v))|) = min(

1

2, 1) =

1

2.

Since the maximum value of ϕ′P2

is 12

and the value of ϕ′P1

(v) is 0, ϕ′P2

(v)− ϕ′P1

(v) ≤ 12.

Let us now consider the case when ∀v ∈ V , ϕ′P1

(vc) − ϕ′P2

(vc) is minimum. Due to Lemma 7,since edge (v, vc) 6∈ EP1 , vc 6∈ VP1 . Then by Lemma 1, ϕ′

P1(vc) = 1.

Due to (i), v has at least one label A in V1. Due to Lemma 7, there exists a label Z in labelP2(v),

that is not in labelP1 (v); thus Z 6= A. Due to Lemma 7, vc 6∈ VP1 . On the other hand, dueto the definition of label, there exists a child vs of v in P1, such that A ∈ labelP1

(vs). Since(v, vc) ∈ P2, vs is the sibling of vc in P2. So, siblingP1 (vc) and siblingP2 (vc) has at least 1label which isA. So far we know that labelP2

(vc) has at least one label Z, and labelP2(vc) has at

least one labelA. The function ϕ′P2

gets the maximum value for vc for instance under the followingcondition: labelP2

(siblingP2(vc)) = {A} and labelP2

(vc) = {Z,A}. If vc and siblingP2(vc)

have more than 2 labels, due to the definition of ς , ϕ′P2

decreases. Then

ϕ′P2

(vc) = minCP2(v)

= min(maxContrP2(vc),maxContrP2

(siblingP2(vc)))

= min( 1|labelP2

(vc)|, 1|labelP2

(siblingP2(vc))|

)

= min( 12, 1) = 1

2.

Since the minimum value ofϕ′P1 is 1 and the maximum value ofϕ′P1 is 12

,ϕ′P1

(vc)−ϕ′P2

(vc) ≥12

.Since ϕ′

P2(v)−ϕ′

P1(v) ≤ 1

2and ϕP1(vc) is 1

2, ϕ′P1

(vc)−ϕ′P2

(vc) ≥ 12

, we can conclude that

(ϕ′P1

(vc)− ϕ′P2

(vc))− (ϕ′P2

(v)− ϕ′P1

(v)) ≥ 0.

Proof (Lemma 9)Consider two cases:

Case 1: Assume that one of the following holds:(i) labelP1

(v) = ∅,(ii) labelP1

(siblingP1(v)) = ∅,

(iii) labelP1 (v) ∩ labelP1 (siblingP1 (v)) 6= ∅,(iv) labelP2

(v) ∩ labelP2(siblingP2

(v)) = ∅.If (i), by Lemma 1, ϕ′

P1(v) ≥ ϕ′

P2(v). By definition of UB, UBϕ(P2, V ) ≤ UBϕ(P1, V ).

If (ii), by Lemma 2, ϕ′P1

(v) ≥ ϕ′P2

(v). By definition of UB, UBϕ(P2, V ) ≤ UBϕ(P1, V ).If neither (i) nor (ii) holds, and (iii) holds, by Lemma 4, ϕ′

P1(v) ≥ ϕ′

P2(v). By definition of UBϕ,

UBϕ(P2, V ) ≤ UBϕ(P1, V ).If neither (i) nor (ii) holds, and (iv) holds, by Lemma 5, ϕ′

P1(v) ≥ ϕ′

P2(v). By definition of UBϕ,

UBϕ(P2, V ) ≤ UBϕ(P1, V ).

Page 35: Computing Weighted Solutions in ASP: Representation ... - pages.cs…pages.cs.wisc.edu/~halit/papers/amai11.pdf · configuration [32], planning [20], multi-agent planning [34], phylogeny

35

Case 2: Assume that all of the following hold:(i) labelP1 (v) 6= ∅,

(ii) labelP1(siblingP1

(v)) 6= ∅,(iii) labelP1

(v) ∩ labelP1(siblingP1

(v)) = ∅,(iv) labelP2

(v) ∩ labelP2(siblingP2

(v)) 6= ∅.Although ϕ′

P2(v) ≥ ϕ′

P1(v) by Lemma 8(a), there is a child vc of v such that ϕ′

P2(vc) ≤ ϕ′

P1(vc)

by Lemma 8(b).Moreover, the difference between (ϕ′

P1(vc)−ϕ′

P2(vc)) is greater than the difference between (ϕ′

P2(v)−

ϕ′P1

(v)) by Lemma 8(c).Therefore,

∑v∈V ϕP2(v) ≤

∑v∈V ϕP1(v); and UBϕ(P2, V ) ≤ UBϕ(P1, V ).

Proof (Lemma 10) Since P is a complete phylogeny, all of its vertices and labels of each vertex is complete.Then, for every v ∈ V , by definition of ϕ′, ϕ′

P (v) = minCP (v) = ϕP (v). Therefore, by the definitionsof weight and UBϕ, weight(P ) = UBϕ(P, V ).

E Proof of Proposition 5

Proposition 5 LBψ is admissible.

Proof Take any completion P of Pp, we will prove that LBψ(Pp) ≤ ψ(P ) where

LBψ(Pp) =∑

i∈D(Pp)

∑a∈act(Pp,i)

ζ(a)

and,

ψ(P ) =

|P |∑i=1

∑a∈act(P,i)

ζ(a)

Since P is a completion of Pp, {1, ..., |P |} ⊇ {i ∈ D(Pp)}. We also know that act(P, i) extendsact(Pp, i) and all the primitive actions that appear inPp is a subset of all the primitive actions inP ; therefore,

∑i∈D(Pp)

∑a∈act(Pp,i)

ζ(a) ≤|P |∑i=1

∑a∈act(P,i)

ζ(a)

Hence, LBψ(Pp) ≤ ψ(P ).