1 Introduction
A fruitful approach to aggregates in answer set programming has been presented in [Faber et al.2010] that allows to represent and reason in the presence of aggregate function which are defined through aggregates atoms that are allowed to be recursive. The aggregate functions defined in [Faber et al.2010], and hence the aggregate atoms defined over them, are allowed to be monotone, antimonotone and nonmonotone which is clearly appropriate for nonmonotonic reasoning. The answer set semantics with aggregates defined in [Faber et al.2010] have shown to be appropriate for many interesting problems in answer set programming that require aggregates over some numerical criteria imposed by the problems and arise in many domains.
On the other hand aggregates have been considered in answer set optimization programming described in [Saad and Brewka2011] that extended the answer set optimization programs [Brewka et al.2003] to allow representing and declaratively solving multiobjective optimization problems in an answer set programming framework. The answer set optimization with aggregates framework of [Saad and Brewka2011] have shown to be able to find Nash equilibrium in strategic games with any number of players and with any number of strategies, which is a multiobjective optimization problem with multiple conflicting goals.
However the aggregates defined in the answer set programming framework in [Faber et al.2010] allow a single aggregation over a single variable which limits its applicability to many interesting problems, especially the problems that require aggregations over a function with multiple variables. And hence, more generally limits its applicability to the problems that require nested multiple aggregations over multiple variables and the problems that require nested multiple aggregations over functions with multiple variables.
On the other hand, although the aggregates defined in answer set optimization programming [Saad and Brewka2011], is similar to the aggregates defined in the answer set programming [Faber et al.2010], allows a single aggregation over a single variable, the answer set optimization programming in [Saad and Brewka2011] is still capable of solving some interesting multiobjective optimization problems like the one arises from finding Nash equilibrium in strategic games. However, the answer set optimization programming of [Saad and Brewka2011] is still incapable of representing and reasoning about many interesting optimization problems that require optimization over objective functions that involve nested multiple aggregation over functions that contain multiple variables. This implies minimization or maximization over nested multiple aggregations over functions with multiple variables or nested multiple aggregations over multiple variables.
In this paper we generalize both answer set optimization programming [Saad and Brewka2011] and answer set programming [Faber et al.2010] with nested multiple aggregates to allow representing and reasoning in the presence of nested multiple aggregation over multiple variables and nested multiple aggregation over functions with multiple variables. We show the applicability of the nested multiple aggregates in answer sets to the Probabilistic Traveling Salesman Problem (PTSP), a fundamental stochastic optimization problem in Operation Research [Jaillet1988], whose objective function involving nested multiple aggregations over a function with multiple variables.
Probabilistic Traveling Salesman Problem is a priori optimization problem for which we want to find a priori a tour with minimum (expected) length through a set of points, where only points out of points () at any given instance of the problem must be visited, where the number
is chosen at random with a known probability distribution, that is based on the probability distribution of visiting each point in the set of
points. In addition, the points chosen to being visited, in a given instance of the problem, has to be visited in the same order as they appear in the a priori tour.Formally, the Probabilistic Traveling Salesman Problem is defined as follows. A Probabilistic Traveling Salesman Problem (PTSP), , is a tuple of the form , where is a graph with a set of nodes, , and a set of arcs, , connecting the nodes in , is an (complete) matrix (the distance matrix) that specifies the distance (cost), , incurred by traveling from a node (location) to a node (location) , is a probability distribution over the nodes in , where is the probability of a node must be visited. In other words, the nodes in represent the set of locations that need to be visited, arcs in represent the roads connecting the locations, the values in represent the distance traveling from location to location , and the probabilities in represent the probability that a location must be visited. The objective is to find a priori tour , a Hamiltonian circuit of , with the minimum expected length (cost). By indexing the nodes of a tour by their order of appearance, we present the tour, , as the sequence of nodes , where is the depot or the starting point from which the tour always starts and ends. It has the index and with probability , since it must be always visited. Therefore, the expected length, of a tour , denoted by , is given by:
(1) 
where are indices of nodes within a tout (not the nodes themselves) and . Given that is the set of all tours in , the objective is to find a tour in with the minimum expected length , i.e., solve the a priori optimization problem
In this paper we develop syntax and semantics for both answer set optimization programs and answer set programs to allow representing and reasoning in the presence of nested multiple aggregates over multiple variables and nested multiple aggregates over functions involving multiple variables. We show the applicability of both the answer set optimization programs with nested multiple aggregates and the answer set programs with nested multiple aggregates to the fundamental stochastic optimization Probabilistic Traveling Salesman Problem, a priori optimization problem in Operation Research [Jaillet1988]. In addition, we show that with minor modification to the probabilistic traveling salesman problems representation in answer set optimization programs with nested multiple aggregates and in answer set programs with nested multiple aggregates, a corresponding classical traveling salesman problems can be intuitively represented and solved in both frameworks. We prove that the presented answer set optimization programs with nested multiple aggregates modify and generalize the answer set optimization programs with a single aggregate over a single variable proposed in [Saad and Brewka2011] as well as a generalization of the answer set optimization programs described in [Brewka et al.2003]. In addition, we prove that the presented answer set programs with nested multiple aggregates generalize the answer set programs with a single aggregate over a single variable described in [Faber et al.2010] as well as a generalization of the original answer set programs presented in [Gelfond and Lifschitz1991].
2 Nested Aggregates Disjunctive Logic Programs
In this section we present the syntax and the answer set semantics of disjunctive logic programs (a form of answer set programming) with nested multiple aggregates, denoted by NDLP. The syntax and the answer set semantics of NDLP generalize and modifies the syntax and semantics of disjunctive logic programs with a single aggregate over a single variable, DLP
, presented in [Faber et al.2010].2.1 NDLP Programs Syntax
Let be a firstorder language with finitely many predicate symbols, function symbols, constants, and infinitely many variables. A term is a constant, a variable or a function. An atom is a predicate in , where is the Herbrand base of . The Herbrand universe of is denoted by . Nonmonotonic negation or the negation as failure is denoted by .
An expression of the form is called a symbolic set, where is a single variable or a function , where are variables or functions and is a conjunction of atoms, negation of atoms, aggregate atoms, and negation of aggregate atoms (defined below). However, a ground set is a set of pairs of the form such that is a constant and is a conjunction of ground atoms, negated ground atoms, ground aggregate atoms, and negated ground aggregate atoms (defined below). A ground set or a symbolic set is called a set term. We say is an aggregate function if is an aggregate function symbol and is a set term, where . If is an aggregate function and is a constant, a variable or a function term called guard, then we say is an aggregate atom, where .
Observe that, from the definition of aggregate functions and aggregate atoms, it can be seen that an aggregate function in an aggregate atom can be defined in terms of other aggregate atoms and hence in terms of other aggregate functions . This means multiple level of nested aggregate functions calculation is achieved by allowing aggregate functions of the aggregate atoms to be defined in terms of other aggregate atoms. This is accomplished by allowing the conjunction in the definition of the symbolic set of the aggregate function in the aggregate atom to contain other aggregate atoms as constituents. This can be illustrated by the following example.
Example 1
Assume that we want to represent the double summation
(2) 
as an aggregate function, , and assign the result to a variable called to form the aggregate atom . Assume also that the possible values of are represented by the predicate . Therefore, the double summation (2) can be represented as the aggregate atom that is defined as:
(3) 
where .
Notice that there are two instances of the aggregate function in the aggregate atom representation of the double summation (2). The outer instance of the aggregate function and the inner instance of the aggregate function . The inner instance of the aggregate function is defined inside the outer instance of the aggregate function .
Moreover, notice that the variable occurs only in the inner instance of the aggregate function . Whereas the variable occurs in both the outer and the inner instances of the aggregate function . This means that the variable is seen only by the inner aggregate function , but not seen by the outer aggregate function , and is seen by both the outer and the inner aggregate function . This implies that the occurrence of in the outer hides the occurrence of in the inner , which means that any substitution of to a constant in both the inner and the outer is made by the outer . This also implies that the scope of the variable is the inner while the scope of the variable is both the outer and the inner , i.e., the entire symbolic set of the outer sum. This motivates the following definition of local variables to aggregate functions.
Definition 1
Let be an aggregate function. A variable, , is a local variable to if and only if appears in and does not appear in any aggregate function that is outer to or in the NDLP rule that contains .
Definition (1) specifies that every aggregate function has its own set of local variables. For example, for the aggregate atom representation of the double summation described in Example (1), the variable is local variable to the outer aggregate function while the variable is local variable to the inner aggregate function .
Definition 2
A global variable is a variable that is not a local variable.
Definition 3
An NDLP program, , is a set of NDLP rules of the form
(4) 
where are atoms and are atoms or aggregate atoms.
Let be an NDLP rule of the form (4). We use and .
2.2 NDLP Programs Semantics
Definition 4
The local ground instantiation of a symbolic set is the set of all local ground pairs of the form , where is a substitution of every local variable appearing in to a constant from .
Definition 5
Let be a symbolic set. Then, the ground instantiation of is the local ground instantiation of , then followed by the local ground instantiation of every symbolic set, , appearing in , then followed by the local ground instantiation of every symbolic set, , appearing in , then etc.
Example 2
Consider the grounding of the aggregate function representation of the double summation presented in Example (1) and described by (3), where and with the following facts added.
Since the aggregate function in (3) contains two levels of nesting of the aggregate function , then the grounding is achieved in two steps. The first step is described as follows, where , , and are variables act as place holders that are replaceable by constants.
followed by the second step which is described as:
Definition 6
A ground instantiation of an NDLP rule, , is the replacement of each global variable appearing in to a constant from , then followed by the ground instantiation of every symbolic set, , appearing in .
The ground instantiation of an NDLP program, , is the set of all possible ground instantiations of every NDLP rule, , in .
Let be a set of objects. Then, we use to denote the set of all multisets over elements in . The semantics of the aggregate functions , , , , and are defined by the mappings; ; , , and , where is the set of all real numbers, is the set of all natural numbers, and is the Herbrand universe. The application of and on the empty multiset returns zero and one respectively. The application of on the empty multiset returns zero. However, the application of and, on the empty multiset is undefined. Let be a symbol that does not occur in any NDLP program.
Definition 7
An interpretation is a subset of the Herbrand base .
An atom, , is true (satisfied) with respect to an interpretation, , if belongs to ; but it is false (unsatisfied) otherwise. The negation of an atom, , is true (satisfied) with respect to if does not belong to ; but it is false (unsatisfied) otherwise. Similarly, the evaluation of an aggregate function, and hence the truth valuation of an aggregate atom, are established with respect to a given interpretation, , as described by the following definitions.
Definition 8
Let be a ground aggregate function and be an interpretation. Then, we define to be the multiset constructed from elements in , where is true in .
Definition 9
Let be a ground aggregate function and be an interpretation. Then, the evaluation of with respect to is, , the result of the application of to . if is not in the domain of .
Example 3
Let be an interpretation. Thus, the evaluation of the ground aggregate function representing the double summation in Example (2) is evaluated w.r.t. as follows in two steps. Considering only the relevant possible values of the variables , , and in Example (2), the first step is to evaluate the inner instance of the aggregate function as follows:
followed by evaluating the second instance of the aggregate function as:
Definition 10
Let be a ground aggregate atom and be an interpretation. Then, is true (satisfied) with respect to if and only if and . Furthermore, is true (satisfied) with respect to if and only if or and .
Definition 11
Let be a ground NDLP program, be a ground NDLP rule of the form (4), and be an interpretation. Then,

satisfies iff such that satisfies .

satisfies iff satisfies and satisfies .

satisfies iff satisfies whenever satisfies or does not satisfy .

satisfies iff satisfies every NDLP rule, , in .
2.3 Answer Sets
A model for an NDLP program, , is an interpretation that satisfies . A model of is minimal if and only if there does not exist a model of such that .
Definition 12
Let be a ground NDLP program, be an NDLP rule in , and be an interpretation. Let denotes that satisfies . Then, the reduct, , of w.r.t. is the ground NDLP program where
The reduct of w.r.t. excludes all rules whose body, , is not satisfied by . The satisfaction of in the definition of the reduct does not distinguish between atoms or aggregate atoms or the negation of atoms or the negation aggregate atoms. This means that if dissatisfaction of is due to unsatisfied atom or aggregate atom or unsatisfied negated atom or negated aggregate atom the consequence is the same, which is the exclusion of from the reduct of .
Definition 13
An interpretation, , for a ground NDLP program, , is an answer set for if is minimal model for .
Observe that the definitions of the reduct and the answer sets semantics for NDLP programs are generalizations of the definitions of the reduct and the answer sets semantics for a single aggregate over a variable disjunctive logic programs, DLP, described in [Faber et al.2010], and hence, generalizations of the definitions of the reduct and the answer sets semantics for the original disjunctive logic programs, DLP, presented in [Gelfond and Lifschitz1991].
2.4 Semantics Properties
In this section we study the semantics properties of NDLP and its relationship to the answer set semantics of a single variable and a single aggregate disjunctive logic programs, DLP [Faber et al.2010], and its relationship to the answer set semantics of the original disjunctive logic programs, DLP [Gelfond and Lifschitz1991].
Theorem 1
Let be an NDLP program. The answer sets of are –minimal models for .
The following theorem shows that the answer set semantics of NDLP subsumes the answer set semantics of DLP [Faber et al.2010], and consequently subsumes the original answer set semantics of the original disjunctive logic programs DLP [Gelfond and Lifschitz1991]. DLP programs are NDLP programs with a single aggregation over a single variable which, unlike NDLP programs, do not allow aggregations over function terms. DLP programs are NDLP programs without any aggregate atoms.
Theorem 2
Let be a DLP program and be an interpretation. Then, is an answer set for iff is an answer set for according to the answer set semantics of [Faber et al.2010].
Proposition 1
Let be a DLP program and be an interpretation. Then, is an answer set for iff is an answer set for according to the answer set semantics of [Gelfond and Lifschitz1991].
3 Nested Aggregates Answer Set Optimization
In this section, we introduce the syntax and semantics of the answer set optimization programs with preferences that involve nested multiple aggregates, called nested aggregates preferences, and denoted by NASO programs, that modify and generalize the syntax and semantics of the answer set optimization with aggregate preferences presented in [Saad and Brewka2011], from a single aggregate over a single variable preferences to nested multiple aggregates over multiple variables and nested multiple aggregates over functions that involve multiple variables preferences. An NASO program is a logic program under the answer set semantics whose answer sets are ranked according to preference relations represented in the program.
An NASO program, , is a union of two sets of logic rules . The first set of logic rules, , is called the generator rules that generate the answer sets that satisfy every rule in . is any set of logic rules with welldefined answer set semantics including normal, extended, and disjunctive sets of rules [Gelfond and Lifschitz1988, Gelfond and Lifschitz1991, Faber et al.2010], as well as disjunctive logic with nested multiple aggregates sets of rules presented in the first part of this paper. The second set of logic rules, , is a set of logic rules that represent the user preferences over the answer sets generated by , called the preference rules. The preference rules in are used to rank the generated answer sets from the most preferred answer set to the least preferred one. An advantage of NASO is that and are independent. This makes preference elicitation easier and the whole approach is more intuitive and easy to use in practice. We focus on the syntax and semantics of the preference rules of the NASO programs , since the syntax and semantics of is the same as syntax and semantics of any set of logic rules with answer set semantics [Gelfond and Lifschitz1991, Gelfond and Lifschitz1988, Faber et al.2010].
3.1 NASO Programs Syntax
The language of NASO programs is the same as the language NDLP programs, presented in the first part of this paper, except that in the language of NASO programs classical negation is allowed. Let be a firstorder language with finitely many predicate symbols, function symbols, constants, and infinitely many variables. A term is a constant, a variable or a function. A literal is either an atom in or the negation of (), where is the Herbrand base of and is the classical negation. The Herbrand universe of is denoted by . Nonmonotonic negation or the negation as failure is denoted by . Let be the set of all literals in , where .
An expression of the form is called a symbolic set, where is a single variable or a function , where are variables or functions terms and is a conjunction of literals, nonmonotonic negation of literals, aggregate atoms, and nonmonotonic negation of aggregate atoms (defined below). However, a ground set is a set of pairs of the form such that is a constant and is a conjunction of ground literals, nonmonotonic negation of ground literals, ground aggregate atoms, and nonmonotonic negotiation of ground aggregate atoms (defined below). A ground set or a symbolic set is called a set term. We say is an aggregate function if is an aggregate function symbol and is a set term, where . If is an aggregate function and is a constant, variable or function term called guard, then we say is an aggregate atom, where . An optimization aggregate is an expression of the form or , where is a set term and is an aggregate function symbol. Let be a set of literals, aggregate atoms, and optimization aggregates. A boolean combination over is a boolean formula over literals, aggregates atoms, and optimization aggregates in constructed by conjunction, disjunction, and nonmonotonic negation (), where nonmonotonic negation is combined only with literals and aggregate atoms.
Similar to NDLP, an aggregate function in an aggregate atom can be defined in terms of other aggregate atoms and hence in terms of other aggregate functions . This is because the conjunction in the definition of the symbolic set of the aggregate function in the aggregate atom can contain other aggregate atoms as constituents. This implies that multiple level of nested aggregate functions calculation is achieved by allowing aggregate functions of the aggregate atoms to be defined in terms of other aggregate atoms.
Let be an aggregate function. A variable, , is a local variable to if and only if appears in and does not appear in any aggregate function that is outer to or in the preference rule the contains . A global variable is a variable that is not a local variable.
Definition 14
A preference rule, , over a set of literals, aggregate atoms, and optimization aggregates, , is an expression of the form
(5) 
where are literals or aggregate atoms and are boolean combinations over .
Let be a preference rule, , and . Intuitively, a preference rule, , says that any answer set that satisfies and is preferred over answer sets that satisfy , some , but not , and any answer set that satisfies and is preferred over answer sets that satisfy , some , but neither nor , etc.
Recalling, an NASO program is a union of two sets of logic rules , where is a set of logic rules with answer set semantics, called the generator rules, and is a set of preference rules.
3.2 NASO Programs Semantics
In defining the semantics of aggregate functions and aggregate atoms for NASO programs as they syntactically defined in the previous section, we follow the same semantics of aggregate functions and aggregate atoms as they defined for NDLP programs. We use for NASO programs the same notions of local ground instantiation and ground instantiation of symbolic sets as they defined for NDLP programs. Similarly, the semantics of the aggregate functions , , , , and are defined by the same mappings as defined for NDLP programs. Let be a symbol that does not occur in any NASO program.
A ground instantiation of a preference rule, , is the replacement of each global variable appearing in to a constant from , then followed by the ground instantiation of every symbolic set, , appearing in . The ground instantiation of an NASO program, , is the set of all possible ground instantiations of every rule, , in . Let be an answer set for in an NASO program, , be a ground aggregate atom, and and is true in be the multiset constructed from elements in . Then, the evaluation of with respect to the answer set is , where if is not in the domain of .
Definition 15
Let be a ground NASO program, be an answer set for , and be a preference rule in . Then the satisfaction of a boolean combination, , appearing in , by , denoted by , is defined inductively as follows:

iff .

iff .

iff and .

iff or and .

iff , and for any answer set , and or and .

iff , and for any answer set , and or and .

iff and .

iff or .
The application of any aggregate function, , except , on a singleton , returns , i.e., . Therefore, we use and as abbreviations for the optimization aggregates and respectively, where is a singleton and is any arbitrary aggregate function except .
Definition 16
Let be a ground NASO program, be an answer set for , and be a preference rule in . Then the satisfaction of the body of by , denoted by , is defined inductively as follows:

iff .

iff .

iff and .

iff or and .

iff , , and , .
The following definition specifies the satisfaction of the preference rules.
Definition 17
Let be a ground NASO program, be an answer set for , be a preference rule in , and be in . Then, we define the following notions of satisfaction of by :

iff and .

iff and does not satisfy any of in .

iff does not satisfy .
Definition 18
Let be a ground NASO program, be two answer sets of , be a preference rule in , and be boolean combination appearing in . Then, is strictly preferred over w.r.t. , denoted by , iff one of the following holds:

and and ,
where and . 
and .
We say, and are equally preferred w.r.t. , denoted by , iff one of the following holds:

and , where .

and .
We say, is at least as preferred as w.r.t. , denoted by , iff or .
Definition (18) specifies the ranking of the answer sets according to a preference rule. The following definitions characterize the ranking of the answer sets with respect to a set of preference rules.
Definition 19 (Pareto Preference)
Let be an NASO program and be answer sets of . Then, is (Pareto) preferred over w.r.t. , denoted by , iff there exists at least one preference rule such that and for every other rule , . We say, and are equally (Pareto) preferred w.r.t. , denoted by , iff for all , .
Definition 20 (Maximal Preference)
Let be an NASO program and be answer sets of . Then, is (Maximal) preferred over w.r.t. , denoted by , iff
We say, and are equally (Maximal) preferred w.r.t. , denoted by , iff
Observe that the Maximal preference relation is more general than the Pareto preference relation, since the Maximal preference definition subsumes the Pareto preference relation. Under the Pareto preference relation, the following result shows that the syntax and semantics of NASO programs subsume the syntax and semantics of the answer set optimization programs of [Brewka et al.2003], since there is no notion of Maximal preference relation was introduced in [Brewka et al.2003]. This is assuming that the answer set optimization programs of [Brewka et al.2003] assign the lowest rank to the answer sets that do not satisfy neither the body nor the head of preference rules.
Theorem 3
Let be an NASO program without either aggregate atoms or optimization aggregates and be answer sets of . Then, is Pareto preferred over w.r.t. iff is Pareto preferred over w.r.t. according to [Brewka et al.2003].
However, the following result shows that the syntax and semantics of NASO programs subsume the syntax and semantics of a single aggregate over a single variable answer set optimization programs of [Saad and Brewka2011], under both the Pareto and the Maximal preference relations, since the notion of Maximal preference relation introduced in [Saad and Brewka2011] is a special case of the Maximal preference relation presented in this paper.
Theorem 4
Let be a single aggregate over a single variable NASO program and be answer sets of . Then, is Pareto (Maximal) preferred over w.r.t. iff is Pareto (Maximal) preferred over w.r.t. according to [Saad and Brewka2011].
4 Probabilistic Traveling Salesman Problem
In this section we show that any instance of a priori optimization probabilistic traveling salesman problem (PTSP) [Jaillet1988] can be intuitively and easily represented and solved by the framework of nested multiple aggregates answer set optimization programs. In addition, we show that with a minor modification to our representation of any instance of PTSP problem in NASO, we can intuitively solve a corresponding classical traveling salesman problem (TSP) in our framework in particular, and in answer set programming in general, since finding the optimal tour for TSPs has not been considered before in answer set programming literature. This is because the emphasis in solving TSPs in answer set programming literature was on generating the possible tours of a given TSP rather than finding the optimal tour for that TSP, which is the tour with the minimum length. The reason for that is tours of a TSP are represented in answer set programming as answer sets and answer set programming is incapable of reasoning across answer sets to find the answer set that represents the tour with the minimum length. Therefore, a different framework that is capable of reasoning across answer sets is required, this framework is NASO programs.
Observe that our representation of PTSPs and consequently of TSPs is built on top of the existing answer set programming representation of TSPs, whose aim is to find all possible tours. This makes our NASO program representation further intuitive and keeps inline with the existing body of work in answer set programming. In addition, it shows and gives insight that many optimization problems can be solved by NASO framework in the same way by similar intuitive modifications to the existing answer set programming representation of corresponding similar problems.
4.1 Probabilistic Traveling Salesman Problem in NASO
Recalling, a Probabilistic Traveling Salesman Problem (PTSP), , is a tuple of the form , where is a set of vertices, is a set of edges, is an distance matrix, where is distance from a vertex to a vertex , and is a probability distribution over vertices in , where is the probability a vertex must be visited. The aim is to find a priori a tour, , of , with the minimum expected length, where is the starting point from which the tour always starts and ends and whose probability . The expected length, , of a tour is given by formula (1).
Any Probabilistic Traveling Salesman Problem (PTSP), , is represented as an NASO program , where the generator rules in generate the answer sets the represents all the possible tours in and the preference rules in rank the answer sets that correspond to all the possible tours in from the tour with the minimum expected length to the tour with the maximum expected length. The representation proceeds as follows.

Every vertex in whose probability is in is represented in as a fact of the form
(6) In addition to the starting vertex is represented in as a fact of the form
(7) 
Every edge in is represented in as a fact of the form
(8) 
Every element in the distance matrix is represented in as a fact of the form
(9) 
The logic rules that generate all the possible tours from, , are represented in by the disjunctive logic rules:
(10) (11) (12) (13) (14) (15) 
The indexing of vertices in any given tour, , by their order of appearance in the tour is represented in by the logic rules:
(17) (18) 
The computation of the expected length of each tour and the ranking of the answer sets corresponding to the tours in from the minimum expected length tour to the maximum expected length tour is represented in by the preference rule (denoted by the preference rule ):
Observe that the logic rules (10)–(12) are exactly a typical set of logic rules that are used in answer set programming literature [Eiter et al.2000] to find Hamiltonian cycles of a given graph adapted to deal with graphs with probabilistic vertices. It can be easily seen that the nested aggregate function within the optimization aggregate in the above preference rule is exactly the representation of the expected length of a tour described by formula (1).
Theorem 5
Let be a Probabilistic Traveling Salesman Problem and be the NASO program representation of . Then, a tour, , is the optimal tour for with the minimum expected length iff an answer set, , of is the top preferred answer set w.r.t. .
4.2 Traveling Salesman Problem in NASO
In this section, we show that with a minor modification to the NASO program representation of a probabilistic traveling salesman problem, we can intuitively solve a corresponding classical traveling salesman problem (TSP). A classical Traveling Salesman Problem (TSP), , is a tuple of the form , where is a set of vertices, is a set of edges, and is an distance matrix, where is an element in that represents the distance from a vertex to a vertex . The aim is to find a tour, , of , with the minimum length, where is the starting point from which the tour always starts and ends and the length, , of a tour is calculated by
(19) 
where . A Traveling Salesman Problem (TSP), , is represented as an NASO program, , where the generator rules in generate the answer sets the represents all the possible tours in and the preference rules in rank the answer sets that correspond to all the possible tours in from the tour with the minimum length to the tour with the maximum length. The generator rules in consists of the logic rules from the logic rule (6) through the logic rule (18) after replacing in the logic rule (6) by and replacing in the logic rule (15) by . The computation of the length of each tour and the ranking of the answer sets corresponding to the tours in from the minimum length tour to the maximum length tour is represented in by the preference rule:
Theorem 6
Let be a classical Traveling Salesman Problem and be the NASO program representation of . Then, a tour, , is the optimal tour for with the minimum length iff an answer set, , of is the top preferred answer set w.r.t. .
4.3 Probabilistic Traveling Salesman Problem in NDLP
We also show that a Probabilistic Traveling Salesman Problem, , can be represented as an NDLP program, , whose answer sets corresponds to tours in . Although, NDLP programs framework is still capable of finding all possible tours in , represented as answer sets, and computing the expected length of each tour, the semantics of NDLP programs is not able to locate the answer set that corresponds to the optimal tour of , since it does not have the capability of reasoning across the answer sets. However, PTSPs can be represented and solved in NDLP programs framework in two steps. The first step is to represent a probabilistic traveling salesman problem, , by an NDLP program whose answer sets correspond to all possible tours in along with their expected length. The second step is to determine the minimum expected length optimal tour,