Introduction
Answer Set Programming (ASP) is a declarative paradigm for knowledge representation and reasoning that has been applied to many crucial tasks [39 , 41 ] , such as resource placement (Azzolini et al. 2025), product configuration [15 ] , software dependency resolution [42 ] , explainable artificial intelligence [47 ] , scheduling in health-related domains [32 , 33 , 31 , 20 ] , shift design [1 ] , mass spectrum analysis [50 ] , among others.
Despite its widespread success, standard ASP does not natively support probabilistic reasoning, which is often essential for modeling uncertainty in real-world scenarios [29 , 24 ] . To account for this, Probabilistic ASP (PASP) extends ASP with the support of primitives that represent uncertain data, either in the form of weights [51 ] or probabilities [24 , 14 , 59 ] . More in detail, we adopt the PASP framework, which extends ASP with probabilistic facts [29 ] , i.e., facts with an associated probability, and adopt the credal semantics (CS) [53 ] . Among the key tasks of PASP, are inference , and most probable explanation (MPE). Inference consists of computing the probability of a ground atom (the query ). Under the credal semantics (CS), each possible combination of probabilistic facts defines a selection, and each selection induces a world represented as an answer set program, thereby determining the probability of that world. The probability of a query is, then, characterized by a lower and an upper bound, depending on whether the query holds in at least one or in all answer sets of the considered worlds. On the other hand, MPE requires identifying the selection with maximum probability such that the induced world bravely or cautiously entails a given atom (often referred to as evidence).
These tasks have been extensively studied in the literature, typically in the setting of plain ASP programs, i.e., without optimization constructs. However, many real-world applications involve optimality criteria over solutions [19 , 39 ] , which are not naturally captured by existing probabilistic ASP frameworks.
We address this gap by introducing optimal PASP, enabling probabilistic reasoning over ASP programs with weak constraints [18 ] , extended with probabilistic facts. Weak constraints are the standard ASP construct used to represent desiderata (i.e., optimization criteria) over answer sets. In particular, they select those answer sets that minimize violations, referred to as optimal answer sets. Building on standard PASP semantics and the established semantics of weak constraints, we obtain a natural extension in which the probabilistic reasoning tasks are computed by considering only optimal answer sets.
In the paper, we define formally the semantics of PASP programs with weak constraints, study the computational complexity of the inference and most probable explanation tasks, demonstrate its modeling capabilities in encoding real-world–inspired problems, and propose practical implementations based on Algebraic Model Counting [49 ] and Answer Set Programming with Quantifiers [6 ] . We also report on the results of an empirical evaluation of the proposed approach conducted on three interesting problems that confirm the applicability of our framework. This paper extends the work presented in [13 ] by refining the computational complexity proofs and providing practical implementations.
The paper is structured as follows: after introducing the required background (Section 2), we precisely define the syntax and semantics of our proposal (Section 3), illustrate its modeling capabilities with three real-world examples (Section 4), provide a computational complexity study of the inference and MPE tasks (Section 5), and propose (Section 6 and Section 7) practical implementations to solve them. Before concluding the paper (Section 9), we provide a broad overview of related work (Section 8).
Background
In this section, we recall the background involving Answer Set Programming, Probabilistic Answer Set Programming, Answer Set Programming with quantifiers, and Algebraic Model Counting.
Answer Set Programming
In ASP a variable is a string starting with an uppercase letter, while a constant is a number or a string starting with a lowercase letter. In ASP a term is either a variable or a constant. A standard atom is an expression of the form p ( t 1 , … , t n ) p(t_1,\ldots,t_n) p ( t 1 , … , t n ) , where p p p is predicate of arity (i.e., number of arguments) n n n and t 1 , … , t n t_1,\ldots,t_n t 1 , … , t n are terms. A standard literal is either a standard atom a a a or its negation n o t a \mathit{not}\ a not a , where n o t \mathit{not} not denotes negation as failure . A standard literal is ground if it contains no variables. Let l l l be a standard literal then l ˉ \bar{l} l ˉ denote the complement of l l l that is l ˉ = a \bar{l}=a l ˉ = a if l = n o t a l=\mathit{not}\ a l = not a ; otherwise l ˉ = n o t a \bar{l}=\mathit{not}\ a l ˉ = not a .
A symbolic set is an expression of the form V : C o n j V:\mathit{Conj} V : Conj where V V V is a list of terms and C o n j \mathit{Conj} Conj is a conjunction of standard literals. A ground set is an expression of the form v 1 : c o n j 1 ; … ; v n : c o n j n v_1:\mathit{conj}_1;\ldots;v_n:\mathit{conj}_n v 1 : conj 1 ; … ; v n : conj n where for each i ∈ { 1 , … , n } i\in\{1,\ldots,n\} i ∈ { 1 , … , n } , v i v_i v i is a list of constants and c o n j i \mathit{conj}_i conj i is a conjunction of ground standard literals. An aggregate atom is an expression of the form # f { S } ≻ T \#f\{S\}\succ T # f { S } ≻ T , where f f f is an aggregate function and we consider only two function types, count and sum , S S S is a symbolic or a ground set, ≻ ∈ { > , ≥ , < , ≤ } \succ\in\{>,\geq,<,\leq\} ≻∈ { > , ≥ , < , ≤ } is a comparison operator, and T T T is a term called guard . An aggregate atom # f { S } ≻ T \#f\{S\}\succ T # f { S } ≻ T is ground if S S S is a ground set and T T T does not contain variables.
An atom is either a standard atom or an aggregate one. A literal is either an atom a a a or its negation n o t a \mathit{not}\ a not a . A literal is said to be positive if it is an atom a a a , otherwise it is negative . Given a set of literals S S S , S + S^{+} S + and S − S^{-} S − represent the set of positive and negative literals in S S S , respectively.
A rule is an expression of the form
h 1 ; … ; h m : − l 1 , … , l n h_1;\ldots;h_m\mathrel{:\!-}l_1,\ldots,l_n h 1 ; … ; h m : − l 1 , … , l n
where n , m ≥ 0 n,m\geq0 n , m ≥ 0 , h 1 , … , h m h_1,\ldots,h_m h 1 , … , h m is a disjunction of standard atoms called head , and l 1 , … , l n l_1,\ldots,l_n l 1 , … , l n is a conjunction of literals called body . A weak constraint is an expression of the form : ∼ l 1 , … , l n [ w @ l , t ] \mathrel{:\sim}l_1,\ldots,l_n\ [w@l,t] :∼ l 1 , … , l n [ w @ l , t ] , where n ≥ 1 n\geq1 n ≥ 1 , l 1 , … , l n l_1,\ldots,l_n l 1 , … , l n is a conjunction of literals called body , w w w and l l l are numbers representing the weight and the level , respectively, and t t t is a list of terms that can be also omitted. In case @l is omitted, the level is assumed to be 0.
Given an ASP expression ϵ \epsilon ϵ (i.e., atom, aggregate, rule, … \ldots … ), v a r s ( ϵ ) \mathit{vars}(\epsilon) vars ( ϵ ) denotes the set of variables appearing in ϵ \epsilon ϵ , and it is ground if v a r s ( ϵ ) = ∅ \mathit{vars}(\epsilon)=\emptyset vars ( ϵ ) = ∅ . For a rule r r r , H r H_r H r is the set of atoms that appear in the head. For a rule r r r (resp. a weak constraint w c wc w c ) we denote by B r B_r B r (resp. B w c B_{wc} B w c ) the set of literals appearing in the body. B r s B_r^s B r s (resp. B w c s B_{wc}^s B w c s ) is the set of standard literals in B r B_r B r (resp. B w c B_{wc} B w c ) and B r a B_r^a B r a (resp. B w c a B_{wc}^a B w c a ) is the set of aggregate literals in B r B_r B r (resp. B w c B_{wc} B w c ).
A rule r r r is said to be a fact if B r = ∅ B_r = \emptyset B r = ∅ , a constraint if H r = ∅ H_r = \emptyset H r = ∅ , or normal if ∣ H r ∣ = 1 \lvert H_r\rvert= 1 ∣ H r ∣ = 1 .
For a rule r r r (resp. a weak constraint w c wc w c ), global variables are variables that appear in B r s B_r^s B r s (resp. B w c s B_{wc}^s B w c s ). Let l l l be an aggregate literal of the form # f { V : C o n j } ≻ T \#f\{V : Conj\} \succ T # f { V : C o nj } ≻ T appearing in the body of some rule or weak constraint. Then, l l l is said to be safe if each variable in C o n j Conj C o nj appears in some positive literal in C o n j Conj C o nj , vars ( V ) ⊆ vars ( C o n j ) \operatorname{vars}(V) \subseteq\operatorname{vars}(Conj) vars ( V ) ⊆ vars ( C o nj ) , and each variable in T T T is global.
A rule r r r is safe if vars ( H r ∪ B r s ) ⊆ vars ( ( B r s ) + ) \operatorname{vars}(H_r \cup B_r^s) \subseteq\operatorname{vars}((B_r^s)^+) vars ( H r ∪ B r s ) ⊆ vars (( B r s ) + ) , and for each l ∈ B r a l \in B_r^a l ∈ B r a , l l l is safe. The definition of safety extends also to weak constraints. A weak constraint w c wc w c of the form : ∼ l 1 , … , l n [ w @ l , t ] :\sim l_1,\ldots,l_n [w@l,t] :∼ l 1 , … , l n [ w @ l , t ] is safe if vars ( B w c s ) ⊆ vars ( ( B w c s ) + ) \operatorname{vars}(B_{wc}^s) \subseteq\operatorname{vars}((B_{wc}^s)^+) vars ( B w c s ) ⊆ vars (( B w c s ) + ) , for each l ∈ B w c a l \in B_{wc}^a l ∈ B w c a , l l l is safe, and variables appearing in w , l , t w,l,t w , l , t appear also in ( B w c s ) + (B_{wc}^s)^+ ( B w c s ) + .
An answer set program is a finite set of rules and weak constraints. For a program T \mathcal{T} T we denote by R ( T ) R(\mathcal{T}) R ( T ) and W ( T ) W(\mathcal{T}) W ( T ) the set of rules and weak constraints of T \mathcal{T} T , respectively. A program T \mathcal{T} T is said to be plain if W ( T ) = ∅ W(\mathcal{T}) = \emptyset W ( T ) = ∅ ; whereas T \mathcal{T} T is said to be normal if each rule in T \mathcal{T} T is normal. In the following, we consider only safe programs, i.e., programs containing only safe rules and safe weak constraints.
Given an ASP T \mathcal{T} T , we denote by U T U_{\mathcal{T}} U T the set of constants appearing in T \mathcal{T} T called Herbrand Universe , and by B T B_{\mathcal{T}} B T the set of ground standard atoms that can be obtained by predicates in T \mathcal{T} T and constants in U T U_{\mathcal{T}} U T , called Herbrand Base .
A variable substitution θ : X ↦ U T \theta: X \mapsto U_{\mathcal{T}} θ : X ↦ U T is a total function that maps variables from the set X X X to constants in U T U_{\mathcal{T}} U T . Given an ASP expression ϵ \epsilon ϵ (i.e., atom, literal, rule, … \ldots … ), θ ( ϵ ) \theta(\epsilon) θ ( ϵ ) denotes the expression obtained from ϵ \epsilon ϵ by substituting each occurrence of variables in V V V with the constant they are mapped to. Given a symbolic set S S S of the form V : C o n j V : Conj V : C o nj , then g r o u n d ( S ) ground(S) g r o u n d ( S ) denotes the ground set made of pairs θ ( V ) : θ ( C o n j ) \theta(V) : \theta(Conj) θ ( V ) : θ ( C o nj ) , where θ : vars ( C o n j ) ↦ U T \theta: \operatorname{vars}(Conj) \mapsto U_{\mathcal{T}} θ : vars ( C o nj ) ↦ U T is a possible variable substitution.
Let r ∈ T r \in\mathcal{T} r ∈ T be a rule of the form h 1 ; … ; h m : − l 1 , … , l n h^1;\ldots;h^m :- l^1,\ldots,l^n h 1 ; … ; h m : − l 1 , … , l n . An instantiation of r r r is a rule of the form h 1 ; … ; h m : − l 1 , … , l n h_1;\ldots;h_m :- l_1,\ldots,l_n h 1 ; … ; h m : − l 1 , … , l n where θ : vars ( ( B r s ) + ) ↦ U T \theta: \operatorname{vars}((B_r^s)^+) \mapsto U_{\mathcal{T}} θ : vars (( B r s ) + ) ↦ U T , for each i ∈ { 1 , … , m } i \in\{1,\ldots,m\} i ∈ { 1 , … , m } , h i = θ ( h i ) h_i = \theta(h^i) h i = θ ( h i ) , and for each j ∈ { 1 , … , n } j \in\{1,\ldots,n\} j ∈ { 1 , … , n } if l j ∈ B r s l^j \in B_r^s l j ∈ B r s , then l j = θ ( l j ) l_j = \theta(l^j) l j = θ ( l j ) , otherwise l j l_j l j is of the form # f { ground ( θ ( V : C o n j ) ) } ≻ θ ( T ) \#f\{\operatorname{ground}(\theta(V : Conj))\} \succ\theta(T) # f { ground ( θ ( V : C o nj ))} ≻ θ ( T ) . We denote by g r o u n d ( r ) ground(r) g r o u n d ( r ) the set of all possible ground instantiations of r r r . Let w c ∈ T wc \in\mathcal{T} w c ∈ T be a weak constraint of the form : ∼ l 1 , … , l n [ W @ L , T ] :\sim l^1,\ldots,l^n [W@L,T] :∼ l 1 , … , l n [ W @ L , T ] . An instantiation of w c wc w c is a weak constraint of the form : ∼ l 1 , … , l n [ w @ l , t ] :\sim l_1,\ldots,l_n[w@l,t] :∼ l 1 , … , l n [ w @ l , t ] where θ : vars ( ( B w c s ) + ) ↦ U T \theta: \operatorname{vars}((B_{wc}^s)^+) \mapsto U_{\mathcal{T}} θ : vars (( B w c s ) + ) ↦ U T , for each i ∈ { 1 , … , n } i \in\{1,\ldots,n\} i ∈ { 1 , … , n } if L i ∈ B w c s L_i \in B_{wc}^s L i ∈ B w c s then l i = θ ( L i ) l_i = \theta(L_i) l i = θ ( L i ) , otherwise l i l_i l i is of the form # f { ground ( θ ( V : C o n j ) ) } ≻ θ ( T ) \#f\{\operatorname{ground}(\theta(V : Conj))\} \succ\theta(T) # f { ground ( θ ( V : C o nj ))} ≻ θ ( T ) , w = θ ( W ) w = \theta(W) w = θ ( W ) , l = θ ( L ) l = \theta(L) l = θ ( L ) , and t = θ ( T ) t = \theta(T) t = θ ( T ) . For an ASP T \mathcal{T} T , g r o u n d ( T ) ground(\mathcal{T}) g r o u n d ( T ) denotes the union of all possible ground instantiations for each rule and weak constraint in T \mathcal{T} T .
Example 1
Let T \mathcal{T} T be the following program:
c(1,2). c(2,1). d(1). d(2).
a(X,Y):- d(X), d(Y).
b(X):- c(X,Y), #count{Z:a(X,Z)} > Y.
:~ b(X). [X@1]
The first line contains 4 facts, the second line contains a normal rule, the third line also represents a normal rule but with an aggregate in the body, while the last rule contains a weak constraint. Then, g r o u n d ( T ) ground(\mathcal{T}) g r o u n d ( T ) denotes the following ground program
c(1,2). c(2,1). d(1). d(2).
a(1,1):- d(1),d(1).
a(1,2):- d(1),d(2).
a(2,1):- d(2),d(1).
a(2,2):- d(2),d(2).
b(1):- c(1,2), #count{1:a(1,1); 2:a(1,2)} > 2.
b(2):- c(2,1), #count{2:a(2,1); 2:a(2,2)} > 1.
:∼ b(1). [1@1]
:∼ b(2). [2@1]
The dependency graph of T \mathcal{T} T , denoted by G T G_{\mathcal{T}} G T , is a directed labeled graph whose nodes are atoms appearing in ground ( T ) \operatorname{ground}(\mathcal{T}) ground ( T ) and there exists a positive (resp. negative) edge ( u , v , + ) (u,v,+) ( u , v , + ) (resp. ( u , v , − ) (u,v,-) ( u , v , − ) ) if there exists a rule r ∈ ground ( T ) r \in\operatorname{ground}(\mathcal{T}) r ∈ ground ( T ) such that v v v appears in the head of r r r and for u u u at least one of the following conditions holds: (i) u u u appears in B r s B_{r}^{s} B r s (resp. not u \operatorname{not}\ u not u appears in B r s B_{r}^{s} B r s ); (ii) B r a B_{r}^{a} B r a contains an aggregate of the form # f { V : C o n j } ≻ T \#f\{V : Conj\} \succ T # f { V : C o nj } ≻ T such that u u u appears in C o n j Conj C o nj (resp. not u \operatorname{not}\ u not u appears in C o n j Conj C o nj ). T \mathcal{T} T is said to be stratified if G T G_{\mathcal{T}} G T contains no loops involving negative edges; head-cycle-free (HCF) if for each r ∈ ground ( T ) r \in\operatorname{ground}(\mathcal{T}) r ∈ ground ( T ) and each pair of atoms u , v ∈ H r u,v \in H_{r} u , v ∈ H r there are no positive loops in G T G_{\mathcal{T}} G T involving both u u u and v v v .
An interpretation I ⊆ B T I \subseteq B_{\mathcal{T}} I ⊆ B T is a set of ground standard atoms. A positive (resp. negative) ground standard literal l = a l = a l = a (resp. l = not a l = \operatorname{not}\ a l = not a ) is true w.r.t. I I I , denoted by I ⊨ l I \models l I ⊨ l , if a ∈ I a \in I a ∈ I (resp. a ∉ I a \notin I a ∈ / I ); otherwise, l l l is false w.r.t. I I I , denoted by I ⊭ l I \not\models l I ⊨ l .
Let S S S be a ground set of the form v 1 : c o n j 1 ; … ; v n : c o n j n v_{1}:conj_{1};\ldots;v_{n}:conj_{n} v 1 : co n j 1 ; … ; v n : co n j n , then E v a l ( S , I ) = { v i ∣ 1 ≤ i ≤ n , I ⊨ c o n j i } Eval(S,I)=\{v_{i}\mid1 \le i \le n, I \models conj_{i}\} E v a l ( S , I ) = { v i ∣ 1 ≤ i ≤ n , I ⊨ co n j i } . Let l l l be a ground aggregate literal of the form # f { S } ≻ t \#f\{S\} \succ t # f { S } ≻ t , then I ⊨ l I \models l I ⊨ l iff ∑ v i ∈ E v a l ( S , I ) v i 0 ≻ t \sum_{v_{i}\in Eval(S,I)}v_{i}^{0}\succ t ∑ v i ∈ E v a l ( S , I ) v i 0 ≻ t holds, with v i 0 = v i [ 0 ] v_{i}^{0}=v_{i}[0] v i 0 = v i [ 0 ] if f = s u m f=sum f = s u m , otherwise, v i 0 = 1 v_{i}^{0}=1 v i 0 = 1 . A disjunction of ground standard literals l 1 ; … ; l n l_{1};\ldots;l_{n} l 1 ; … ; l n is true w.r.t. I I I , denoted by I ⊨ l 1 ; … ; l n I \models l_{1};\ldots;l_{n} I ⊨ l 1 ; … ; l n , if I ⊨ l i I \models l_{i} I ⊨ l i , for some i ∈ { 1 , … , n } i \in\{1,\ldots,n\} i ∈ { 1 , … , n } . A conjunction of ground standard literals l 1 , … , l n l_{1},\ldots,l_{n} l 1 , … , l n is true w.r.t. I I I , denoted by I ⊨ l 1 , … , l n I \models l_{1},\ldots,l_{n} I ⊨ l 1 , … , l n , if I ⊨ l i I \models l_{i} I ⊨ l i , for each i ∈ { 1 , … , n } i \in\{1,\ldots,n\} i ∈ { 1 , … , n } . Let r ∈ ground ( T ) r \in\operatorname{ground}(\mathcal{T}) r ∈ ground ( T ) be a rule, then r r r is satisfied w.r.t. I I I if B r B_{r} B r is false w.r.t. I I I or H r H_{r} H r is true w.r.t. I I I . An interpretation I I I is a model of T \mathcal{T} T if I I I satisfies each rule in ground ( T ) \operatorname{ground}(\mathcal{T}) ground ( T ) .
Let T \mathcal{T} T be a program and I I I be an interpretation, then T I \mathcal{T}^{I} T I denotes the FLP-reduct [40 ] , that is, the program obtained from T \mathcal{T} T by removing each rule having a false body w.r.t. I I I . A model I I I is an answer set of T \mathcal{T} T if I I I a ⊂ \subset ⊂ -minimal model of T I \mathcal{T}^{I} T I (i.e., there is no I ′ ⊂ I I^{\prime} \subset I I ′ ⊂ I such that I ′ I^{\prime} I ′ is a model of T I \mathcal{T}^{I} T I ). For an ASP T \mathcal{T} T we denote with A S ( T ) AS(\mathcal{T}) A S ( T ) the set of its answer sets.
For M ∈ A S ( T ) M \in AS(\mathcal{T}) M ∈ A S ( T ) , weak constraints in ground ( T ) \operatorname{ground}(\mathcal{T}) ground ( T ) define the cost of M M M . More precisely, the set of weak constraint violations is defined as w s ( T , M ) = { w , l , t ∣ : ∼ l 1 , … , l n [ w @ l , t ] ∈ T , M ⊨ l 1 , … , l n } ws(\mathcal{T},M)=\{w,l,t\mid:\sim l_{1},\ldots,l_{n}[w@l,t]\in\mathcal{T}, M \models l_{1},\ldots,l_{n}\} w s ( T , M ) = { w , l , t ∣:∼ l 1 , … , l n [ w @ l , t ] ∈ T , M ⊨ l 1 , … , l n } . Then, for each level l l l , the cost of M M M at level l l l is defined as C ( M , T , l ) = ∑ w , l , t ∈ w s ( T , M ) w C(M,\mathcal{T},l)=\sum_{w,l,t\in ws(\mathcal{T},M)}w C ( M , T , l ) = ∑ w , l , t ∈ w s ( T , M ) w . Let M 1 , M 2 ∈ A S ( T ) M_{1},M_{2}\in AS(\mathcal{T}) M 1 , M 2 ∈ A S ( T ) , then M 1 M_{1} M 1 is dominated by M 2 M_{2} M 2 if there exists some level l l l such that C ( T , M 1 , l ) > C ( T , M 2 , l ) C(\mathcal{T},M_{1},l)>C(\mathcal{T},M_{2},l) C ( T , M 1 , l ) > C ( T , M 2 , l ) , and for each l ′ > l l'>l l ′ > l , C ( T , M 1 , l ′ ) = C ( T , M 2 , l ′ ) C(\mathcal{T},M_{1},l')=C(\mathcal{T},M_{2},l') C ( T , M 1 , l ′ ) = C ( T , M 2 , l ′ ) . An answer set M M M is also an optimal answer set if, for each M ′ ∈ A S ( T ) M'\in AS(\mathcal{T}) M ′ ∈ A S ( T ) , M M M is not dominated by M ′ M' M ′ . We denote by A S ∗ ( T ) AS^{*}(\mathcal{T}) A S ∗ ( T ) the set of optimal answer sets of T \mathcal{T} T . In what follows, we consider ground head-cycle-free programs containing only stratified aggregates [4 ] . Note that stratified aggregates do not introduce any additional source of complexity [4 ] , but they are instrumental in providing natural and intuitive encoding in our proofs.
Probabilistic Answer Set Programming
Probabilistic facts De Raedt et al. [29 ] are among the simplest syntactical constructs to express uncertainty in a logic-based language. In detail, a probabilistic fact has the form π : : a \pi:: a π :: a where a a a is a ground standard atom and π ∈ [ 0 , 1 ] \pi\in[0,1] π ∈ [ 0 , 1 ] is a probability. A probabilistic answer set program (PASP, and we use the same acronym to also denote Probabilistic Answer Set Programming) P \mathcal{P} P is a tuple P = ( T , F ) \mathcal{P} = (\mathcal{T},\mathcal{F}) P = ( T , F ) where T \mathcal{T} T is a plain head-cycle-free ASP and F \mathcal{F} F is a set of probabilistic facts. With F a \mathcal{F}^{a} F a we identify the ground standard atoms associated with the probabilistic facts in F \mathcal{F} F . We impose that probabilistic facts cannot appear in heads of rules. This is a standard assumption in the literature De Raedt et al. [29 ] . A subset of F a \mathcal{F}^{a} F a identifies a selection σ \sigma σ . For a PASP with n n n probabilistic facts, there are 2 n 2^n 2 n possible selections. A selection σ \sigma σ identifies a world w σ w_{\sigma} w σ , i.e., an answer set program obtained by adding each atom in σ \sigma σ to T \mathcal{T} T . We denote with S \mathcal{S} S and Σ \Sigma Σ the set of all possible selections and worlds, respectively.
To assign a meaning to PASPs, we consider the credal semantics (CS) Cozman and Mauá [24 ] . The probability of a world w σ w_{\sigma} w σ , P ( w σ ) \mathrm{P}(w_{\sigma}) P ( w σ ) , is computed by multiplying the probabilities of the probabilistic facts according to whether they are included or not in the world w σ w_{\sigma} w σ . More precisely,
P ( w σ ) = ∏ a i ∈ w σ π i ⋅ ∏ a i ∉ w σ ( 1 − π i ) (1) \mathrm{P}(w_{\sigma}) = \prod_{a_i \in w_{\sigma}} \pi_i \cdot\prod_{a_i \notin w_{\sigma}} (1-\pi_i) \tag*{(1)} P ( w σ ) = a i ∈ w σ ∏ π i ⋅ a i ∈ / w σ ∏ ( 1 − π i ) (1)
where F = { π 1 : : a 1 , … , π n : : a n } \mathcal{F} = \{\pi_1 :: a_1, \ldots, \pi_n :: a_n\} F = { π 1 :: a 1 , … , π n :: a n } . We also use the notation P ( σ ) \mathrm{P}(\sigma) P ( σ ) for a selection σ \sigma σ and we set it to P ( w σ ) \mathrm{P}(w_{\sigma}) P ( w σ ) .
The probability of a ground atom q q q (the query) is characterized by a lower P ‾ ( q ) \underline{\mathrm{P}}(q) P ( q ) and an upper P ‾ ( q ) \overline{\mathrm{P}}(q) P ( q ) bound (also called lower and upper probability). In words, a world contributes to the the upper probability if the query is present in some answer sets while it contributes to the lower probability if the query is present in all answer sets. In formulas,
P ‾ ( q ) = ∑ w σ ∈ Σ ∣ ∀ M ∈ A S ( w σ ) , M ⊨ q P ( w σ ) , (2) \underline{\mathrm{P}}(q) = \sum_{\substack{w_{\sigma} \in\Sigma\mid\forall M \in AS(w_{\sigma}),\ M \models q}} \mathrm{P}(w_{\sigma}), \tag*{(2)} P ( q ) = w σ ∈ Σ ∣ ∀ M ∈ A S ( w σ ) , M ⊨ q ∑ P ( w σ ) , (2)
P ‾ ( q ) = ∑ w σ ∈ Σ ∣ ∃ M ∈ A S ( w σ ) , M ⊨ q P ( w σ ) . (3) \overline{\mathrm{P}}(q) = \sum_{\substack{w_{\sigma} \in\Sigma\mid\exists M \in AS(w_{\sigma}),\ M \models q}} \mathrm{P}(w_{\sigma}). \tag*{(3)} P ( q ) = w σ ∈ Σ ∣ ∃ M ∈ A S ( w σ ) , M ⊨ q ∑ P ( w σ ) . (3)
Computing the probability of a query is called inference.
The CS requires that every world has at least one answer set, i.e., to be coherent. This is necessary as it ensures that, for a query q q q , P ‾ ( q ) + P ‾ ( n o t q ) = 1 \underline{\mathrm{P}}(q) + \overline{\mathrm{P}}(\mathop{\mathrm{not}\ q}) = 1 P ( q ) + P ( not q ) = 1 . If some worlds are incoherent, then there is a loss of probability mass, and the above relation does not hold. In this paper, we always assume coherent PASP, unless otherwise stated.
The most probable explanation Azzolini et al. [12 ] task in PASP requires finding the selection which generates the world associated with the highest probability (computed with Equation 1) where a ground literal e e e (the evidence) holds cautiously (i.e., in every answer set) or bravely (i.e., in at least one answer set). These two are defined as M P E ‾ ( e ) \underline{\mathrm{MPE}}(e) MPE ( e ) and M P E ‾ ( e ) \overline{\mathrm{MPE}}(e) MPE ( e ) , respectively, and are computed as
M P E ‾ ( e ) = arg max σ ∈ S ∣ ∀ M ∈ A S ( w σ ) , M ⊨ e P ( w σ ) , (4) \underline{\mathrm{MPE}}(e) = \underset{\sigma\in\mathcal{S} \mid\forall M \in AS(w_{\sigma}),\ M \models e}{\operatorname{arg\,max}}\ \mathrm{P}(w_{\sigma}), \tag*{(4)} MPE ( e ) = σ ∈ S ∣ ∀ M ∈ A S ( w σ ) , M ⊨ e arg max P ( w σ ) , (4)
M P E ‾ ( e ) = arg max σ ∈ S ∣ ∃ M ∈ A S ( w σ ) , M ⊨ e P ( w σ ) . (5) \overline{\mathrm{MPE}}(e) = \underset{\sigma\in\mathcal{S} \mid\exists M \in AS(w_{\sigma}),\ M \models e}{\operatorname{arg\,max}}\ \mathrm{P}(w_{\sigma}). \tag*{(5)} MPE ( e ) = σ ∈ S ∣ ∃ M ∈ A S ( w σ ) , M ⊨ e arg max P ( w σ ) . (5)
We denote with P ( M P E ( e ) ‾ ) \mathrm{P}(\overline{\mathrm{MPE}(e)}) P ( MPE ( e ) ) (resp. P ( M P E ( e ) ‾ ) \mathrm{P}(\overline{\mathrm{MPE}(e)}) P ( MPE ( e ) ) ) the probability of the selection associated with M P E ( e ) \mathrm{MPE}(e) MPE ( e ) (resp. M P E ( e ) ‾ \overline{\mathrm{MPE}(e)} MPE ( e ) ).
Example 2
Consider the following simple PASP, which will be our running example.
0.2::a.
0.3::b.
q:- a.
q;nq:- b.
There are 4 worlds, whose probabilities and answer sets are listed in Table 1 . If we consider the query q q q , it is present in every answer set of w 2 w_2 w 2 and w 3 w_3 w 3 , so these worlds contribute to the lower probability. For the upper probability, w 1 w_1 w 1 contributes as well. Overall, P ‾ ( q ) = 0.2 \underline{\mathrm{P}}(q) = 0.2 P ( q ) = 0.2 and P ‾ ( q ) = 0.44 \overline{\mathrm{P}}(q) = 0.44 P ( q ) = 0.44 . Similarly, M P E ( q ) = { a } \mathrm{MPE}(q) = \{a\} MPE ( q ) = { a } and M P E ‾ ( q ) = { b } \overline{\mathrm{MPE}}(q) = \{b\} MPE ( q ) = { b } .
Table 1. Selections, probabilities, and answer sets for Example 2.
Answer Set Programming with Quantifiers
We now introduce Quantified Answer Set Programming (ASP(Q)) which will be instrumental in our complexity studies. ASP(Q) extends ASP by introducing the concept of quantifiers over (optimal) answer sets of ASP programs [6 , 54 ] . With quantifiers, we can model problems throughout the entire PH as naturally as we can model NP problems in ASP. An ASP(Q) program Π \Pi Π is of the form:
□ 1 s t T 1 … □ n s t T n : C , (6) \Box^{\mathrm{st}}_1\mathcal{T}_1\ldots\Box^{\mathrm{st}}_n\mathcal{T}_n:C, \tag*{(6)} □ 1 st T 1 … □ n st T n : C , (6)
where, for each i ∈ { 1 , … , n } i \in\{1,\ldots,n\} i ∈ { 1 , … , n } , T i \mathcal{T}_i T i is a normal ASP program, □ i ∈ { ∀ s t , ∃ s t } \Box_i \in\{\forall^{\mathrm{st}},\exists^{\mathrm{st}}\} □ i ∈ { ∀ st , ∃ st } , and C C C is a normal program both plain and stratified. An ASP(Q) program is said to be existential if □ 1 = ∃ \Box_1 = \exists □ 1 = ∃ , otherwise it is universal . Moreover, we say that an ASP(Q) program is uniform if □ i = □ i + 1 \Box_i = \Box_{i+1} □ i = □ i + 1 , for each i ∈ { 1 , … , n − 1 } i \in\{1,\ldots,n-1\} i ∈ { 1 , … , n − 1 } . Let Π \Pi Π be an ASP(Q) of the form (6), T \mathcal{T} T be a program, and M ∈ A S ( T ) M \in AS(\mathcal{T}) M ∈ A S ( T ) . Then, f i x T ( M ) \mathit{fix}_{\mathcal{T}}(M) fix T ( M ) denotes the set of facts and constraints { a ∣ a ∈ M } ∪ { : − a ∣ a ∈ B T ∖ M } \{a \mid a \in M\} \cup\{:-a \mid a \in B_{\mathcal{T}}\setminus M\} { a ∣ a ∈ M } ∪ { : − a ∣ a ∈ B T ∖ M } and Π T , M \Pi_{\mathcal{T},M} Π T , M the ASP(Q) of the form □ 1 s t T 1 ∪ f i x T ( M ) … □ n s t T n : C \Box^{\mathrm{st}}_1\mathcal{T}_1\cup\mathit{fix}_{\mathcal{T}}(M)\ldots\Box^{\mathrm{st}}_n\mathcal{T}_n:C □ 1 st T 1 ∪ fix T ( M ) … □ n st T n : C . The ASP(Q) semantics can now be defined inductively:
∃ s t T : C \exists^{\mathrm{st}}\mathcal{T}:C ∃ st T : C is coherent iff there exists M ∈ A S ∗ ( T ) M \in AS^*(\mathcal{T}) M ∈ A S ∗ ( T ) such that C ∪ f i x T ( M ) C \cup\mathit{fix}_{\mathcal{T}}(M) C ∪ fix T ( M ) is coherent.
∀ s t T : C \forall^{\mathrm{st}}\mathcal{T}:C ∀ st T : C is coherent iff for each M ∈ A S ∗ ( T ) M \in AS^*(\mathcal{T}) M ∈ A S ∗ ( T ) , C ∪ f i x T ( M ) C\cup\mathit{fix}_{\mathcal{T}}(M) C ∪ fix T ( M ) is coherent.
∃ s t T Π \exists^{\mathrm{st}}\mathcal{T}\Pi ∃ st T Π is coherent iff there exists M ∈ A S ∗ ( T ) M \in AS^*(\mathcal{T}) M ∈ A S ∗ ( T ) such that Π T , M \Pi_{\mathcal{T},M} Π T , M is coherent.
∀ s t T Π \forall^{\mathrm{st}}\mathcal{T}\Pi ∀ st T Π is coherent iff for each M ∈ A S ∗ ( T ) M \in AS^*(\mathcal{T}) M ∈ A S ∗ ( T ) , Π T , M \Pi_{\mathcal{T},M} Π T , M is coherent.
For an existential ASP(Q) program Π \Pi Π of the form (6), M ∈ A S ∗ ( T 1 ) M \in AS^*(\mathcal{T}_1) M ∈ A S ∗ ( T 1 ) is a quantified answer set of Π \Pi Π iff □ 2 s t T 2 ∪ f i x T 1 ( M 1 ) … □ n s t T n : C \Box^{\mathrm{st}}_2\mathcal{T}_2\cup\mathit{fix}_{\mathcal{T}_1}(M_1)\ldots\Box^{\mathrm{st}}_n\mathcal{T}_n:C □ 2 st T 2 ∪ fix T 1 ( M 1 ) … □ n st T n : C is coherent. Q A S ( Π ) QAS(\Pi) Q A S ( Π ) denotes the quantified answer sets of Π \Pi Π .
Algebraic Model Counting
Algebraic Model Counting (AMC) (Kimmig et al. [49 ] ) is a generic framework that generalizes the well-known Weighted Model Counting (WMC) tasks to commutative semirings (Gondran and Minoux [44 ] ).
Definition 1 (Commutative Semiring) A commutative semiring is a tuple R = ( D , ⊕ , ⊗ , 0 , 1 ) \mathcal{R} = (D, \oplus, \otimes, 0, 1) R = ( D , ⊕ , ⊗ , 0 , 1 ) where D D D is the domain of interest (for example, N \mathbb{N} N , R \mathbb{R} R , etc), ⊕ \oplus ⊕ and ⊗ \otimes ⊗ are associative and commutative operations, and 0 and 1 are the neutral elements for ⊕ \oplus ⊕ and ⊗ \otimes ⊗ , respectively.
Definition 2 (Algebraic Model Counting) Given a propositional theory T T T over variables V V V , a commutative semiring R R R , and a weight function w : l i t ( V ) ↦ A w : lit(V) \mapsto A w : l i t ( V ) ↦ A , where l i t ( V ) lit(V) l i t ( V ) is the set of propositional literals build with the variables in V V V , A M C ( T ) AMC(T) A M C ( T ) is defined as
A M C ( T ) = ⨁ M ∈ m o d e l s ( T ) ⨂ l ∈ M w ( l ) AMC(T) = \bigoplus_{M \in models(T)} \bigotimes_{l \in M} w(l) A M C ( T ) = M ∈ m o d e l s ( T ) ⨁ l ∈ M ⨂ w ( l ) where m o d e l s ( T ) models(T) m o d e l s ( T ) is the set of models of T T T .
By selecting an appropriate semiring, it is possible to encode many different tasks (see [49 ] for a list of examples).
Despite the generality of AMC, some tasks in Statistical Relational Artificial Intelligence (De Raedt et al. [28 ] ) can be better formalized within the Second-Level Algebraic Model Counting (2AMC) framework (Kiesel et al. [48 ] ). Intuitively, 2AMC extends AMC by nesting an AMC task inside another AMC task.
Definition 3 (Second-Level Algebraic Model Counting) Given a propositional theory T T T whose variables are partitioned into ( V i , V o ) (V_i, V_o) ( V i , V o ) , two commutative semirings R i = ( D i , ⊕ i , ⊗ i , n ⊕ i , n ⊗ i ) R_i = (D^i, \oplus^i, \otimes^i, n^i_{\oplus}, n^i_{\otimes}) R i = ( D i , ⊕ i , ⊗ i , n ⊕ i , n ⊗ i ) and R o = ( D o , ⊕ o , ⊗ o , n ⊕ o , n ⊗ o ) R_o = (D^o, \oplus^o, \otimes^o, n^o_{\oplus}, n^o_{\otimes}) R o = ( D o , ⊕ o , ⊗ o , n ⊕ o , n ⊗ o ) , two weight functions, w i w_i w i and w o w_o w o , and a transformation function f i o f_{io} f i o mapping the values of R i R_i R i to R o R_o R o , let T = ( T , V i , V o , R i , R o , w i , w o , f i o ) \mathcal{T} = (T, V_i, V_o, R_i, R_o, w_i, w_o, f_{io}) T = ( T , V i , V o , R i , R o , w i , w o , f i o ) , 2AMC on T \mathcal{T} T is defined as:
2 A M C ( T ) = ⨁ I o ∈ μ ( V o ) o ⨂ a ∈ I o o w o ( a ) ⊗ o f i o ( ⨁ I i ∈ φ ( T ∣ I o ) i ⨂ b ∈ I i i w i ( b ) ) (7) 2AMC(\mathcal{T}) = \bigoplus_{I_o \in\mu(V_o)}^{o} \bigotimes_{a \in I_o}^{o} w_o(a) \otimes^{o} f_{io}\left(\bigoplus_{I_i \in\varphi(T \mid I_o)}^{i} \bigotimes_{b \in I_i}^{i} w_i(b)\right) \tag*{(7)} 2 A M C ( T ) = I o ∈ μ ( V o ) ⨁ o a ∈ I o ⨂ o w o ( a ) ⊗ o f i o I i ∈ φ ( T ∣ I o ) ⨁ i b ∈ I i ⨂ i w i ( b ) (7) where μ ( V o ) \mu(V_o) μ ( V o ) is the set of possible assignments to V o V_o V o and φ ( T ∣ I o ) \varphi(T \mid I_o) φ ( T ∣ I o ) the set of assignments I i I_i I i of V i V_i V i such that ( I i , I o ) (I_i, I_o) ( I i , I o ) satisfies T T T .
Optimal Probabilistic ASP
We now introduce the Optimal Probabilistic Answer Set Programming (optimal PASP/optPASP) framework.
Definition 4 An optimal PASP P ∼ \mathcal{P}^{\sim} P ∼ is a tuple ( T , F , W ) (\mathcal{T}, \mathcal{F}, \mathcal{W}) ( T , F , W ) , where T \mathcal{T} T is a plain head-cycle-free ASP, F \mathcal{F} F is a set of probabilistic facts, and W \mathcal{W} W is a set of weak constraints.
In other words, an optimal PASP is a PASP extended with a set of weak constraints. The set of weak constraints imposes an optimality criterion on the possible answer sets for a world. As for plain PASP (i.e., PASP without weak constraints), we require that each world has at least one (optimal) answer set. Clearly, if w σ w_{\sigma} w σ has only one answer set A A A , then A A A will also be the optimal answer set.
The probability bounds of a query q q q in an optimal PASP are computed by checking whether query is true in the optimal answer sets of the worlds: a world contributes to the upper probability if the query is present in some optimal answer sets while it contributes to the lower probability if the query is present in all optimal answer sets. This is analogous to Equations (2) and (3) which target plain PASP, the only difference is in the answer sets to check (all for plain PASP while only the optimal ones for optPASP). In formulas, given an optimal PASP P ∼ \mathcal{P}^{\sim} P ∼ , the lower (resp. upper) optimal probability P ‾ ∗ ( q ) \underline{\mathsf{P}}^{*}(q) P ∗ ( q ) (resp. P ‾ ∗ ( q ) \overline{\mathsf{P}}^{*}(q) P ∗ ( q ) ) for a query q q q are computed as
P ‾ ∗ ( q ) = ∑ w σ ∈ Σ ∣ ∀ M ∈ A S ∗ ( w σ ) , M ⊨ q P ( w σ ) , (8) \underline{\mathsf{P}}^{*}(q)=\sum_{w_{\sigma}\in\Sigma\mid\forall M\in AS^{*}(w_{\sigma}),\,M\models q} \mathrm{P}(w_{\sigma}), \tag*{(8)} P ∗ ( q ) = w σ ∈ Σ ∣ ∀ M ∈ A S ∗ ( w σ ) , M ⊨ q ∑ P ( w σ ) , (8)
and
P ‾ ∗ ( q ) = ∑ w σ ∈ Σ ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q P ( w σ ) . (9) \overline{\mathsf{P}}^{*}(q)=\sum_{w_{\sigma}\in\Sigma\mid\exists M\in AS^{*}(w_{\sigma}),\,M\models q} \mathrm{P}(w_{\sigma}). \tag*{(9)} P ∗ ( q ) = w σ ∈ Σ ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q ∑ P ( w σ ) . (9)
We now introduce the MPE task for optPASP, analogously to the definition for PASP (Equation (4) and (5) ). Given a ground literal e e e (the evidence), the lower (cautious) and upper (brave) optimal MPE states are now computed by considering only optimal answer sets. That is,
MPE ‾ ∗ ( e ) = arg max σ ∈ S ∣ ∀ M ∈ A S ∗ ( w σ ) , M ⊨ e P ( w σ ) , (10) \underline{\operatorname{MPE}}^{*}(e)=\underset{\sigma\in S\mid\forall M\in AS^{*}(w_{\sigma}),\,M\models e}{\arg\max}\ \mathrm{P}(w_{\sigma}), \tag*{(10)} MPE ∗ ( e ) = σ ∈ S ∣ ∀ M ∈ A S ∗ ( w σ ) , M ⊨ e arg max P ( w σ ) , (10)
MPE ‾ ∗ ( e ) = arg max σ ∈ S ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ e P ( w σ ) . (11) \overline{\operatorname{MPE}}^{*}(e)=\underset{\sigma\in S\mid\exists M\in AS^{*}(w_{\sigma}),\,M\models e}{\arg\max}\ \mathrm{P}(w_{\sigma}). \tag*{(11)} MPE ∗ ( e ) = σ ∈ S ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ e arg max P ( w σ ) . (11)
The next theorem relates the probability of a query computed in a plain PASP to that computed in an optimal PASP.
Theorem 1 Let T \mathcal{T} T , F \mathcal{F} F , and W \mathcal{W} W be a set of normal rules, probabilistic facts, and weak constraints, respectively, and q q q an atom (query). Let P = ( T , F ) \mathcal{P}=(\mathcal{T},\mathcal{F}) P = ( T , F ) and P ∼ = ( T , F , W ) \mathcal{P}^{\sim}=(\mathcal{T},\mathcal{F},\mathcal{W}) P ∼ = ( T , F , W ) . Then, P ‾ ( q ) ≤ P ‾ ∗ ( q ) ≤ P ‾ ∗ ( q ) ≤ P ‾ ( q ) \underline{\mathrm{P}}(q)\leq\underline{\mathrm{P}}^{*}(q)\leq\overline{\mathrm{P}}^{*}(q)\leq\overline{\mathrm{P}}(q) P ( q ) ≤ P ∗ ( q ) ≤ P ∗ ( q ) ≤ P ( q ) .
Proof The number of worlds of P \mathcal{P} P and P ∼ \mathcal{P}^{\sim} P ∼ is the same, as is the probability for each world, since the set of probabilistic facts is the same. Consider a world w w w in P \mathcal{P} P and its counterpart w ∗ w^{*} w ∗ for P ∼ \mathcal{P}^{\sim} P ∼ . Since A S ∗ ( w ∗ ) ⊆ A S ( w ) AS^{*}(w^{*})\subseteq AS(w) A S ∗ ( w ∗ ) ⊆ A S ( w ) , if the condition for the world to contribute to the lower bound is satisfied for P \mathcal{P} P , then it will be satisfied for P ∼ \mathcal{P}^{\sim} P ∼ but not vice versa (the condition for P \mathcal{P} P is stronger). Conversely, if the condition for the world to contribute to the upper bound is satisfied for P ∼ \mathcal{P}^{\sim} P ∼ , then it will be satisfied for P \mathcal{P} P but not vice versa (the condition for P ∼ \mathcal{P}^{\sim} P ∼ is stronger). □ \square □
Theorem 1 shows that the semantics of optimal PASP is credal as it is the set of all probability measures that dominate an infinitely monotone Choquet capacity ([7 , 23 ] ). As in the credal semantics for plain PASP, the distribution of the probability mass of a world over the optimal answer set is left open.
The only difference is that the set of answer sets is a subset of those for plain PASP. Moreover, the following theorems immediately hold.
Theorem 2. Let P = ( T , F ) \mathcal{P}=(\mathcal{T},\mathcal{F}) P = ( T , F ) with query q q q and P ∼ = ( T , F , W ) \mathcal{P}^{\sim}=(\mathcal{T},\mathcal{F},\mathcal{W}) P ∼ = ( T , F , W ) with W = { : ∼ q [ C ] } \mathcal{W}=\{\mathord{:}\mathord{\sim} q [C]\} W = { : ∼ q [ C ]} with C < 0 C<0 C < 0 or with W = { : ∼ q ˉ [ C ] } \mathcal{W}=\{\mathord{:}\mathord{\sim} \bar{q} [C]\} W = { : ∼ q ˉ [ C ]} with C > 0 C>0 C > 0 . Then, P ‾ ∗ ( q ) = P ‾ ∼ ( q ) = P ‾ ( q ) \underline{\mathrm{P}}^{*}(q)=\underline{\mathrm{P}}^{\sim}(q)=\underline{\mathrm{P}}(q) P ∗ ( q ) = P ∼ ( q ) = P ( q ) .
Theorem 3. Let P = ( T , F ) \mathcal{P}=(\mathcal{T},\mathcal{F}) P = ( T , F ) with query q q q and P ∼ = ( T , F , W ) \mathcal{P}^{\sim}=(\mathcal{T},\mathcal{F},\mathcal{W}) P ∼ = ( T , F , W ) with W = { : ∼ q [ C ] } \mathcal{W}=\{\mathord{:}\mathord{\sim} q [C]\} W = { : ∼ q [ C ]} with C > 0 C>0 C > 0 or with W = { : ∼ n o t q [ C ] } \mathcal{W}=\{\mathord{:}\mathord{\sim} \mathit{not}\ q [C]\} W = { : ∼ not q [ C ]} with C < 0 C<0 C < 0 . Then, P ‾ ∗ ( q ) = P ‾ ∼ ( q ) = P ‾ ( q ) \underline{\mathrm{P}}^{*}(q)=\underline{\mathrm{P}}^{\sim}(q)=\underline{\mathrm{P}}(q) P ∗ ( q ) = P ∼ ( q ) = P ( q ) .
Observation 1. The credal semantics is not defined when there is at least one incoherent world. Incoherencies are usually due to constraints (or odd cycles through negation). The possibility of using weak constraints allows us to relax “strong” constraints, making such problems coherent and interpretable under the credal semantics.
Example 3. Consider Example 2 extended with a weak constraint and a rule, thus obtaining an optPASP:
0.2::a.
0.3::b.
q:- a.
q;nq:- b.
qr:- nq.
:∼ qr.[1]
Here, the world w 1 w_1 w 1 obtained with selection { b } \{b\} { b } (see Table 1 ) will have only one optimal answer set, namely { b , q } \{b,q\} { b , q } . Here, P ‾ ∗ ( q ) = P ‾ ∗ ( q ) = 0.44 \underline{\mathrm{P}}^{*}(q)=\overline{\mathrm{P}}^{*}(q)=0.44 P ∗ ( q ) = P ∗ ( q ) = 0.44 . Then, M P E ∗ ( q ) = M P E ‾ ∗ ( q ) = { b } \mathrm{MPE}^{*}(q)=\overline{\mathrm{MPE}}^{*}(q)=\{b\} MPE ∗ ( q ) = MPE ∗ ( q ) = { b } . If we change the last rule to qr :- q, the unique optimal answer set for w 1 w_1 w 1 will be { b , n q } \{b,nq\} { b , n q } so, in this case, P ‾ ∗ ( q ) = P ‾ ∗ ( q ) = 0.2 \underline{\mathrm{P}}^{*}(q)=\overline{\mathrm{P}}^{*}(q)=0.2 P ∗ ( q ) = P ∗ ( q ) = 0.2 . Now, M P E ‾ ∗ ( q ) = M P E ‾ ∗ ( q ) = { a } \underline{\mathrm{MPE}}^{*}(q)=\overline{\mathrm{MPE}}^{*}(q)=\{a\} MPE ∗ ( q ) = MPE ∗ ( q ) = { a } . For this example, the lower and upper probability (resp. MPE states) coincide, but this does not hold in general.
Modeling Examples
In this section, we show how three real world problems can be naturally encoded within the optPASP framework.
Optimal Reviewer Assignment. The optimal reviewer assignment problem has received substantial interest in literature [17 , 46 , 30 , 5 ] , with many different variations. In brief, it consists of assigning reviewers to articles for peer review. For ease of explanation, here we consider a simplified scenario where each reviewer may accept the invitation and terminate her/his reviews within the deadline with a certain probability and in which each paper may be assigned to at least one reviewer. The probabilities may derive from historical data. For example, a particular reviewer was invited to be a member of the program committee of N N N conferences and X X X times he/she accepted the invitation and completed the reviews within the expected deadline. So, the value X / N X/N X / N can be the probability value associated to that particular reviewer. The goal is to find a set of paper assignments such that the number of papers assigned to each reviewer is roughly the same. This task can be encoded with the following P ∼ \mathcal{P}^{\sim} P ∼ , for the case of three reviewers and two papers.
0.6::reviewer(r1). 0.7::reviewer(r2). 0.8::reviewer(r3).
paper(p1). paper(p2).
willing(R,P):- reviewer(R), paper(P).
assign(R,P):- willing(R,P), not skip(R,P).
skip(R,P):- willing(R,P), not assign(R,P).
reviewed(P):- assign(R,P).
load(R,2):- assign(R,P1), assign(R,P2), P1!=P2.
load(R,1):- assign(R,P), not load(R,2).
load(R,0):- reviewer(R), not load(R,1), not load(R,2).
less_than_two :- load(R,C), C < 2.
delta(R0,R1,D):- load(R0,L0), load(R1,L1), R0 != R1, L0<=L1, D=L1-L0.
:∼ assign(R1,P), assign(R2,P), assign(R3,P), R1!=R2, R1!=R3, R2!=R3. [1@2,P]
:∼ paper(P), not reviewed(P). [1@1,P]
:∼ delta(R0,R1,D). [D@0,R0,R1]
Articles to review are identified with the predicate p a p e r / 1 paper/1 p a p er /1 while reviewers with r e v i e w e r / 1 reviewer/1 r e v i e w er /1 probabilistic facts. For simplicity, we assume that every reviewer is willing to review any article (w i l l i n g / 2 willing/2 w i l l in g /2 ) and can (a s s i g n / 2 assign/2 a ss i g n /2 ) or not (s k i p / 2 skip/2 s k i p /2 ) be assigned to a paper. The predicate (l o a d / 2 load/2 l o a d /2 ) computes the load of a reviewer, i.e., the number of papers that she/he has to review. The difference in load between each pair of reviewers is represented by d e l t a / 3 delta/3 d e l t a /3 . Two weak constraints impose optimality criteria on the solutions:
the weak constraint at the priority level 2 minimizes the number of papers assigned to more than two reviewers;
the weak constraint at the priority level 1 minimizes the number of articles not reviewed;
the weak constraint at the priority level 0 minimizes the difference in load among reviewers.
By asking l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o , we can compute the probability (bounds) that at least one reviewer is assigned with less than two papers (which, for the previous program, is [0.336, 0.788]). We can also ask other queries within this program. For instance, we can compute the probability that at least one paper received exactly one review, by adding rules of the form
one_review :- assign(r1,P), not assign(r2,P), not assign(r3,P).
one_review :- assign(r2,P), not assign(r1,P), not assign(r3,P).
one_review :- assign(r3,P), not assign(r1,P), not assign(r2,P).
and then asking the probability of one review . Overall, with our proposed formalism, it is now possible to answer probability queries involving the optimal assignment for reviewers, which were not possible with plain PASP.
Scheduling Problem under No-Show Behavior. The patient scheduling and overbooking problem under no-show behavior [58 , 21 , 2 , 31 ] describes a scenario where patients should undergo different medical exams that require different resources. As patients may not show up, the facility adopts overbooking to avoid leaving resources idle. However, this may result in patients that actually show up, but do not have the required resource assigned: in this case, they should be refunded. The following P ∼ \mathcal{P}^{\sim} P ∼ models the problem in a simplified scenario.
0.4::show(1). 0.4::show(2). 0.4::show(3).
0.4::show(4). 0.4::show(5).
res(r1,chair). res(r3,bed).
res(r2,chair). res(r4,bed).
exam(e1,chair). exam(e2,bed).
take(1,e1). take(2,e2). take(3,e1).
take(4,e2). take(5,e2).
require(P,R):- take(P,E),exam(E,R).
assign(P,R,Id) :- show(P), require(P,R), res(Id,R), not nAssign(P,R,Id).
nAssign(P,R,Id) :- show(P), require(P,R), res(Id,R), not assign(P,R,Id).
:- assign(P1,R,I), assign(P2,R,I), P1!=P2.
fulfilled(P):- show(P), assign(P,R,I).
two_not_fulfilled:- show(A),show(B), A!=B, not fulfilled(A), not fulfilled(B).
refund_cost(P,2):- show(P), not fulfilled(P).
resource_cost(R,1):- assign(P1,chair,R).
resource_cost(R,2):- assign(P1,bed,R).
:∼ refund_cost(R,C). [C@1,R]
:∼ resource_cost(R,C). [C@0,R]
The probabilistic facts of the form s h o w ( X ) show(X) s h o w ( X ) with X ∈ { 1 , … , 5 } X \in\{1, \ldots, 5\} X ∈ { 1 , … , 5 } , denote the probabilities with which the patients may or may not show up. The facts of the form e x a m ( E , R ) exam(E,R) e x am ( E , R ) state that exam E E E requires resource R R R . We assume that there are two exams, e 1 e1 e 1 and e 2 e2 e 2 , and two types of resources, chair and bed , each associated with an id (r e s ( I d , R ) res(Id,R) r es ( I d , R ) ). The facts of the form t a k e ( P , E ) take(P,E) t ak e ( P , E ) state that the patient P P P undergoes exam E E E . A resource of type R R R with id I d Id I d can be assigned (a s s i g n ( P , R , I d ) assign(P,R,Id) a ss i g n ( P , R , I d ) ), and in this case, the request has been fulfilled , or not assigned (n A s s i g n ( P , R , I d ) nAssign(P,R,Id) n A ss i g n ( P , R , I d ) ) to a patient P P P who showed up and actually required that resource. The constraint prohibits assigning a resource to two patients at the same time. The predicate r e f u n d _ c o s t ( P , R ) refund\_cost(P,R) r e f u n d _ cos t ( P , R ) states that the cost for refunding a patient P P P that is present but not fulfilled is R R R . Similarly, used resources are associated with a cost through r e s o u r c e _ c o s t / 2 resource\_cost/2 r eso u r ce _ cos t /2 . Two weak constraints impose optimality of the solutions: we want to minimize the cost of the refund (level 1) and then the cost of the used resources (level 0). Here we may be interested in computing the probability of having two patients not fulfilled, by querying t w o _ n o t _ f u l f i l l e d two\_not\_fulfilled tw o _ n o t _ f u l f i l l e d , obtaining [0.0256, 0.16].
In general, with optimal PASP we can compute probabilities of events in scenarios of optimal resource allocation.
Viral Marketing. The viral marketing problem is a well-studied problem in decision theory [60 , 34 ] (Azzolini et al. 2025). It considers a social network of people, represented by a graph. Some of them can be targeted by an ad. Friendship relations influence the shopping behavior of the people involved. The following optimal PASP, adapted from [60 ] , models the problem:
0.7::buys_from_viral(P0,P1):- person(P0), person(P1), P0 != P1.
0.2::buys_from_marketing(P):- person(P).
market(P) :- person(P), not noMarket(P).
noMarket(P) :- person(P), not market(P).
buys(P):- market(P), buys_from_marketing(P).
buys(P):- friend(P,F), buys(F), buys_from_viral(P,F).
:~ market(P). [20@1,P]
:~ buys(P). [-5@1,P]
where person/1 facts describe people in the network and friend/2 facts denote friendship relationship. A person P P P can be marketed (market (P P P )) or not (nMarket (P P P )). The rule with 0.7 :: buys_from_viral (P 0 P_0 P 0 , P 1 P_1 P 1 ) in the head represents, in a compact way, a set of ground probabilistic facts of the form 0.7 :: buys_from_viral (P 0 P_0 P 0 , P 1 P_1 P 1 ) probabilistic fact for each pair of people P 1 P_1 P 1 and P 2 P_2 P 2 . These facts state that the shopping behavior of P 1 P_1 P 1 is influenced with probability 0.7 by the behavior of P 2 P_2 P 2 . Similarly for the probability of buying from direct marketing (0.2 :: buys_from_marketing /1). Then, a person P P P buys (buys (P P P )) a product if it is marketed and buys from the marketing or if it has a friend who buys the product and influences her. Two weak constraints, with the same priority level, represent the cost of two actions: marketing a particular person has a certain cost, but if someone buys the product, this gives a reward (i.e., a negative cost). We are interested in computing, for example, the probability that a particular person or group buys the product, or that the number of people that buys the product is above a certain threshold. Overall, with optPASP we can now reason about the viral marketing scenario in a more fine-grained way, by considering different optimization criteria for the underlying ASP.
Computational Complexity Study
In this section, we study the complexity of the main reasoning tasks in optimal Probabilistic Answer Set Programs. In particular, we focus on propositional programs and consider the following decision problems.
Definition 5 (Inference). Given an optimal PASP P ∼ \mathcal{P}^{\sim} P ∼ , a ground literal q q q , and a rational γ \gamma γ , the
Definition 6 (MPE). Given an optimal PASP P ~ \widetilde{P} P , a ground literal e e e , and a rational γ \gamma γ , the
brave optimal MPE task asks whether P ( M P E ∗ ‾ ( e ) ) ≥ γ \mathrm{P}(\overline{\mathrm{MPE}^{*}}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ ;
cautious optimal MPE task asks whether P ( M P E ∗ ‾ ( e ) ) ≥ γ \mathrm{P}(\overline{\mathrm{MPE}^{*}}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ .
Computational complexity results for PASP without weak constraints (i.e., plain PASP) are well known. In particular, Mauá and Cozman [53 ] showed that the complexity of the cautious MPE problem for HCF programs (the fragment we consider in this paper) is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P , while the complexity of cautious inference is P P N P \mathrm{PP}^{\mathrm{NP}} PP NP .
Observation 2. Note that brave inference can be cast as cautious inference using the relation P ∗ ‾ ( q ) = 1 − P ∗ ( n o t q ) \overline{\mathrm{P}^{*}}(q) = 1-\mathrm{P}^{*}(not\ q) P ∗ ( q ) = 1 − P ∗ ( n o t q ) . For this reason, when we use the term inference while discussing complexity results, we refer to either brave or cautious inference. However, this relation does not hold for M P E ∗ ‾ \overline{\mathrm{MPE}^{*}} MPE ∗ and M P E ∗ \mathrm{MPE}^{*} MPE ∗ . Therefore the two tasks must be studied separately.
We first focus on the cautious and brave MPE problems, by showing that the usage of weak constraints i ) i) i ) causes a jump in complexity in the brave case (i.e., M P E ‾ ( e ) \overline{\mathrm{MPE}}(e) MPE ( e ) ) w.r.t. plain PASP while i i ) ii) ii ) the inherited complexity of weak constraints is absorbed in the cautious case (i.e., M P E ( e ) \mathrm{MPE}(e) MPE ( e ) ). So, surprisingly, the two cases have the same computational complexity for optimal PASP.
Lastly, we focus on the brave inference task (as the cautious case can be converted to the brave one) and show that the complexity coincides with the complexity of brave inference in plain PASP. That is, weak constraints do not change the complexity of the inference problem . To facilitate the comparison, Table 2 summarizes the completeness results for both plain and optimal PASP.
Table 2. Complexity results for plain and optimal PASP. Results with a reference are proven in this paper while the remaining are taken from [53 ] .
Computational Complexity of MPE
Mauá and Cozman [53 ] proved that the complexity of cautious MPE for plain PASP is complete for Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P . However, to the best of our knowledge, no completeness results are available for the brave MPE problem. To this end, the following theorem provides a completeness results for such a problem. Note that in the following proofs we assume that the logarithm can be efficiently computed and rounded in such a way that distinct probability values are mapped to distinct integers.
Let P \mathcal{P} P be a plain PASP, e e e be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Deciding whether P ( M P E ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}(e)) \ge\gamma P ( MPE ( e )) ≥ γ is NP-complete.
Proof
(Hardness) Let ϕ \phi ϕ be a boolean formula in 3-CNF over a set of propositional variables V V V of the form C 1 ∧ ⋯ ∧ C n C_1 \land\cdots\land C_n C 1 ∧ ⋯ ∧ C n , where each clause is of the form C i = l i 1 ∨ l i 2 ∨ l i 3 C_i = l_i^1 \lor l_i^2 \lor l_i^3 C i = l i 1 ∨ l i 2 ∨ l i 3 and each literal l i j l_i^j l i j (with 1 ≤ j ≤ 3 1 \le j \le3 1 ≤ j ≤ 3 ) is either a variable a ∈ V a \in V a ∈ V or its negation ¬ a \neg a ¬ a .
Verifying the satisfiability of ϕ \phi ϕ is NP-complete. To prove hardness for brave MPE in plain PASP, we encode ϕ \phi ϕ into a plain PASP P = ( T , F ) \mathcal{P} = (\mathcal{T},\mathcal{F}) P = ( T , F ) , such that P ( M P E ( s a t ) ) ≥ 0.5 ∣ F ∣ \mathrm{P}(\mathrm{MPE}(sat)) \ge0.5^{|\mathcal{F}|} P ( MPE ( s a t )) ≥ 0. 5 ∣ F ∣ iff ϕ \phi ϕ is satisfiable.
More precisely, F \mathcal{F} F is composed of probabilistic facts of the form 0.5 : : v 0.5 :: v 0.5 :: v for each variable v ∈ V v \in V v ∈ V , whereas T \mathcal{T} T is of the form:
r 1 : a s g n ( v , t ) : − v . ∀ v ∈ V r 2 : a s g n ( v , f ) : − n o t v . ∀ v ∈ V r 3 : s a t ( c ) : − a s g n ( l , f ) . ∀ c ∈ ϕ , ¬ l ∈ c r 4 : s a t ( c ) : − a s g n ( l , t ) . ∀ c ∈ ϕ , l ∈ c r 5 : u n s a t : − c l a u s e ( c ) , n o t s a t ( c ) . ∀ c ∈ ϕ r 6 : s a t : − n o t u n s a t . \begin{aligned}
r_1 &: \quad asgn(v,t) \mathrel{:-} v. && \forall v \in V\\
r_2 &: \quad asgn(v,f) \mathrel{:-} not\ v. && \forall v \in V\\
r_3 &: \quad sat(c) \mathrel{:-} asgn(l,f). && \forall c \in\phi,\ \neg l \in c\\
r_4 &: \quad sat(c) \mathrel{:-} asgn(l,t). && \forall c \in\phi,\ l \in c\\
r_5 &: \quad unsat \mathrel{:-} clause(c),\ not\ sat(c). && \forall c \in\phi\\
r_6 &: \quad sat \mathrel{:-} not\ unsat.
\end{aligned} r 1 r 2 r 3 r 4 r 5 r 6 : a s g n ( v , t ) : − v . : a s g n ( v , f ) : − n o t v . : s a t ( c ) : − a s g n ( l , f ) . : s a t ( c ) : − a s g n ( l , t ) . : u n s a t : − c l a u se ( c ) , n o t s a t ( c ) . : s a t : − n o t u n s a t . ∀ v ∈ V ∀ v ∈ V ∀ c ∈ ϕ , ¬ l ∈ c ∀ c ∈ ϕ , l ∈ c ∀ c ∈ ϕ
Let σ \sigma σ be a possible selection, then σ \sigma σ encodes a truth assignment τ σ \tau_\sigma τ σ for the variables in V V V . More precisely, for each v ∈ V v \in V v ∈ V , if v ∈ σ v \in\sigma v ∈ σ , then τ σ ( v ) = ⊤ \tau_\sigma(v) = \top τ σ ( v ) = ⊤ (i.e., v v v is true in τ σ \tau_\sigma τ σ ); otherwise τ σ ( v ) = ⊥ \tau_\sigma(v) = \bot τ σ ( v ) = ⊥ (i.e., v v v is false in τ σ \tau_\sigma τ σ ). Rules in T \mathcal{T} T check whether a truth assignment satisfies ϕ \phi ϕ or not: the atom s a t sat s a t is derived iff such an assignment satisfies all the clauses of ϕ \phi ϕ ; whereas the atom u n s a t unsat u n s a t is derived if there is at least one clause of ϕ \phi ϕ which is not satisfied.
Thus, the world w σ w_\sigma w σ , which enforces the truth assignment τ σ \tau_\sigma τ σ into T \mathcal{T} T , admits an answer set containing s a t sat s a t iff τ σ \tau_\sigma τ σ satisfies ϕ \phi ϕ , and so ϕ \phi ϕ is satisfiable.
Since all possible selections have the same probability, which is 0.5 ∣ F ∣ 0.5^{|\mathcal{F}|} 0. 5 ∣ F ∣ , and they are in one-to-one correspondence with possible truth assignments for variables in V V V , then P ( M P E ( s a t ) ) ≥ 0.5 ∣ F ∣ \mathrm{P}(\mathrm{MPE}(sat)) \ge0.5^{|\mathcal{F}|} P ( MPE ( s a t )) ≥ 0. 5 ∣ F ∣ iff ϕ \phi ϕ is satisfiable.
(Membership) We prove membership to the NP class by means of an head-cycle-free ASP encoding that is coherent iff P ( M P E ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}(e)) \ge\gamma P ( MPE ( e )) ≥ γ . Recall that verifying coherence of head-cycle-free ASP is NP-complete [26 ] .
Let P = ( T , F ) \mathcal{P} = (\mathcal{T},\mathcal{F}) P = ( T , F ) be a PASP and e e e be a ground literal. We construct the following T 1 \mathcal{T}_1 T 1 :
a ; n a . ∀ p : : a ∈ F p r o b ( log ( p ) , i d a ) : − a . ∀ p : : a ∈ F p r o b ( log ( 1 − p ) , i d a ) : − n o t a . ∀ p : : a ∈ F H r : − B r . ∀ r ∈ T : − # s u m { S } < log ( γ ) . : − e ˉ . \begin{aligned}
a;\ na. && \forall p :: a \in\mathcal{F}\\
prob(\log(p),id_a) \mathrel{:-} a. && \forall p :: a \in\mathcal{F}\\
prob(\log(1-p),id_a) \mathrel{:-} not\ a. && \forall p :: a \in\mathcal{F}\\
H_r \mathrel{:-} B_r. && \forall r \in\mathcal{T}\\
\mathrel{:-} \#sum\{S\} < \log(\gamma).\\
\mathrel{:-} \bar{e}.
\end{aligned} a ; na . p r o b ( log ( p ) , i d a ) : − a . p r o b ( log ( 1 − p ) , i d a ) : − n o t a . H r : − B r . : − # s u m { S } < log ( γ ) . : − e ˉ . ∀ p :: a ∈ F ∀ p :: a ∈ F ∀ p :: a ∈ F ∀ r ∈ T
where each i d a id_a i d a is a unique identifier for the probabilistic fact p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F , each atom n a na na is a fresh atom not appearing anywhere else, and S S S is a ground set where for each probabilistic fact p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F there are two elements of the form log ( p ) , i d a : p r o b ( log ( p ) , i d a ) \log(p),id_a : prob(\log(p),id_a) log ( p ) , i d a : p r o b ( log ( p ) , i d a ) and log ( 1 − p ) , i d a : p r o b ( log ( 1 − p ) , i d a ) \log(1-p),id_a : prob(\log(1-p),id_a) log ( 1 − p ) , i d a : p r o b ( log ( 1 − p ) , i d a ) . Note that e ˉ \bar{e} e ˉ is the complement of e e e .
Intuitively, rules of the form a ; n a a; na a ; na , for p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F , guess a possible selection σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a and the log-probability of σ \sigma σ is encoded by means of atoms over the predicate prob / 2 \operatorname{prob}/2 prob /2 deriving prob ( log ( p ) , i d a ) \operatorname{prob}(\log(p), id_{a}) prob ( log ( p ) , i d a ) for each a ∈ σ a \in\sigma a ∈ σ and prob ( log ( 1 − p ) , i d a ) \operatorname{prob}(\log(1-p), id_{a}) prob ( log ( 1 − p ) , i d a ) for each a ∈ F a ∖ σ a \in\mathcal{F}^{a} \setminus\sigma a ∈ F a ∖ σ . Then, rules in T ⊆ T 1 \mathcal{T} \subseteq\mathcal{T}_{1} T ⊆ T 1 guess a model of the world w σ w_{\sigma} w σ and the last two constraints impose that (i) the sum of log-probability of probabilistic facts cannot be less than log ( γ ) \log(\gamma) log ( γ ) and (ii) evidence e e e cannot be false.
Thus, there exists an answer set of T 1 \mathcal{T}_{1} T 1 iff there exists σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a such that P ( σ ) ≥ γ \mathrm{P}(\sigma) \ge\gamma P ( σ ) ≥ γ and there exists M ∈ A S ( w σ ) M \in AS(w_{\sigma}) M ∈ A S ( w σ ) such that e ∈ M e \in M e ∈ M , and so the thesis follows.
Theorem 4 completes the complexity study on MPE for plain PASP, establishing that brave MPE is easier than the cautious MPE for plain PASP. We now study the complexity of MPE for optimal PASP.
First, we provide hardness for brave optimal MPE via a reduction from the well-known Propositional Abduction Problem (PAP) [35 ] . Recall that a PAP is defined as a tuple of the form A = ⟨ V , T , H , M ⟩ \mathcal{A} = \langle V,T,H,M\rangle A = ⟨ V , T , H , M ⟩ , where V V V is a set of propositional variables, T T T is a satisfiable propositional logic theory over variables in V V V , H ⊆ V H \subseteq V H ⊆ V is a set of hypotheses, and M ⊆ V M \subseteq V M ⊆ V is a set of manifestations. A solution for A \mathcal{A} A is a subset of the hypotheses S ⊆ H S \subseteq H S ⊆ H such that T ∪ S T \cup S T ∪ S is satisfiable and T ∪ S ⊨ M T \cup S \models M T ∪ S ⊨ M . Let sol ( A ) \operatorname{sol}(\mathcal{A}) sol ( A ) be the set of solutions to PAP, then deciding whether sol ( A ) ≠ ∅ \operatorname{sol}(\mathcal{A}) \ne\varnothing sol ( A ) = ∅ is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P -complete [35 ] .
Theorem 5 (Hardness of brave optimal MPE). Let P ∼ \mathcal{P}^{\sim} P ∼ be an optimal PASP, e e e be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P -hard.
Proof. Let A = ⟨ V , T , H , M ⟩ \mathcal{A} = \langle V,T,H,M\rangle A = ⟨ V , T , H , M ⟩ be a PAP. We assume w.l.o.g. that the theory T T T is a 3-CNF formula over the variables in V V V . Recall that a 3-CNF formula is a conjunction of clauses C 1 ∧ ⋯ ∧ C n C_{1} \wedge\cdots\wedge C_{n} C 1 ∧ ⋯ ∧ C n , where each clause is of the form C i = l i 1 ∨ l i 2 ∨ l i 3 C_{i} = l_{i}^{1} \vee l_{i}^{2} \vee l_{i}^{3} C i = l i 1 ∨ l i 2 ∨ l i 3 and each l i j l_{i}^{j} l i j (with 1 ≤ j ≤ 3 1 \le j \le3 1 ≤ j ≤ 3 ) is either a variable a ∈ V a \in V a ∈ V or its (classical) negation ¬ a \neg a ¬ a . With a slight abuse of notation, we refer to the theory T T T as a set of clauses, and each clause as a set of literals (i.e., T = { C 1 , … , C n } T = \{C_{1}, \ldots, C_{n}\} T = { C 1 , … , C n } , where for each i ∈ { 1 , … , n } i \in\{1,\ldots,n\} i ∈ { 1 , … , n } , C i = { l i 1 , l i 2 , l i 3 } C_{i} = \{l_{i}^{1}, l_{i}^{2}, l_{i}^{3}\} C i = { l i 1 , l i 2 , l i 3 } ). From A \mathcal{A} A we can construct an optimal PASP P ∼ \mathcal{P}^{\sim} P ∼ such that P ( M P E ∗ ( e ) ) ≥ 0.5 ∣ H ∣ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge0.5^{|H|} P ( MPE ∗ ( e )) ≥ 0. 5 ∣ H ∣ iff sol ( A ) ≠ ∅ \operatorname{sol}(\mathcal{A}) \ne\varnothing sol ( A ) = ∅ . In detail, P ∼ = ( T , F , W ) \mathcal{P}^{\sim} = (\mathcal{T},\mathcal{F},\mathcal{W}) P ∼ = ( T , F , W ) where F = { 0.5 : : s ( x ) ∣ x ∈ H } \mathcal{F} = \{0.5 :: s(x) \mid x \in H\} F = { 0.5 :: s ( x ) ∣ x ∈ H } , W = { : ∼ entailed [ 1 @ 1 ] } \mathcal{W} = \{:\sim\operatorname{entailed}\ [1@1]\} W = { :∼ entailed [ 1@1 ]} , and T \mathcal{T} T is of the form:
T = { t a u ( x , t ) ; t a u ( x , f ) . ∀ x ∈ V s a t C l ( C i ) : − t a u ( x , t ) . ∀ x ∈ V , C i ∈ T s a t C l ( C i ) : − t a u ( x , f ) . ∀ x ∈ V , C i ∈ T ∣ ¬ x ∈ C i u n s a t T S : − n o t s a t C l ( C i ) . ∀ C i ∈ T u n s a t T S : − s ( x ) , t a u ( x , f ) . ∀ x ∈ H c o n s i s t e n t : − n o t u n s a t T S . t a u ′ ( x , t ) ; t a u ′ ( x , f ) . ∀ x ∈ V s a t C l ′ ( C i ) : − t a u ′ ( x , t ) . ∀ x ∈ V , C i ∈ T ∣ x ∈ C i s a t C l ′ ( C i ) : − t a u ′ ( x , f ) . ∀ x ∈ V , C i ∈ T ∣ ¬ x ∈ C i u n s a t T S ′ : − n o t s a t C l ′ ( C i ) . ∀ C i ∈ T u n s a t T S ′ : − s ( x ) , t a u ′ ( x , f ) . ∀ x ∈ H s a t T S ′ : − n o t u n s a t T S ′ . n o t E n t a i l : − s a t T S , t a u ′ ( x , f ) . ∀ x ∈ M e n t a i l e d : − n o t n o t E n t a i l . e : − c o n s i s t e n t , e n t a i l e d . : ∼ e n t a i l e d . [ 1 @ 1 ] \mathcal{T} = \left\{
\begin{aligned}
&\mathit{tau}(x,t); \mathit{tau}(x,f). && \forall x \in V \\
&\mathit{satCl}(C_i) :- \mathit{tau}(x,t). && \forall x \in V,C_i \in T \\
&\mathit{satCl}(C_i) :- \mathit{tau}(x,f). && \forall x \in V,C_i \in T \mid\neg x \in C_i \\
&\mathit{unsatTS} :- \mathit{not}\ \mathit{satCl}(C_i). && \forall C_i \in T \\
&\mathit{unsatTS} :- s(x),\mathit{tau}(x,f). && \forall x \in H \\
&\mathit{consistent} :- \mathit{not}\ \mathit{unsatTS}. \\
\\
&\mathit{tau}'(x,t);\mathit{tau}'(x,f). && \forall x \in V \\
&\mathit{satCl}'(C_i) :- \mathit{tau}'(x,t). && \forall x \in V,C_i \in T \mid x \in C_i \\
&\mathit{satCl}'(C_i) :- \mathit{tau}'(x,f). && \forall x \in V,C_i \in T \mid\neg x \in C_i \\
&\mathit{unsatTS}' :- \mathit{not}\ \mathit{satCl}'(C_i). && \forall C_i \in T \\
&\mathit{unsatTS}' :- s(x),\mathit{tau}'(x,f). && \forall x \in H \\
&\mathit{satTS}' :- \mathit{not}\ \mathit{unsatTS}'. \\
&\mathit{notEntail} :- \mathit{satTS},\mathit{tau}'(x,f). && \forall x \in M \\
&\mathit{entailed} :- \mathit{not}\ \mathit{notEntail}. \\
\\
&e :- \mathit{consistent},\mathit{entailed}. \\
&:\sim\mathit{entailed}.\ [1@1]
\end{aligned}
\right. T = ⎩ ⎨ ⎧ tau ( x , t ) ; tau ( x , f ) . satCl ( C i ) : − tau ( x , t ) . satCl ( C i ) : − tau ( x , f ) . unsatTS : − not satCl ( C i ) . unsatTS : − s ( x ) , tau ( x , f ) . consistent : − not unsatTS . tau ′ ( x , t ) ; tau ′ ( x , f ) . satCl ′ ( C i ) : − tau ′ ( x , t ) . satCl ′ ( C i ) : − tau ′ ( x , f ) . unsatTS ′ : − not satCl ′ ( C i ) . unsatTS ′ : − s ( x ) , tau ′ ( x , f ) . satTS ′ : − not unsatTS ′ . notEntail : − satTS , tau ′ ( x , f ) . entailed : − not notEntail . e : − consistent , entailed . :∼ entailed . [ 1@1 ] ∀ x ∈ V ∀ x ∈ V , C i ∈ T ∀ x ∈ V , C i ∈ T ∣ ¬ x ∈ C i ∀ C i ∈ T ∀ x ∈ H ∀ x ∈ V ∀ x ∈ V , C i ∈ T ∣ x ∈ C i ∀ x ∈ V , C i ∈ T ∣ ¬ x ∈ C i ∀ C i ∈ T ∀ x ∈ H ∀ x ∈ M
We now prove that P ( M P E ‾ ∗ ( e ) ) ≥ 0.5 ∣ F ∣ \mathrm{P}(\overline{\mathrm{MPE}}^{*}(e)) \ge0.5^{|\mathcal{F}|} P ( MPE ∗ ( e )) ≥ 0. 5 ∣ F ∣ iff s o l ( A ) ≠ ∅ sol(\mathcal{A}) \ne\emptyset so l ( A ) = ∅ . Since each probabilistic fact in P ∼ \mathcal{P}^{\sim} P ∼ has probability 0.5 0.5 0.5 , each selection σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a has the same probability, which is 0.5 ∣ F ∣ 0.5^{|\mathcal{F}|} 0. 5 ∣ F ∣ . Thus, P ( M P E ‾ ∗ ( e ) ) ≥ 0.5 ∣ F ∣ \mathrm{P}(\overline{\mathrm{MPE}}^{*}(e)) \ge0.5^{|\mathcal{F}|} P ( MPE ∗ ( e )) ≥ 0. 5 ∣ F ∣ iff there exists σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a such that ∃ I ∈ A S ∗ ( w σ ) \exists I \in AS^{*}(w_{\sigma}) ∃ I ∈ A S ∗ ( w σ ) such that e ∈ I e \in I e ∈ I .
Let σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a be a possible selection and S = { x ∣ s ( x ) ∈ σ } ⊆ H S = \{x \mid s(x) \in\sigma\} \subseteq H S = { x ∣ s ( x ) ∈ σ } ⊆ H . By construction, w σ w_{\sigma} w σ guesses a pair of assignments ( τ , τ ′ ) (\tau,\tau') ( τ , τ ′ ) (encoded by atoms over predicates t a u \mathit{tau} tau and t a u ′ \mathit{tau}' tau ′ , respectively), then:
c o n s i s t e n t \mathit{consistent} consistent is true in I I I iff τ \tau τ satisfies T ∪ S T \cup S T ∪ S ;
e n t a i l e d \mathit{entailed} entailed is true in I I I iff τ ′ \tau' τ ′ satisfies the entailment T ∪ S ⊨ M T \cup S \models M T ∪ S ⊨ M (i.e., if τ ′ \tau' τ ′ satisfies T ∪ S T \cup S T ∪ S and τ ′ \tau' τ ′ satisfies also M M M ); and
e e e is true in I I I iff both c o n s i s t e n t \mathit{consistent} consistent and e n t a i l e d \mathit{entailed} entailed are true in I I I .
Thus, given I ′ ∈ A S ∗ ( w σ ) I' \in AS^{*}(w_{\sigma}) I ′ ∈ A S ∗ ( w σ ) , then e ∈ I ′ e \in I' e ∈ I ′ iff c o n s i s t e n t ∈ I ′ \mathit{consistent} \in I' consistent ∈ I ′ and e n t a i l e d ∈ I ′ \mathit{entailed} \in I' entailed ∈ I ′ . Since c o n s i s t e n t ∈ I ′ \mathit{consistent} \in I' consistent ∈ I ′ iff the guessed assignment τ \tau τ satisfies T ∪ S T \cup S T ∪ S , then τ \tau τ is a witness for the consistency of T ∪ S T \cup S T ∪ S . On the other hand, if e n t a i l e d ∈ I ′ \mathit{entailed} \in I' entailed ∈ I ′ , then C ( w σ , I ′ , 1 ) = 1 C(w_{\sigma},I',1)=1 C ( w σ , I ′ , 1 ) = 1 . So, this means that for each I ′ ∈ A S ( w σ ) I' \in AS(w_{\sigma}) I ′ ∈ A S ( w σ ) , e n t a i l e d ∈ I ′ \mathit{entailed} \in I' entailed ∈ I ′ , otherwise I ′ I' I ′ would not be optimal. Thus, for every guessed assignment τ ′ \tau' τ ′ associated to a I ′ ∈ A S ∗ ( w σ ) I' \in AS^{*}(w_{\sigma}) I ′ ∈ A S ∗ ( w σ ) , τ ′ \tau' τ ′ satisfies T ∪ S ⊨ M T \cup S \models M T ∪ S ⊨ M , and so e n t a i l e d ∈ I \mathit{entailed} \in I entailed ∈ I iff T ∪ S ⊨ M T \cup S \models M T ∪ S ⊨ M holds. Since c o n s i s t e n t ∈ I ′ \mathit{consistent} \in I' consistent ∈ I ′ iff T ∪ S T \cup S T ∪ S is consistent and e n t a i l e d ∈ I ′ \mathit{entailed} \in I' entailed ∈ I ′ iff T ∪ S ⊨ M T \cup S \models M T ∪ S ⊨ M holds, then, we can conclude that e ∈ I e \in I e ∈ I iff S ∈ s o l ( A ) S \in sol(\mathcal{A}) S ∈ so l ( A ) and so P ( M P E ‾ ∗ ( e ) ) ≥ 0.5 ∣ F ∣ \mathrm{P}(\overline{\mathrm{MPE}}^{*}(e)) \ge0.5^{|\mathcal{F}|} P ( MPE ∗ ( e )) ≥ 0. 5 ∣ F ∣ iff s o l ( A ) ≠ ∅ sol(\mathcal{A}) \ne\emptyset so l ( A ) = ∅ . □
Theorem 6 (Hardness of cautious optimal MPE ) Let P ∼ \mathcal{P}^{\sim} P ∼ be an optimal PASP, e e e be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Deciding whether P ( M P E ‾ ∗ ( e ) ) ≥ γ \mathrm{P}(\overline{\mathrm{MPE}}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is Σ 2 P \Sigma^{P}_{2} Σ 2 P -hard.
Proof The proof follows directly by observing that each PASP is indeed an optimal PASP where the underlying ASP contains no weak constraints. Deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ for a PASP is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P -hard [53 ] and so the thesis follows.
From Theorem 5 and Theorem 6 we can observe that weak constraints cause a jump in complexity for brave MPE, but they do not introduce further complexity for cautious MPE. Indeed, both problems are hard for Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P .
We now provide memberships, which give us the completeness for cautious/brave MPE for optimal PASP. In both cases, we rely on ASP(Q) [6 , 54 ] which allows modeling this problem in a very natural way.
Theorem 7 (Membership of brave optimal MPE ) Let P ∼ \mathcal{P}^{\sim} P ∼ be an optimal PASP, e e e be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is in Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P .
Proof. For an optimal PASP P ∼ = ( T , F , W ) \mathcal{P}^{\sim} = (\mathcal{T},\mathcal{F},\mathcal{W}) P ∼ = ( T , F , W ) , deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is equivalent at verifying that there exists a selection σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a such that P ( σ ) ≥ γ \mathrm{P}(\sigma) \ge\gamma P ( σ ) ≥ γ and there exists M ∈ A S ∗ ( ω σ ) M \in AS^{*}(\omega_{\sigma}) M ∈ A S ∗ ( ω σ ) such that e ∈ M e \in M e ∈ M .
To this end, we provide an ASP(Q) encoding that verifies the existence of such σ \sigma σ . More precisely, we can encode this problem into an ASP(Q), namely Π \Pi Π , of the form ∃ s t T 1 ∃ s t T 2 : C \exists^{st} T_{1}\exists^{st} T_{2} : C ∃ s t T 1 ∃ s t T 2 : C where T 1 T_{1} T 1 is made of the following rules for each probabilistic fact p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F :
a ; n a . prob ( log ( p ) , i d a ) : − a . prob ( log ( 1 − p ) , i d a ) : − not a . \begin{aligned}
a; \; na. \\
\operatorname{prob}(\log(p), id_{a}) &:\!- a. \\
\operatorname{prob}(\log(1-p), id_{a}) &:\!- \operatorname{not}\ a.
\end{aligned} a ; na . prob ( log ( p ) , i d a ) prob ( log ( 1 − p ) , i d a ) : − a . : − not a .
where i d a id_{a} i d a is a unique identifier for the probabilistic fact p : : a p :: a p :: a and n a na na is a fresh atom not appearing anywhere else. Finally, T 2 = T ∪ W T_{2} = \mathcal{T} \cup\mathcal{W} T 2 = T ∪ W , and C C C is of the form:
: − e ‾ . :\!- \overline{e}. : − e .
: − # s u m { S } < log ( γ ) . :\!- \#sum\{S\} < \log(\gamma). : − # s u m { S } < log ( γ ) .
where S S S is a ground set where for each probabilistic fact p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F there are two elements of the form log ( p ) , i d a : prob ( log ( p ) , i d a ) \log(p), id_{a} : \operatorname{prob}(\log(p), id_{a}) log ( p ) , i d a : prob ( log ( p ) , i d a ) and log ( 1 − p ) , i d a : prob ( log ( 1 − p ) , i d a ) \log(1-p), id_{a} : \operatorname{prob}(\log(1-p), id_{a}) log ( 1 − p ) , i d a : prob ( log ( 1 − p ) , i d a ) . From Theorem 5 by Mazzotta et al. [54 ] , verifying the coherence of Π \Pi Π is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P -complete. So, this gives us the membership to Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P .
By construction, the program T 1 T_{1} T 1 guesses a set S ⊆ F a S \subseteq\mathcal{F}^{a} S ⊆ F a and then entails:
an atom prob ( log ( p ) , i d a ) \operatorname{prob}(\log(p), id_{a}) prob ( log ( p ) , i d a ) iff p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F and a ∈ S a \in S a ∈ S ; and
an atom prob ( log ( 1 − p ) , i d a ) \operatorname{prob}(\log(1-p), id_{a}) prob ( log ( 1 − p ) , i d a ) iff p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F and a ∉ S a \notin S a ∈ / S .
Thus, S S S corresponds to a possible selection, and atoms over the predicate prob / 2 \operatorname{prob}/2 prob /2 encode the log-probability of such a selection. So, there is a one-to-one correspondence between possible selections and the answer sets of program T 1 T_{1} T 1 . According to the semantics of ASP(Q), Π \Pi Π is coherent iff there exists M 1 ∈ A S ∗ ( T 1 ) M_{1} \in AS^{*}(T_{1}) M 1 ∈ A S ∗ ( T 1 ) such that ∃ s t T 2 ′ : C \exists^{st} T'_{2} : C ∃ s t T 2 ′ : C is coherent, with T 2 ′ = T 2 ∪ fix T 1 ( M 1 ) T'_{2} = T_{2} \cup\operatorname{fix}_{T_{1}}(M_{1}) T 2 ′ = T 2 ∪ fix T 1 ( M 1 ) .
Let M 1 ∈ A S ( T 1 ) = A S ∗ ( T 1 ) M_1 \in AS(\mathcal{T}_1) = AS^*(\mathcal{T}_1) M 1 ∈ A S ( T 1 ) = A S ∗ ( T 1 ) and σ \sigma σ the corresponding selection then, by construction, fix T 1 ( M 1 ) \operatorname{fix}_{\mathcal{T}_1}(M_1) fix T 1 ( M 1 ) is of the form:
a . ∀ p : : a ∈ F s.t. a ∈ M 1 n a . ∀ p : : a ∈ F s.t. a ∉ M 1 p r o b ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M 1 p r o b ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M 1 : − a . ∀ p : : a ∈ F s.t. a ∉ M 1 : − n a . ∀ p : : a ∈ F s.t. a ∈ M 1 : − p r o b ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M 1 : − p r o b ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M 1 \begin{aligned}
a. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1 \\
na. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\
prob(\log(p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1 \\
prob(\log(1-p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\[4pt]
:-a. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\
:-na. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1 \\
:-prob(\log(p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\
:-prob(\log(1-p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1
\end{aligned} a . na . p r o b ( log ( p ) , i d a ) . p r o b ( log ( 1 − p ) , i d a ) . : − a . : − na . : − p r o b ( log ( p ) , i d a ) . : − p r o b ( log ( 1 − p ) , i d a ) . ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1
We can observe that, by construction, fresh atoms of the form n a na na , for some p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F , probabilistic facts and atoms over the predicate p r o b / 2 prob/2 p r o b /2 do not appear in the head of any rule of T ⊆ T 2 ′ \mathcal{T} \subseteq\mathcal{T}'_2 T ⊆ T 2 ′ . So, this means that atoms appearing in the constraints of fix T 1 ( M 1 ) \operatorname{fix}_{\mathcal{T}_1}(M_1) fix T 1 ( M 1 ) are false in every answer set of T 2 ′ \mathcal{T}'_2 T 2 ′ and so such constraints are trivially satisfied. Thus, we can simplify T 2 ′ \mathcal{T}'_2 T 2 ′ to T ∪ W ∪ F a c t s \mathcal{T} \cup\mathcal{W} \cup Facts T ∪ W ∪ F a c t s , where F a c t s Facts F a c t s is:
a . ∀ p : : a ∈ F s.t. a ∈ M 1 n a . ∀ p : : a ∈ F s.t. a ∉ M 1 p r o b ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M 1 p r o b ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M 1 \begin{aligned}
a. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1 \\
na. &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\
prob(\log(p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \in M_1 \\
prob(\log(1-p),id_a). &\qquad\forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1
\end{aligned} a . na . p r o b ( log ( p ) , i d a ) . p r o b ( log ( 1 − p ) , i d a ) . ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1
Moreover, we observe that fresh atoms of the form n a na na , for some p : : a ∈ F p :: a \in\mathcal{F} p :: a ∈ F , and the atoms over the predicate p r o b / 2 prob/2 p r o b /2 do not appear in anywhere else in T 2 ′ \mathcal{T}'_2 T 2 ′ and so they do not affect the answer sets of the program T 2 ′ \mathcal{T}'_2 T 2 ′ .
Let A A A be the following set of atoms:
A = { n a . ∀ p : : a ∈ F s.t. a ∉ M 1 p r o b ( log ( p ) , i d a ) ∀ p : : a ∈ P ∼ s.t. a ∈ M 1 p r o b ( log ( 1 − p ) , i d a ) ∀ p : : a ∈ P ∼ s.t. a ∉ M 1 A = \left\{
\begin{aligned}
&na. && \forall p :: a \in\mathcal{F}\ \text{s.t.}\ a \notin M_1 \\
&prob(\log(p),id_a) && \forall p :: a \in\mathcal{P}^{\sim}\ \text{s.t.}\ a \in M_1 \\
&prob(\log(1-p),id_a) && \forall p :: a \in\mathcal{P}^{\sim}\ \text{s.t.}\ a \notin M_1
\end{aligned}
\right. A = ⎩ ⎨ ⎧ na . p r o b ( log ( p ) , i d a ) p r o b ( log ( 1 − p ) , i d a ) ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ P ∼ s.t. a ∈ M 1 ∀ p :: a ∈ P ∼ s.t. a ∈ / M 1
Then, we can remove facts over atoms in A A A from T 2 ′ \mathcal{T}'_2 T 2 ′ , obtaining the world w σ w_\sigma w σ , and so answer sets of T 2 ′ \mathcal{T}'_2 T 2 ′ will be of the form A ∪ M 2 A \cup M_2 A ∪ M 2 where M 2 ∈ A S ( w σ ) M_2 \in AS(w_\sigma) M 2 ∈ A S ( w σ ) . Since atoms in A A A do not appear in any weak constraint of W \mathcal{W} W , then A ∪ M 2 ∈ A S ∗ ( T 2 ′ ) A \cup M_2 \in AS^*(\mathcal{T}'_2) A ∪ M 2 ∈ A S ∗ ( T 2 ′ ) iff M 2 ∈ A S ∗ ( w σ ) M_2 \in AS^*(w_\sigma) M 2 ∈ A S ∗ ( w σ ) .
According to the coherence of ASP(Q), ∃ T 2 ′ : C \exists\mathcal{T}'_2 : C ∃ T 2 ′ : C is coherent iff there exists M 2 ′ ∈ A S ∗ ( T 2 ′ ) M'_2 \in AS^*(\mathcal{T}'_2) M 2 ′ ∈ A S ∗ ( T 2 ′ ) such that C ′ = C ∪ fix T 2 ′ ( M 2 ′ ) C' = C \cup\operatorname{fix}_{\mathcal{T}'_2}(M'_2) C ′ = C ∪ fix T 2 ′ ( M 2 ′ ) is coherent.
Let M 2 ′ ∈ A S ∗ ( T 2 ′ ) M'_2 \in AS^*(\mathcal{T}'_2) M 2 ′ ∈ A S ∗ ( T 2 ′ ) , then M 2 ′ = A ∪ M 2 M'_2 = A \cup M_2 M 2 ′ = A ∪ M 2 and M 2 ∈ A S ∗ ( w σ ) M_2 \in AS^*(w_\sigma) M 2 ∈ A S ∗ ( w σ ) . By construction, the program C ′ C' C ′ is coherent iff the constraints in C C C are satisfied w.r.t. M 2 ′ M'_2 M 2 ′ . Thus, C ′ C' C ′ is coherent iff M 2 ⊨ e M_2 \models e M 2 ⊨ e and the sum of the log-probability of probabilistic facts (encoded by atoms over the predicate p r o b / 2 prob/2 p r o b /2 in A A A ) is greater than or equal to log ( γ ) \log(\gamma) log ( γ ) .
Thus, Π \Pi Π is coherent iff there exists σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a such that P ( σ ) ≥ γ P(\sigma) \geq\gamma P ( σ ) ≥ γ and there exists M ∈ A S ∗ ( w σ ) M \in AS^*(w_\sigma) M ∈ A S ∗ ( w σ ) such that M ⊨ e M \models e M ⊨ e , that is P ( M P E ∗ ( e ) ) ≥ γ P(\mathrm{MPE}^*(e)) \geq\gamma P ( MPE ∗ ( e )) ≥ γ . Thus, the thesis follows. □
Based on the approach of the proof of Theorem 7 we can also provide a membership result for cautious MPE.
Theorem 8 (Membership of cautious optimal MPE)
Let P ~ \widetilde{\mathcal{P}} P be an optimal PASP, e e e be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is in Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P .
Proof
For an optimal PASP P ~ = ( T , F , W ) \widetilde{\mathcal{P}}=(\mathcal{T},\mathcal{F},\mathcal{W}) P = ( T , F , W ) , deciding whether P ( M P E ∗ ( e ) ) ≥ γ \mathrm{P}(\mathrm{MPE}^{*}(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is equivalent to verifying that there exists a selection σ ⊆ F \sigma\subseteq\mathcal{F} σ ⊆ F such that P ( σ ) ≥ γ \mathrm{P}(\sigma) \ge\gamma P ( σ ) ≥ γ and for each M ∈ A S ∗ ( w σ ) M \in AS^{*}(w_{\sigma}) M ∈ A S ∗ ( w σ ) , e ∈ M e \in M e ∈ M . Thus, similarly to Theorem 5, we provide an ASP(Q) encoding that verifies the existence of such σ \sigma σ . More precisely, we can encode such a problem into an ASP(Q) Π \Pi Π of the form ∃ s t T 1 ∃ s t T 2 : C \exists^{st}\mathcal{T}_{1}\exists^{st}\mathcal{T}_{2}: C ∃ s t T 1 ∃ s t T 2 : C where T 1 \mathcal{T}_{1} T 1 is equal to T 1 \mathcal{T}_{1} T 1 of 7. Finally, T 2 = T ∪ W ∪ { : ∼ e [ 1 @ l m i n − 1 ] } \mathcal{T}_{2}=\mathcal{T}\cup\mathcal{W}\cup\{\mathord{:}\mathord{\sim}e\ [1@lmin-1]\} T 2 = T ∪ W ∪ { : ∼ e [ 1@ l min − 1 ]} , with l m i n lmin l min being the lowest level among weak constraints in W \mathcal{W} W , and C C C is as in Theorem 7. As in the previous case, verifying the coherence of Π \Pi Π is Σ 2 P \Sigma^{\mathrm{P}}_{2} Σ 2 P -complete [54 ] .
By construction, the program T 1 \mathcal{T}_{1} T 1 guesses a set S ⊆ F S\subseteq\mathcal{F} S ⊆ F and then entails:
an atom prob ( log ( p ) , i d a ) \operatorname{prob}(\log(p),id_{a}) prob ( log ( p ) , i d a ) iff p : : a ∈ P ~ p::a\in\widetilde{\mathcal{P}} p :: a ∈ P and a ∈ S a\in S a ∈ S ; and
an atom prob ( log ( 1 − p ) , i d a ) \operatorname{prob}(\log(1-p),id_{a}) prob ( log ( 1 − p ) , i d a ) iff p : : a ∈ P ~ p::a\in\widetilde{\mathcal{P}} p :: a ∈ P and a ∉ S a\notin S a ∈ / S .
Thus, S S S corresponds to a possible selection, and the atoms over the predicate prob / 2 \operatorname{prob}/2 prob /2 encode the log-probability of such a selection. So, there is a one-to-one correspondence between the possible selections and the answer sets of the program T 1 \mathcal{T}_{1} T 1 . According to the semantics of ASP(Q), Π \Pi Π is coherent iff there exists M 1 ∈ A S ∗ ( T 1 ) M_{1}\in AS^{*}(\mathcal{T}_{1}) M 1 ∈ A S ∗ ( T 1 ) such that ∃ s t T 2 ′ : C \exists^{st}\mathcal{T}'_{2}:C ∃ s t T 2 ′ : C is coherent, with T 2 ′ = T 2 ∪ f i x T 1 ( M 1 ) \mathcal{T}'_{2}=\mathcal{T}_{2}\cup fix_{\mathcal{T}_{1}}(M_{1}) T 2 ′ = T 2 ∪ f i x T 1 ( M 1 ) .
Let M 1 ∈ A S ( T 1 ) = A S ∗ ( T 1 ) M_{1}\in AS(\mathcal{T}_{1})=AS^{*}(\mathcal{T}_{1}) M 1 ∈ A S ( T 1 ) = A S ∗ ( T 1 ) , and σ \sigma σ be the corresponding selection. By construction f i x T 1 ( M 1 ) fix_{\mathcal{T}_{1}}(M_{1}) f i x T 1 ( M 1 ) is of the form:
a . ∀ p : : a ∈ F s.t. a ∈ M 1 n a . ∀ p : : a ∈ F s.t. a ∉ M 1 prob ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M 1 prob ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M 1 : − a . ∀ p : : a ∈ F s.t. a ∉ M 1 : − n a . ∀ p : : a ∈ F s.t. a ∈ M 1 : − prob ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M 1 : − prob ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M 1 \begin{aligned}
a. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M_{1}\\
na. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M_{1}\\
\operatorname{prob}(\log(p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M_{1}\\
\operatorname{prob}(\log(1-p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M_{1}\\
\mathord{:}\mathord{-}a. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M_{1}\\
\mathord{:}\mathord{-}na. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M_{1}\\
\mathord{:}\mathord{-}\operatorname{prob}(\log(p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M_{1}\\
\mathord{:}\mathord{-}\operatorname{prob}(\log(1-p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M_{1}
\end{aligned} a . na . prob ( log ( p ) , i d a ) . prob ( log ( 1 − p ) , i d a ) . : − a . : − na . : − prob ( log ( p ) , i d a ) . : − prob ( log ( 1 − p ) , i d a ) . ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1 ∀ p :: a ∈ F s.t. a ∈ / M 1 ∀ p :: a ∈ F s.t. a ∈ M 1
As in the previous case, we can observe that, by construction, atoms of the form n a na na , for some p : : a ∈ F p::a\in\mathcal{F} p :: a ∈ F , probabilistic facts, and atoms over the predicate prob / 2 \operatorname{prob}/2 prob /2 do not appear in the head of any rule in T ⊆ T 2 ′ \mathcal{T}\subseteq\mathcal{T}'_{2} T ⊆ T 2 ′ . So, this means that atoms appearing in the constraints of f i x T 1 ( M 1 ) fix_{\mathcal{T}_{1}}(M_{1}) f i x T 1 ( M 1 ) are false in every answer set of T 2 ′ \mathcal{T}'_{2} T 2 ′ and so such constraints are trivially satisfied. Thus, we can simplify T 2 ′ \mathcal{T}'_{2} T 2 ′ to T ∪ W ∪ { : ∼ e [ 1 @ l m i n − 1 ] } ∪ F a c t s \mathcal{T}\cup\mathcal{W}\cup\{\mathord{:}\mathord{\sim}e\ [1@lmin-1]\}\cup Facts T ∪ W ∪ { : ∼ e [ 1@ l min − 1 ]} ∪ F a c t s , where F a c t s Facts F a c t s is of the form:
a . ∀ p : : a ∈ F s.t. a ∈ M n a . ∀ p : : a ∈ F s.t. a ∉ M prob ( log ( p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∈ M prob ( log ( 1 − p ) , i d a ) . ∀ p : : a ∈ F s.t. a ∉ M \begin{aligned}
a. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M\\
na. &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M\\
\operatorname{prob}(\log(p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\in M\\
\operatorname{prob}(\log(1-p),id_{a}). &\qquad\forall p::a\in\mathcal{F}\ \text{s.t. }a\notin M
\end{aligned} a . na . prob ( log ( p ) , i d a ) . prob ( log ( 1 − p ) , i d a ) . ∀ p :: a ∈ F s.t. a ∈ M ∀ p :: a ∈ F s.t. a ∈ / M ∀ p :: a ∈ F s.t. a ∈ M ∀ p :: a ∈ F s.t. a ∈ / M
Moreover, we observe that atoms of the form n a na na , for some p : : a ∈ F p::a\in\mathcal{F} p :: a ∈ F , and atoms over the predicate prob / 2 \operatorname{prob}/2 prob /2 do not appear in anywhere else in T 2 ′ \mathcal{T}'_{2} T 2 ′ and so they do not affect the answer sets of the program T 2 ′ \mathcal{T}'_{2} T 2 ′ . Let A A A be the following set of atoms:
A = { n a ∀ p : : a ∈ P ∼ s.t. a ∈ M p r o b ( log ( p ) , i d a ) ∀ p : : a ∈ P ∼ s.t. a ∈ M p r o b ( log ( 1 − p ) , i d a ) ∀ p : : a ∈ P ∼ s.t. a ∉ M A = \left\{ \begin{array}{ll}
na & \forall p :: a \in\mathcal{P}^{\sim}\ \text{s.t. } a \in M \\
prob(\log(p), id_a) & \forall p :: a \in\mathcal{P}^{\sim}\ \text{s.t. } a \in M \\
prob(\log(1-p), id_a) & \forall p :: a \in\mathcal{P}^{\sim}\ \text{s.t. } a \notin M
\end{array} \right. A = ⎩ ⎨ ⎧ na p r o b ( log ( p ) , i d a ) p r o b ( log ( 1 − p ) , i d a ) ∀ p :: a ∈ P ∼ s.t. a ∈ M ∀ p :: a ∈ P ∼ s.t. a ∈ M ∀ p :: a ∈ P ∼ s.t. a ∈ / M
Then, we can remove from T 2 ′ \mathcal{T}'_2 T 2 ′ facts over the atoms in A A A , obtaining the program P = w σ ∪ { ∼ : e [ 1 @ l m i n − 1 ] } P = w_{\sigma} \cup\{\mathord{\sim}: e\ [1@lmin - 1]\} P = w σ ∪ { ∼ : e [ 1@ l min − 1 ]} . So, each answer set of T 2 ′ \mathcal{T}'_2 T 2 ′ is of the form A ∪ M A \cup M A ∪ M where M ∈ A S ( P ) = A S ( w σ ) M \in AS(P) = AS(w_{\sigma}) M ∈ A S ( P ) = A S ( w σ ) , since P P P extends the world w σ w_{\sigma} w σ with a weak constraint.
According to the semantics of ASP(Q), ∃ s t T 2 ′ : C \exists^{st}\mathcal{T}'_2 : C ∃ s t T 2 ′ : C is coherent iff there exists M 2 ∈ A S ∗ ( T 2 ′ ) M_2 \in AS^*(\mathcal{T}'_2) M 2 ∈ A S ∗ ( T 2 ′ ) such that C ∪ f i x T 2 ′ ( M 2 ) C \cup fix_{\mathcal{T}'_2}(M_2) C ∪ f i x T 2 ′ ( M 2 ) is coherent. The constraints in C C C impose that the sum of the log-probabilities of probabilistic facts (encoded by atoms over the predicate p r o b / 2 prob/2 p r o b /2 in A A A ) must be greater than or equal to log ( γ ) \log(\gamma) log ( γ ) and e e e must be true w.r.t. M 2 M_2 M 2 .
Thus, we now show that there exists such M 2 M_2 M 2 iff the evidence e e e is true in every optimal answer set of w σ w_{\sigma} w σ , which means P ( MPE ∗ ( e ) ) ≥ γ P(\operatorname{MPE}^*(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ and so the thesis follows.
Let M 2 ∈ A S ∗ ( T 2 ′ ) M_2 \in AS^*(\mathcal{T}'_2) M 2 ∈ A S ∗ ( T 2 ′ ) , then M 2 = A ∪ M M_2 = A \cup M M 2 = A ∪ M where M ∈ A S ∗ ( P ) M \in AS^*(P) M ∈ A S ∗ ( P ) . Then we show that (i) M ∈ A S ∗ ( w σ ) M \in AS^*(w_{\sigma}) M ∈ A S ∗ ( w σ ) and (ii) M ⊨ e M \models e M ⊨ e iff e e e is true in every M ′ ∈ A S ∗ ( w σ ) M' \in AS^*(w_{\sigma}) M ′ ∈ A S ∗ ( w σ ) .
By construction we know that:
for each l ≥ l m i n l \ge lmin l ≥ l min , C ( P , M , l ) = C ( w σ , M , l ) C(P,M,l) = C(w_{\sigma},M,l) C ( P , M , l ) = C ( w σ , M , l ) ; and
if e ∉ M e \notin M e ∈ / M , then C ( P , M , l m i n − 1 ) = 0 C(P,M,lmin - 1) = 0 C ( P , M , l min − 1 ) = 0 , otherwise C ( P , M , l m i n − 1 ) = 1 C(P,M,lmin - 1) = 1 C ( P , M , l min − 1 ) = 1 .
So, if M ∉ A S ∗ ( w σ ) M \notin AS^*(w_{\sigma}) M ∈ / A S ∗ ( w σ ) (i.e., M M M is an optimal answer set of P P P but it is not optimal for w σ w_{\sigma} w σ ), then M M M is dominated by M ′ ∈ A S ∗ ( w σ ) ⊆ A S ( w σ ) = A S ( P ) M' \in AS^*(w_{\sigma}) \subseteq AS(w_{\sigma}) = AS(P) M ′ ∈ A S ∗ ( w σ ) ⊆ A S ( w σ ) = A S ( P ) , and so M M M would not be optimal for P P P , which is a contradiction. So M ∈ A S ∗ ( w σ ) M \in AS^*(w_{\sigma}) M ∈ A S ∗ ( w σ ) .
Now, let us assume that there exists M ′ ∈ A S ∗ ( w σ ) M' \in AS^*(w_{\sigma}) M ′ ∈ A S ∗ ( w σ ) such that M ′ ⊭ e M' \not\models e M ′ ⊨ e and the evidence e e e is true in M M M (i.e., M ⊨ e M \models e M ⊨ e ). Since A S ( P ) = A S ( w σ ) AS(P) = AS(w_{\sigma}) A S ( P ) = A S ( w σ ) , then M ′ ∈ A S ( P ) M' \in AS(P) M ′ ∈ A S ( P ) and C ( P , M ′ , l m i n − 1 ) = 0 < 1 = C ( P , M , l m i n − 1 ) C(P,M',lmin - 1) = 0 < 1 = C(P,M,lmin - 1) C ( P , M ′ , l min − 1 ) = 0 < 1 = C ( P , M , l min − 1 ) . Thus, M M M is dominated by M ′ M' M ′ since M ∈ A S ∗ ( w σ ) M \in AS^*(w_{\sigma}) M ∈ A S ∗ ( w σ ) , and so, for each l ≥ l m i n l \ge lmin l ≥ l min , C ( P , M ′ , l ) = C ( P , M , l ) C(P,M',l) = C(P,M,l) C ( P , M ′ , l ) = C ( P , M , l ) and M ∉ A S ∗ ( P ) M \notin AS^*(P) M ∈ / A S ∗ ( P ) . This is a contradiction, since M M M is an optimal answer set of P P P .
Thus, we can conclude that e ∈ M e \in M e ∈ M iff for each M ′ ∈ A S ∗ ( w σ ) M' \in AS^*(w_{\sigma}) M ′ ∈ A S ∗ ( w σ ) , e ∈ M ′ e \in M' e ∈ M ′ , and the thesis follows. □
Theorem 9 (Complexity of cautious and brave optimal MPE) Given an optimal PASP P ~ \widetilde{P} P , a ground literal e e e , and a rational number γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] , deciding whether (i) P ( MPE ∗ ( e ) ) ≥ γ P(\operatorname{MPE}^*(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is Σ 2 P \Sigma^P_2 Σ 2 P -complete and (ii) P ‾ ( MPE ∗ ( e ) ) ≥ γ \overline{P}(\operatorname{MPE}^*(e)) \ge\gamma P ( MPE ∗ ( e )) ≥ γ is Σ 2 P \Sigma^P_2 Σ 2 P -complete.
Proof The proof follows from theorems 5-8. □
Computational Complexity of Inference
We now study the complexity of the brave inference problem (Definition 5). We start from the hardness result and then also provide a membership result, thus proving completeness. Recall that brave inference can be converted to cautious inference and vice versa, so studying one is enough. This is because P ‾ ( q ) = 1 − P ( n o t q ) \overline{P}(q) = 1 - P(\mathord{not}\ q) P ( q ) = 1 − P ( n o t q ) for a query atom q q q . Also note that for MPE, converting the lower state into the upper state is not possible in general, as the latter is a world in which the query is cautiously or bravely entailed.
Theorem 10 (Hardness of brave optimal inference). Let P ~ \widetilde{P} P be an optimal PASP, q q q be a ground literal, and γ \gamma γ be a rational number in [ 0 , 1 ] [0,1] [ 0 , 1 ] . Verifying whether P ‾ ∗ ( q ) > γ \overline{P}^{*}(q) > \gamma P ∗ ( q ) > γ is hard for P P N P \mathrm{PP}^{\mathrm{NP}} PP NP .
Proof. Hardness directly follows from the inference problem in PASP. Indeed, every PASP is an optimal PASP where the set of weak constraints is empty, so the complexity of the inference problem is at least difficult as in PASP, that is, P P N P \mathrm{PP}^{\mathrm{NP}} PP NP [53 ] .
Before considering membership of the brave inference problem for optimal PASP, we first recall the complexity of brave reasoning in HCF programs with weak constraints (i.e., the ASP fragment considered in this paper), which is instrumental in what follows.
Theorem 11 (Buccafurri et al. [18 ] ) Let T \mathcal{T} T be an HCF program with weak constraints and q q q be ground literal. Verifying whether there exists M ∈ A S ∗ ( T ) M \in\mathrm{AS}^{*}(\mathcal{T}) M ∈ AS ∗ ( T ) such that M ⊨ q M \models q M ⊨ q is Δ 2 P \Delta^{\mathrm{P}}_{2} Δ 2 P -complete.
Theorem 12 (Membership of brave optimal inference). Let P ~ \widetilde{P} P be an optimal PASP, q q q be an atom, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Then, verifying whether P ‾ ∗ ( q ) > γ \overline{P}^{*}(q) > \gamma P ∗ ( q ) > γ is in P P N P \mathrm{PP}^{\mathrm{NP}} PP NP .
Proof. To prove this, we can apply, with slight modifications, the methodology employed by Cozman and Mauá [23 ] to prove the complexity of brave inference for plain PASP.
Let P ~ = ( T , F , W ) \widetilde{P} = (\mathcal{T},\mathcal{F},\mathcal{W}) P = ( T , F , W ) be an optimal PASP. We construct a non-deterministic Turing Machine T M P ~ TM_{\widetilde{P}} T M P such that, for each probabilistic fact p i : : a i ∈ F p_i :: a_i \in\mathcal{F} p i :: a i ∈ F , with p i = μ i / ν i p_i = \mu_i/\nu_i p i = μ i / ν i for some (smallest) integers μ i \mu_i μ i and ν i \nu_i ν i , it chooses one among ν i \nu_i ν i computation paths. For μ i \mu_i μ i of these computation paths, a i a_i a i is considered true, while for the remaining ν i − μ i \nu_i-\mu_i ν i − μ i , a i a_i a i is considered false. This means that such a machine has ∏ a i ∈ F a ν i \prod_{a_i \in\mathcal{F}^{a}} \nu_i ∏ a i ∈ F a ν i computation paths, and for each selection σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a , there are ∏ a i ∈ σ μ i ⋅ ∏ a i ∈ F a ∖ σ ( ν i − μ i ) \prod_{a_i \in\sigma}\mu_i \cdot\prod_{a_i \in\mathcal{F}^{a}\setminus\sigma}(\nu_i-\mu_i) ∏ a i ∈ σ μ i ⋅ ∏ a i ∈ F a ∖ σ ( ν i − μ i ) computation paths. Each of these paths is polynomial w.r.t. the input size and returns yes iff ∃ M ∈ A S ∗ ( w σ ) \exists M \in\mathrm{AS}^{*}(w_{\sigma}) ∃ M ∈ AS ∗ ( w σ ) such that M ⊨ q M \models q M ⊨ q .
Let S = { σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) s . t . M ⊨ q } S=\{\sigma\subseteq\mathcal{F}^{a} \mid\exists M \in\mathrm{AS}^{*}(w_{\sigma})\ \mathrm{s.t.}\ M \models q\} S = { σ ⊆ F a ∣ ∃ M ∈ AS ∗ ( w σ ) s.t. M ⊨ q } , i.e., the set of selections σ \sigma σ such that the query q q q is true in at least one optimal answer set of the world w σ w_{\sigma} w σ identified by σ \sigma σ . Then, the number of accepting paths of T M P ~ TM_{\widetilde{P}} T M P is equal to
∑ σ ∈ S ( ∏ a i ∈ σ μ i ⋅ ∏ a i ∈ F a ∖ σ ( ν i − μ i ) ) . \sum_{\sigma\in S}\left(\prod_{a_i \in\sigma}\mu_i \cdot\prod_{a_i \in\mathcal{F}^{a}\setminus\sigma}(\nu_i-\mu_i)\right). σ ∈ S ∑ a i ∈ σ ∏ μ i ⋅ a i ∈ F a ∖ σ ∏ ( ν i − μ i ) .
If we divide this quantity by the total number of paths, we obtain the probability of the query q q q . That is,
P ‾ ( q ) = ∑ σ ∈ S ( ∏ a i ∈ σ μ i ⋅ ∏ a i ∈ F a ∖ σ ( ν i − μ i ) ) ∏ a i ∈ F a ν i . \overline{P}(q)=\frac{\sum_{\sigma\in S}\left(\prod_{a_i \in\sigma}\mu_i\cdot\prod_{a_i \in\mathcal{F}^{a}\setminus\sigma}(\nu_i-\mu_i)\right)}{\prod_{a_i \in\mathcal{F}^{a}}\nu_i}. P ( q ) = ∏ a i ∈ F a ν i ∑ σ ∈ S ( ∏ a i ∈ σ μ i ⋅ ∏ a i ∈ F a ∖ σ ( ν i − μ i ) ) .
This means that P ‾ ( q ) > γ \overline{P}(q)>\gamma P ( q ) > γ if and only if the number of accepting paths of T M P ~ TM_{\widetilde{P}} T M P is greater than γ ⋅ ∏ a i ∈ F a ν i \gamma\cdot\prod_{a_i \in\mathcal{F}^{a}}\nu_i γ ⋅ ∏ a i ∈ F a ν i . If γ = 1 / 2 \gamma= 1/2 γ = 1/2 , then P ‾ ( q ) > γ \overline{\mathrm{P}}(q) > \gamma P ( q ) > γ if and only if more than half of the computational paths are accepting. For a generated selection, verifying the existence of an optimal answer set is Δ 2 P \Delta^{\mathrm{P}}_{2} Δ 2 P (Theorem 11). Thus, for γ = 1 / 2 \gamma= 1/2 γ = 1/2 the problem is in P P Δ 2 P \mathrm{PP}^{\Delta^{\mathrm{P}}_{2}} PP Δ 2 P .
We now reduce the general case, i.e., with an arbitrary value of γ \gamma γ , to the specific case γ = 1 / 2 \gamma= 1/2 γ = 1/2 , obtain membership in P P Δ 2 P \mathrm{PP}^{\Delta^{\mathrm{P}}_{2}} PP Δ 2 P . First, consider γ > 1 / 2 \gamma> 1/2 γ > 1/2 . Then construct an optimal PASP P ~ ′ = ( T ′ , F ′ , W ) \widetilde{\mathcal{P}}' = (T', \mathcal{F}', \mathcal{W}) P ′ = ( T ′ , F ′ , W ) , where T ′ = T ∪ { a u x 2 : − q , a u x 1 } T' = T \cup\{aux_{2} :- q, aux_{1}\} T ′ = T ∪ { a u x 2 : − q , a u x 1 } , and F ′ = F ∪ { 1 / ( 2 γ ) : : a u x 1 } \mathcal{F}' = \mathcal{F} \cup\{1/(2\gamma) :: aux_{1}\} F ′ = F ∪ { 1/ ( 2 γ ) :: a u x 1 } , with fresh atoms a u x 1 aux_{1} a u x 1 and a u x 2 aux_{2} a u x 2 not appearing elsewhere, and prove that P ‾ ( a u x 2 ) > 1 / 2 \overline{\mathrm{P}}(aux_{2}) > 1/2 P ( a u x 2 ) > 1/2 if and only if P ‾ ( q ) > γ \overline{\mathrm{P}}(q) > \gamma P ( q ) > γ .
Selections for P ~ ′ \widetilde{\mathcal{P}}' P ′ are obtained from selections for P ~ \widetilde{\mathcal{P}} P by including or not a u x 1 aux_{1} a u x 1 . Therefore, for each selection σ ⊆ F a \sigma\subseteq\mathcal{F}^{a} σ ⊆ F a for P ~ \widetilde{\mathcal{P}} P , we have two possible selections, σ 1 = σ \sigma_{1} = \sigma σ 1 = σ , where a u x 1 aux_{1} a u x 1 is not included, and σ 2 = σ ∪ { a u x 1 } \sigma_{2} = \sigma\cup\{aux_{1}\} σ 2 = σ ∪ { a u x 1 } , where a u x 1 aux_{1} a u x 1 is included. The corresponding worlds w σ 1 w_{\sigma_{1}} w σ 1 and w σ 2 w_{\sigma_{2}} w σ 2 preserve all the optimal answer sets of w σ w_{\sigma} w σ as a u x 1 aux_{1} a u x 1 and a u x 2 aux_{2} a u x 2 appear only in the new rule a u x 2 : − q , a u x 1 aux_{2} :- q, aux_{1} a u x 2 : − q , a u x 1 and they do not appear in any weak constraints. For each M ∈ A S ∗ ( w σ ) M \in AS^{*}(w_{\sigma}) M ∈ A S ∗ ( w σ ) we have: 1) M ∈ A S ∗ ( w σ 1 ) M \in AS^{*}(w_{\sigma_{1}}) M ∈ A S ∗ ( w σ 1 ) since a u x 1 ∉ σ 1 aux_{1} \notin\sigma_{1} a u x 1 ∈ / σ 1 and so a u x 2 ∉ M aux_{2} \notin M a u x 2 ∈ / M ; and 2) M ∪ { a u x 1 , a u x 2 } ∈ A S ∗ ( w σ 2 ) M \cup\{aux_{1}, aux_{2}\} \in AS^{*}(w_{\sigma_{2}}) M ∪ { a u x 1 , a u x 2 } ∈ A S ∗ ( w σ 2 ) if and only if M ⊨ q M \models q M ⊨ q . Thus,
P ‾ ( a u x 2 ) = ∑ σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q P ( σ 2 ) = ∑ σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q 1 2 γ ⋅ P ( σ ) = 1 2 γ ⋅ ∑ σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q P ( σ ) = 1 2 γ ⋅ P ‾ ( q ) . \begin{aligned}
\overline{\mathrm{P}}(aux_{2}) =
\sum_{\substack{\sigma\subseteq\mathcal{F}^{a} \mid\exists M \in AS^{*}(w_{\sigma}),\,M \models q}} \mathrm{P}(\sigma_{2}) \\
&=
\sum_{\substack{\sigma\subseteq\mathcal{F}^{a} \mid\exists M \in AS^{*}(w_{\sigma}),\,M \models q}} \frac{1}{2\gamma} \cdot\mathrm{P}(\sigma) \\
&=
\frac{1}{2\gamma} \cdot
\sum_{\substack{\sigma\subseteq\mathcal{F}^{a} \mid\exists M \in AS^{*}(w_{\sigma}),\,M \models q}} \mathrm{P}(\sigma) \\
&= \frac{1}{2\gamma} \cdot\overline{\mathrm{P}}(q).
\end{aligned} P ( a u x 2 ) = σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q ∑ P ( σ 2 ) = σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q ∑ 2 γ 1 ⋅ P ( σ ) = 2 γ 1 ⋅ σ ⊆ F a ∣ ∃ M ∈ A S ∗ ( w σ ) , M ⊨ q ∑ P ( σ ) = 2 γ 1 ⋅ P ( q ) .
Thus, P ‾ ( a u x 2 ) > 1 / 2 \overline{\mathrm{P}}(aux_{2}) > 1/2 P ( a u x 2 ) > 1/2 if and only if 1 / ( 2 γ ) ⋅ P ‾ ( q ) > 1 / 2 1/(2\gamma) \cdot\overline{\mathrm{P}}(q) > 1/2 1/ ( 2 γ ) ⋅ P ( q ) > 1/2 i.e., P ‾ ( q ) > γ \overline{\mathrm{P}}(q) > \gamma P ( q ) > γ . If γ < 1 / 2 \gamma< 1/2 γ < 1/2 , then set the probability of a u x 1 aux_{1} a u x 1 to 1 − 2 γ 2 − 2 γ \frac{1-2\gamma}{2-2\gamma} 2 − 2 γ 1 − 2 γ and proceed as before. Thus, deciding whether P ‾ ( q ) > γ \overline{\mathrm{P}}(q) > \gamma P ( q ) > γ is in P P Δ 2 P \mathrm{PP}^{\Delta^{\mathrm{P}}_{2}} PP Δ 2 P . As observed by Mauá and Cozman [53 ] , P P Δ 2 P = P P N P \mathrm{PP}^{\Delta^{\mathrm{P}}_{2}} = \mathrm{PP}^{\mathrm{NP}} PP Δ 2 P = PP NP and so the thesis follows. □
Theorem 13. Let P ~ \widetilde{\mathcal{P}} P be an optimal PASP, q q q be a ground literal, and γ ∈ [ 0 , 1 ] \gamma\in[0,1] γ ∈ [ 0 , 1 ] be a rational number. Then, verifying whether P ‾ ∗ ( q ) > γ \overline{\mathrm{P}}^{*}(q) > \gamma P ∗ ( q ) > γ is P P N P \mathrm{PP}^{\mathrm{NP}} PP NP -complete.
Proof. Follows from Theorem 10 and 12. □
Implementation of Inference and MPE in Optimal PASP
We now show how inference and the computation of the MPE in optimal PASP can be naturally encoded as a 2AMC task. After this, we consider an ASP(Q)-based implementation for the MPE task.
Encoding Inference as a 2AMC Task
Here we consider an optimal PASP with query q q q , probabilistic facts F \mathcal{F} F , and weak constraints W \mathcal{W} W , where, w.l.o.g., each weak constraint is of the form ∼ a . [ w , i d a ] \mathord{\sim} a.[w, id_a] ∼ a . [ w , i d a ] , a a a is a ground atom, and w > 0 w > 0 w > 0 (the weight). We omit the level l l l , as multiple levels of weak constraints can be rearranged into only one level and negative weights can be rewritten as positive, see [3 , 18 ] . Furthermore, each weak constraint of the form ∼ l 1 , … , l n [ w , t ] \mathord{\sim} l_1,\ldots,l_n [w,t] ∼ l 1 , … , l n [ w , t ] can be rewritten as a normal rule of the form v ( w , t ) : − l 1 , … , l n v(w,t) \mathbin{:-} l_1,\ldots,l_n v ( w , t ) : − l 1 , … , l n and a weak constraint of the form ∼ v ( w , t ) [ w , t ] \mathord{\sim} v(w,t) [w,t] ∼ v ( w , t ) [ w , t ] . This will be instrumental in what follows, as our implementation assumes that weights are associated with atoms.
To perform inference, the two layers of AMC (Definition 3) are instantiated as follows.
Inner Layer. For the inner layer A i A_i A i we have:
as semiring, R i = ( N 3 , ⊕ , ⊗ , ( ∞ , 0 , 0 ) , ( 0 , 1 , 1 ) ) R^i = (\mathbb{N}^3,\oplus,\otimes,(\infty,0,0),(0,1,1)) R i = ( N 3 , ⊕ , ⊗ , ( ∞ , 0 , 0 ) , ( 0 , 1 , 1 )) ;
as variables B P ∖ F \mathcal{B}_{P}\setminus\mathcal{F} B P ∖ F ;
as weight function:
w i ( a ) = { ( 0 , 0 , 1 ) if a = n o t q ( w ( a ) , 1 , 1 ) if a ∈ W ( 0 , 1 , 1 ) otherwise w_i(a) =
\begin{cases}
(0,0,1) & \text{if } a = \mathop{\mathrm{not}} q \\
(w(a),1,1) & \text{if } a \in\mathcal{W} \\
(0,1,1) & \text{otherwise}
\end{cases} w i ( a ) = ⎩ ⎨ ⎧ ( 0 , 0 , 1 ) ( w ( a ) , 1 , 1 ) ( 0 , 1 , 1 ) if a = not q if a ∈ W otherwise
where ( a 0 , a 1 , a 2 ) ⊗ ( b 0 , b 1 , b 2 ) = ( a 0 + b 0 , a 1 ⋅ b 1 , a 2 ⋅ b 2 ) (a_0,a_1,a_2)\otimes(b_0,b_1,b_2)=(a_0+b_0,a_1\cdot b_1,a_2\cdot b_2) ( a 0 , a 1 , a 2 ) ⊗ ( b 0 , b 1 , b 2 ) = ( a 0 + b 0 , a 1 ⋅ b 1 , a 2 ⋅ b 2 ) and w ( a ) w(a) w ( a ) is the weight (cost) associated with atom a a a , and
( a 0 , a 1 , a 2 ) ⊕ ( b 0 , b 1 , b 2 ) = { ( a 0 , a 1 , a 2 ) if a 0 < b 0 ( b 0 , b 1 , b 2 ) if b 0 < a 0 ( a 0 , a 1 + b 1 , a 2 + b 2 ) if a 0 = b 0 . (a_0,a_1,a_2)\oplus(b_0,b_1,b_2)=
\begin{cases}
(a_0,a_1,a_2) & \text{if } a_0 < b_0 \\
(b_0,b_1,b_2) & \text{if } b_0 < a_0 \\
(a_0,a_1+b_1,a_2+b_2) & \text{if } a_0 = b_0.
\end{cases} ( a 0 , a 1 , a 2 ) ⊕ ( b 0 , b 1 , b 2 ) = ⎩ ⎨ ⎧ ( a 0 , a 1 , a 2 ) ( b 0 , b 1 , b 2 ) ( a 0 , a 1 + b 1 , a 2 + b 2 ) if a 0 < b 0 if b 0 < a 0 if a 0 = b 0 .
The first component stores the weights, the second counts the number of models where the query q q q is true, while the last counts all the models. As the transformation function, we use:
f i o ( ( n 0 , n 1 , n 2 ) ) = { ( 0 , 0 ) if n 1 = 0 ( 0 , 1 ) if n 2 > n 1 > 0 ( 1 , 1 ) if n 1 = n 2 > 0 f_{io}((n_0,n_1,n_2)) =
\begin{cases}
(0,0) & \text{if } n_1 = 0 \\
(0,1) & \text{if } n_2 > n_1 > 0 \\
(1,1) & \text{if } n_1 = n_2 > 0
\end{cases} f i o (( n 0 , n 1 , n 2 )) = ⎩ ⎨ ⎧ ( 0 , 0 ) ( 0 , 1 ) ( 1 , 1 ) if n 1 = 0 if n 2 > n 1 > 0 if n 1 = n 2 > 0
Remember that n 1 n_1 n 1 cannot be larger than n 2 n_2 n 2 .
Outer Layer. For the outer layer A o A_o A o we have:
as semiring, R o = ( [ 0 , 1 ] 2 , + , ⋅ , ( 0 , 0 ) , ( 1 , 1 ) ) R^o = ([0,1]^2,+,\cdot,(0,0),(1,1)) R o = ([ 0 , 1 ] 2 , + , ⋅ , ( 0 , 0 ) , ( 1 , 1 )) , i.e., a double probability semiring extended to two dimensions;
as variables F \mathcal{F} F ;
as weight function:
w m ( a ) = { ( p , p ) if a = f with p.f. p : : f , ( 1 − p , 1 − p ) if a = n o t f with p.f. p : : f , ( 1 , 1 ) otherwise. w_m(a) =
\begin{cases}
(p,p) & \text{if } a = f \text{ with p.f. } p :: f, \\
(1-p,1-p) & \text{if } a = \mathop{\mathrm{not}} f \text{ with p.f. } p :: f, \\
(1,1) & \text{otherwise.}
\end{cases} w m ( a ) = ⎩ ⎨ ⎧ ( p , p ) ( 1 − p , 1 − p ) ( 1 , 1 ) if a = f with p.f. p :: f , if a = not f with p.f. p :: f , otherwise.
where p.f. stands for probabilistic fact.
Theorem 14 R i \mathcal{R}^{i} R i is commutative.
Proof To prove that R i \mathcal{R}^{i} R i is commutative, we have to show that both ⊕ \oplus ⊕ and ⊗ \otimes ⊗ are commutative. Let a = ( a 0 , a 1 , a 2 ) a=(a_0,a_1,a_2) a = ( a 0 , a 1 , a 2 ) and b = ( b 0 , b 1 , b 2 ) b=(b_0,b_1,b_2) b = ( b 0 , b 1 , b 2 ) be arbitrary elements in N 3 \mathbb{N}^3 N 3 . For ⊕ \oplus ⊕ , we have to show that a ⊕ b = b ⊕ a a\oplus b=b\oplus a a ⊕ b = b ⊕ a . We have three cases: 1) ( a 0 < b 0 ) (a_0<b_0) ( a 0 < b 0 ) , 2) ( b 0 < a 0 ) (b_0<a_0) ( b 0 < a 0 ) , and 3) ( a 0 = b 0 ) (a_0=b_0) ( a 0 = b 0 ) . Cases 1) and 2) follow from the definition. For case 3) a ⊕ b = ( a 0 , a 1 + b 1 , a 2 + b 2 ) a\oplus b=(a_0,a_1+b_1,a_2+b_2) a ⊕ b = ( a 0 , a 1 + b 1 , a 2 + b 2 ) , b ⊕ a = ( b 0 , b 1 + a 1 , b 2 + a 2 ) b\oplus a=(b_0,b_1+a_1,b_2+a_2) b ⊕ a = ( b 0 , b 1 + a 1 , b 2 + a 2 ) , addition in N \mathbb{N} N is commutative, and a 0 = b 0 a_0=b_0 a 0 = b 0 , so the resulting tuples are identical.
For ⊗ \otimes ⊗ , we have to show, as before, that a ⊗ b = b ⊗ a a\otimes b=b\otimes a a ⊗ b = b ⊗ a . For a ⊗ b = ( a 0 + b 0 , a 1 ⋅ b 1 , a 2 ⋅ b 2 ) a\otimes b=(a_0+b_0,a_1\cdot b_1,a_2\cdot b_2) a ⊗ b = ( a 0 + b 0 , a 1 ⋅ b 1 , a 2 ⋅ b 2 ) and b ⊗ a = ( b 0 + a 0 , b 1 ⋅ a 1 , b 2 ⋅ a 2 ) b\otimes a=(b_0+a_0,b_1\cdot a_1,b_2\cdot a_2) b ⊗ a = ( b 0 + a 0 , b 1 ⋅ a 1 , b 2 ⋅ a 2 ) . Addition and multiplication on N \mathbb{N} N are commutative, thus a ⊗ b = b ⊗ a a\otimes b=b\otimes a a ⊗ b = b ⊗ a . □
Theorem 15 R o \mathcal{R}^{o} R o is commutative.
Proof This is trivial, as it is a duplication of the probability semiring [49 ] , which is commutative. □
We now prove that the transformation function f i o f_{io} f i o is a monoid homomorphism between the inner and outer semiring. This is crucial to ensure an efficient implementation (see [48 ] ).
Definition 7 (Monoid Homomorphism) Given two monoids M 0 = ( D 0 , ⊗ 0 , e 0 ) \mathcal{M}_0=(D_0,\otimes_0,e_0) M 0 = ( D 0 , ⊗ 0 , e 0 ) M 1 = ( D 1 , ⊗ 1 , e 1 ) \mathcal{M}_1=(D_1,\otimes_1,e_1) M 1 = ( D 1 , ⊗ 1 , e 1 ) and where, for i ∈ { 0 , 1 } i\in\{0,1\} i ∈ { 0 , 1 } , D i D_i D i are the domains, ⊗ i \otimes_i ⊗ i are binary operations with neutral elements e i e_i e i , a function f : M 0 → M 1 f:\mathcal{M}_0\to\mathcal{M}_1 f : M 0 → M 1 is a monoid homomorphism if ∀ m a , m b ∈ D 0 \forall m_a,m_b\in D_0 ∀ m a , m b ∈ D 0 , 1) f ( e 0 ) = e 1 f(e_0)=e_1 f ( e 0 ) = e 1 and 2) f ( m a ⊗ 0 m b ) = f ( m a ) ⊗ 1 f ( m b ) f(m_a\otimes_0m_b)=f(m_a)\otimes_1f(m_b) f ( m a ⊗ 0 m b ) = f ( m a ) ⊗ 1 f ( m b ) .
Theorem 16 f i o f_{io} f i o is a monoid homomorphism between M i = ( N 0 3 , ⊗ , ( 0 , 1 , 1 ) ) \mathcal{M}^{i}=(\mathbb{N}^3_0,\otimes,(0,1,1)) M i = ( N 0 3 , ⊗ , ( 0 , 1 , 1 )) (obtained from R i \mathcal{R}^{i} R i ) and M o = ( [ 0 , 1 ] 2 , ⋅ , ( 1 , 1 ) ) \mathcal{M}^{o}=([0,1]^2,\cdot,(1,1)) M o = ([ 0 , 1 ] 2 , ⋅ , ( 1 , 1 )) (obtained from R o \mathcal{R}^{o} R o )
Proof We have to prove that 1) f i o ( ( 0 , 1 , 1 ) ) = ( 1 , 1 ) f_{io}((0,1,1))=(1,1) f i o (( 0 , 1 , 1 )) = ( 1 , 1 ) and 2) ∀ m 1 , m 2 ∈ M i \forall m_1,m_2\in\mathcal{M}^{i} ∀ m 1 , m 2 ∈ M i , f i o ( m 1 ⊗ m 2 ) = f i o ( m 1 ) ⋅ f i o ( m 2 ) f_{io}(m_1\otimes m_2)=f_{io}(m_1)\cdot f_{io}(m_2) f i o ( m 1 ⊗ m 2 ) = f i o ( m 1 ) ⋅ f i o ( m 2 ) . For 1) we are in the case of n 1 = n 2 = 1 > 0 n_1=n_2=1>0 n 1 = n 2 = 1 > 0 , thus, f i o ( ( 0 , 1 , 1 ) ) = ( 1 , 1 ) f_{io}((0,1,1))=(1,1) f i o (( 0 , 1 , 1 )) = ( 1 , 1 ) by definition. For 2) we have to consider three possible cases.
Case 1, where m 1 = ( a , 0 , 0 ) m_1=(a,0,0) m 1 = ( a , 0 , 0 ) and m 2 = ( b , 0 , 0 ) m_2=(b,0,0) m 2 = ( b , 0 , 0 ) . Then m 1 ⊗ m 2 = ( a + b , 0 , 0 ) m_1\otimes m_2=(a+b,0,0) m 1 ⊗ m 2 = ( a + b , 0 , 0 ) . f i o ( ( a + b , 0 , 0 ) ) = ( 0 , 0 ) f_{io}((a+b,0,0))=(0,0) f i o (( a + b , 0 , 0 )) = ( 0 , 0 ) . In the other direction, f i o ( ( a , 0 , 0 ) ) = ( 0 , 0 ) f_{io}((a,0,0))=(0,0) f i o (( a , 0 , 0 )) = ( 0 , 0 ) , f i o ( ( b , 0 , 0 ) ) = ( 0 , 0 ) f_{io}((b,0,0))=(0,0) f i o (( b , 0 , 0 )) = ( 0 , 0 ) , ( 0 , 0 ) ⋅ ( 0 , 0 ) = ( 0 , 0 ) (0,0)\cdot(0,0)=(0,0) ( 0 , 0 ) ⋅ ( 0 , 0 ) = ( 0 , 0 ) , and the two results match.
Case 2, where m 1 = ( a , v 1 , v 1 ) m_1=(a,v_1,v_1) m 1 = ( a , v 1 , v 1 ) and m 2 = ( b , v 2 , v 2 ) m_2=(b,v_2,v_2) m 2 = ( b , v 2 , v 2 ) with v 1 , v 2 > 0 v_1,v_2>0 v 1 , v 2 > 0 . Then m 1 ⊗ m 2 = ( a + b , v 1 ⋅ v 2 , v 1 ⋅ v 2 ) m_1\otimes m_2=(a+b,v_1\cdot v_2,v_1\cdot v_2) m 1 ⊗ m 2 = ( a + b , v 1 ⋅ v 2 , v 1 ⋅ v 2 ) , and f i o ( m 1 ⊗ m 2 ) = ( 1 , 1 ) f_{io}(m_1\otimes m_2)=(1,1) f i o ( m 1 ⊗ m 2 ) = ( 1 , 1 ) as the last two elements are equal and
> 0 > 0 > 0 . In the other direction, f i o ( m 1 ) = ( 1 , 1 ) f_{io}(m_1) = (1, 1) f i o ( m 1 ) = ( 1 , 1 ) and f i o ( m 2 ) = ( 1 , 1 ) f_{io}(m_2) = (1, 1) f i o ( m 2 ) = ( 1 , 1 ) , so ( 1 , 1 ) ⋅ ( 1 , 1 ) = ( 1 , 1 ) (1, 1) \cdot(1, 1) = (1, 1) ( 1 , 1 ) ⋅ ( 1 , 1 ) = ( 1 , 1 ) , and the two results match.
Case 3, where m 1 = ( a , v 1 , v 2 ) m_1 = (a, v_1, v_2) m 1 = ( a , v 1 , v 2 ) with 0 < v 1 < v 2 0 < v_1 < v_2 0 < v 1 < v 2 and m 2 = ( b , v 3 , v 4 ) m_2 = (b, v_3, v_4) m 2 = ( b , v 3 , v 4 ) with 0 < v 3 < v 4 0 < v_3 < v_4 0 < v 3 < v 4 . Then m 1 ⊗ m 2 = ( a + b , v 1 ⋅ v 3 , v 2 ⋅ v 4 ) m_1 \otimes m_2 = (a+b, v_1 \cdot v_3, v_2 \cdot v_4) m 1 ⊗ m 2 = ( a + b , v 1 ⋅ v 3 , v 2 ⋅ v 4 ) . Note that v 1 ⋅ v 3 < v 2 ⋅ v 4 v_1 \cdot v_3 < v_2 \cdot v_4 v 1 ⋅ v 3 < v 2 ⋅ v 4 so f i o ( m 1 ⊗ m 2 ) = ( 0 , 1 ) f_{io}(m_1 \otimes m_2) = (0, 1) f i o ( m 1 ⊗ m 2 ) = ( 0 , 1 ) . In the other direction, f i o ( m 1 ) = ( 0 , 1 ) f_{io}(m_1) = (0, 1) f i o ( m 1 ) = ( 0 , 1 ) and f i o ( m 2 ) = ( 0 , 1 ) f_{io}(m_2) = (0, 1) f i o ( m 2 ) = ( 0 , 1 ) , so ( 0 , 1 ) ⋅ ( 0 , 1 ) = ( 0 , 1 ) (0, 1) \cdot(0, 1) = (0, 1) ( 0 , 1 ) ⋅ ( 0 , 1 ) = ( 0 , 1 ) , and the two results match. The other case where, for either m 1 m_1 m 1 or m 2 m_2 m 2 , both the second and third elements of the tuple are equal can be similarly proven.
Example 4
Consider Example 3 and query q q q . Here, in the innermost layer we consider the atoms { q , n q , q r } \{q, nq, qr\} { q , n q , q r } while in the outermost { a , b } \{a, b\} { a , b } . Assume we fix the atom b b b in the outermost layer. For clarity, assume q r qr q r has cost 2.
We have two answer sets: A 0 = { q } A_0 = \{q\} A 0 = { q } and A 1 = { n q , q r } A_1 = \{nq, qr\} A 1 = { n q , q r } . For A 0 A_0 A 0 , the atom q q q is associated with the tuple ( 0 , 1 , 1 ) (0, 1, 1) ( 0 , 1 , 1 ) . For A 1 A_1 A 1 , the atom n q nq n q is associated with the tuple ( 0 , 1 , 1 ) (0, 1, 1) ( 0 , 1 , 1 ) and the atom q r qr q r is associated with the tuple ( 2 , 1 , 1 ) (2, 1, 1) ( 2 , 1 , 1 ) . Furthermore, there is an additional tuple to consider, ( 0 , 0 , 1 ) (0, 0, 1) ( 0 , 0 , 1 ) , as the query is false (we do not explicitly include such an atom in the answer sets). Overall, we have ( 0 , 1 , 1 ) ⊗ ( 2 , 1 , 1 ) ⊗ ( 0 , 0 , 1 ) = ( 2 , 0 , 1 ) (0, 1, 1) \otimes(2, 1, 1) \otimes(0, 0, 1) = (2, 0, 1) ( 0 , 1 , 1 ) ⊗ ( 2 , 1 , 1 ) ⊗ ( 0 , 0 , 1 ) = ( 2 , 0 , 1 ) . Then, ( 0 , 1 , 1 ) ⊕ ( 2 , 0 , 1 ) = ( 0 , 1 , 1 ) (0, 1, 1) \oplus(2, 0, 1) = (0, 1, 1) ( 0 , 1 , 1 ) ⊕ ( 2 , 0 , 1 ) = ( 0 , 1 , 1 ) as 1 < 2 1 < 2 1 < 2 (the first element of the tuple). After applying the transformation function, we get f ( ( 0 , 1 , 1 ) ) = ( 1 , 1 ) f((0, 1, 1)) = (1, 1) f (( 0 , 1 , 1 )) = ( 1 , 1 ) , as the second element of the tuple (which counts the number of answer sets with the query true) is 1. In the outer layer, we have ( 0.3 , 0.3 ) ⋅ ( 0.8 , 0.8 ) ⋅ ( 0 , 0 ) = ( 1 , 1 ) (0.3, 0.3) \cdot(0.8, 0.8) \cdot(0, 0) = (1, 1) ( 0.3 , 0.3 ) ⋅ ( 0.8 , 0.8 ) ⋅ ( 0 , 0 ) = ( 1 , 1 ) , so a contribution of 0.24 to both the lower and upper probability.
Similarly, If we consider the atom a a a in the outermost layer, we have only one answer set { a , q } \{a, q\} { a , q } whose atoms are both associated with the tuple ( 0 , 1 , 1 ) (0, 1, 1) ( 0 , 1 , 1 ) . Then, ( 0 , 1 , 1 ) ⊗ ( 0 , 1 , 1 ) = ( 0 , 1 , 1 ) (0, 1, 1) \otimes(0, 1, 1) = (0, 1, 1) ( 0 , 1 , 1 ) ⊗ ( 0 , 1 , 1 ) = ( 0 , 1 , 1 ) . We apply the transformation function on this and get f i o ( ( 0 , 1 , 1 ) ) = ( 1 , 1 ) f_{io}((0, 1, 1)) = (1, 1) f i o (( 0 , 1 , 1 )) = ( 1 , 1 ) . In the outer layer, we have ( 0.7 , 0.7 ) ⊗ ( 0.2 , 0.2 ) ⊗ ( 1 , 1 ) = ( 0.14 , 0.14 ) (0.7, 0.7) \otimes(0.2, 0.2) \otimes(1, 1) = (0.14, 0.14) ( 0.7 , 0.7 ) ⊗ ( 0.2 , 0.2 ) ⊗ ( 1 , 1 ) = ( 0.14 , 0.14 ) so a contribution to both the lower and upper probability. The considerations for the two remaining selections are analogous.
Encoding MPE as a 2AMC Task
The 2AMC encoding can be obtained with minimal modifications from the 2AMC encoding for inference. In particular, we can still consider the same inner layer and transformation function. For the outer layer, instead, we need to consider
as semiring, R o M P E = ( R 2 × 2 ∣ F ∣ 2 , m a x 4 , t i m e s 4 , ( 0 , 0 , F , F ) , ( 1 , 1 , { } , { } ) ) \mathcal{R}^{MPE}_{o} = (\mathbb{R}^{2} \times2^{|\mathcal{F}|^{2}}, max^{4}, times^{4}, (0, 0, \mathcal{F}, \mathcal{F}), (1, 1, \{\}, \{\})) R o M P E = ( R 2 × 2 ∣ F ∣ 2 , ma x 4 , t im e s 4 , ( 0 , 0 , F , F ) , ( 1 , 1 , { } , { })) ;
as variables F \mathcal{F} F ;
as weight function:
w m ( a ) = { ( p , p , { a } , { a } ) if a = f with p : : f ( 1 − p , 1 − p , { } , { } ) if a = not f with p : : f ( 1 , 1 , { } , { } ) otherwise w_m(a) =
\begin{cases}
(p,p,\{a\},\{a\}) & \text{if } a=f \text{ with } p::f \\
(1-p,1-p,\{\},\{\}) & \text{if } a=\operatorname{not}\ f \text{ with } p::f \\
(1,1,\{\},\{\}) & \text{otherwise}
\end{cases} w m ( a ) = ⎩ ⎨ ⎧ ( p , p , { a } , { a }) ( 1 − p , 1 − p , { } , { }) ( 1 , 1 , { } , { }) if a = f with p :: f if a = not f with p :: f otherwise
where m a x 4 ( ( x 0 , x 1 , R 0 , R 1 ) , ( y 0 , y 1 , S 0 , S 1 ) ) = ( z 0 , z 1 , T 0 , T 1 ) max^{4}((x_0,x_1,R_0,R_1),(y_0,y_1,S_0,S_1)) = (z_0,z_1,T_0,T_1) ma x 4 (( x 0 , x 1 , R 0 , R 1 ) , ( y 0 , y 1 , S 0 , S 1 )) = ( z 0 , z 1 , T 0 , T 1 ) with
if x 0 > y 0 x_0 > y_0 x 0 > y 0 , z 0 = x 0 z_0 = x_0 z 0 = x 0 ; else z 0 = y 0 z_0 = y_0 z 0 = y 0 ;
if x 1 > y 1 x_1 > y_1 x 1 > y 1 , z 1 = x 1 z_1 = x_1 z 1 = x 1 ; else z 1 = y 1 z_1 = y_1 z 1 = y 1 ;
if x 0 > y 0 x_0 > y_0 x 0 > y 0 , T 0 = R 0 T_0 = R_0 T 0 = R 0 ; else if x 0 < y 0 x_0 < y_0 x 0 < y 0 , T 0 = S 0 T_0 = S_0 T 0 = S 0 ; else (if x 0 = y 0 x_0 = y_0 x 0 = y 0 ), T 0 = min > ( R 0 , S 0 ) T_0 = \min_{>}(R_0, S_0) T 0 = min > ( R 0 , S 0 ) , where > > > fixes a total order on 2 ∣ F ∣ 2^{|\mathcal{F}|} 2 ∣ F ∣ ;
if x 1 > y 1 x_1 > y_1 x 1 > y 1 , T 1 = R 1 T_1 = R_1 T 1 = R 1 ; else if x 1 < y 1 x_1 < y_1 x 1 < y 1 , T 1 = S 1 T_1 = S_1 T 1 = S 1 ; else (if x 1 = y 1 x_1 = y_1 x 1 = y 1 ), T 1 = min > ( R 1 , S 1 ) T_1 = \min_{>}(R_1, S_1) T 1 = min > ( R 1 , S 1 ) , where > > > fixes a total order on 2 ∣ F ∣ 2^{|\mathcal{F}|} 2 ∣ F ∣ ;
and t i m e s 4 ( ( x 0 , x 1 , R 0 , R 1 ) , ( y 0 , y 1 , S 0 , S 1 ) ) = ( x 0 ⋅ y 0 , x 1 ⋅ y 1 , R 0 ∪ S 0 , R 1 ∪ S 1 ) times^{4}((x_0,x_1,R_0,R_1),(y_0,y_1,S_0,S_1)) = (x_0 \cdot y_0, x_1 \cdot y_1, R_0 \cup S_0, R_1 \cup S_1) t im e s 4 (( x 0 , x 1 , R 0 , R 1 ) , ( y 0 , y 1 , S 0 , S 1 )) = ( x 0 ⋅ y 0 , x 1 ⋅ y 1 , R 0 ∪ S 0 , R 1 ∪ S 1 ) . The first two components store, respectively, the value associated with the lower and upper MPE states, while the last two components store the facts selected for such states.
Theorem 17. R o M P E \mathcal{R}_{o}^{\mathrm{MPE}} R o MPE is commutative.
Proof. As before, we have to prove that both m a x max ma x and t i m e s times t im es are commutative. The proof for t i m e s times t im es is easy, as both multiplication and union of sets is commutative. The proof for m a x max ma x follows a similar path. This is possible thanks to the total order on the sets of atoms that allows writing min > ( S x , S y ) = min > ( S y , S x ) \min_{>}(S_x,S_y) = \min_{>}(S_y,S_x) min > ( S x , S y ) = min > ( S y , S x ) , ensuring commutativity.
Encoding MPE as an ASP(Q) Program
ASP(Q) supports weak constraints (both within each subprogram and on the whole ASP(Q)) to define preferences over quantified answer sets, so it is a natural candidate for modelling MPE in optimal PASP, given its promising results in solving the same task for plain PASP [12 ] .
As shown in the proofs of Theorem 7 and 8, the brave and cautious MPE problems can be framed as ASP(Q) having two quantifiers: the first guesses a selection of probabilistic facts, while the second searches over the optimal answer sets of the corresponding world for a set that satisfies or not a given query. In this way, each quantified answer set corresponds to a candidate MPE state. Then, by expressing preferences among quantified answer sets by means of global weak constraints, we can select as optimal quantified answer set the candidate MPE state with the maximum probability, thus obtaining a valid MPE state. This idea is formalized in the following definition.
Definition 8. Let P ∼ \mathcal{P}^{\sim} P ∼ be an optimal PASP of the form ( T , F , W ) (\mathcal{T},\mathcal{F},\mathcal{W}) ( T , F , W ) and q q q be an atom then:
ASP Q ‾ ( P ∼ ) is an ASP(Q) of the form ∃ s t P 1 ∃ s t P 2 : C : C ω ; \overline{\operatorname{ASP}_{Q}}(\mathcal{P}^{\sim}) \text{ is an ASP(Q) of the form } \exists^{st}P_1\exists^{st}P_2 : C : C^{\omega}; ASP Q ( P ∼ ) is an ASP(Q) of the form ∃ s t P 1 ∃ s t P 2 : C : C ω ; ASP Q ‾ ( P ∼ ) is an ASP(Q) of the form ∃ s t P 1 ∀ s t P 2 : C : C ω ; \overline{\operatorname{ASP}_{Q}}(\mathcal{P}^{\sim}) \text{ is an ASP(Q) of the form } \exists^{st}P_1\forall^{st}P_2 : C : C^{\omega}; ASP Q ( P ∼ ) is an ASP(Q) of the form ∃ s t P 1 ∀ s t P 2 : C : C ω ; where P 1 = { a ; n a ∣ p : : a ∈ F } P_1 = \{a; na \mid p :: a \in\mathcal{F}\} P 1 = { a ; na ∣ p :: a ∈ F } , P 2 = T P_2 = \mathcal{T} P 2 = T , C = { : − n o t q } C = \{ :-\ \mathop{\mathrm{not}} q\} C = { : − not q } and C ω C^{\omega} C ω is of the form:
C ω = { : ∼ a [ − log ( p ) @ 1 , a ] ∀ p : : a ∈ F : ∼ n a [ − log ( 1 − p ) @ 1 , a ] ∀ p : : a ∈ F C^{\omega} =
\left\{
\begin{aligned}
&:\sim a\ [-\log(p)@1,a] && \forall p :: a \in\mathcal{F}\\
&:\sim na\ [-\log(1-p)@1,a] && \forall p :: a \in\mathcal{F}
\end{aligned}
\right. C ω = { :∼ a [ − log ( p ) @1 , a ] :∼ na [ − log ( 1 − p ) @1 , a ] ∀ p :: a ∈ F ∀ p :: a ∈ F with n a na na being fresh atoms not appearing anywhere else.
To illustrate the ASP(Q) encoding, we consider the Optimal Reviewer Assignment problem from § 4 .
Brave MPE. Suppose we want to compute the brave MPE for the query l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o . Starting from the optimal PASP presented in Section 4, namely P ∼ \mathcal{P}^{\sim} P ∼ , and applying Definition 8, A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) is of the form ∃ s t P 1 ∃ s t P 2 : C : C ω \exists^{st} P_1\exists^{st} P_2 : C : C^{\omega} ∃ s t P 1 ∃ s t P 2 : C : C ω shown below:
%@exists P₁
reviewer(r1);no_reviewer(r1). reviewer(r2);no_reviewer(r2).
reviewer(r3);no_reviewer(r3). reviewer(r4);no_reviewer(r4).
%@exists P₂
paper(p1). paper(p2).
willing(R,P):- reviewer(R), paper(P).
assign(R,P) :- willing(R,P), not skip(R,P).
skip(R,P) :- willing(R,P), not assign(R,P).
reviewed(P):- assign(R,P).
load(R,2):- assign(R,P1), assign(R,P2), P1!=P2.
load(R,1):- assign(R,P), not load(R,2).
load(R,0):- reviewer(R), not load(R,1), not load(R,2).
less_than_two :- load(R,C), C < 2.
delta(R0,R1,D):- load(R0,L0), load(R1,L1), R0 != R1, L0<=L1, D=L1-L0.
:∼ assign(R1,P), assign(R2,P), assign(R3,P), R1!=R2, R1!=R3, R2!=R3. [1@2,P]
:∼ paper(P), not reviewed(P). [1@1,P]
:∼ delta(R0,R1,D). [D@0,R0,R1]
%@constraint C
:- not less_than_two.
%@global Cω
:∼ reviewer(r1). [-log(0.8)@1,r1]
:∼ reviewer(r2). [-log(0.1)@1,r2]
:∼ reviewer(r3). [-log(0.7)@1,r3]
:∼ reviewer(r4). [-log(0.2)@1,r4]
:∼ no_reviewer(r1). [-log(0.2)@1,r1]
:∼ no_reviewer(r2). [-log(0.9)@1,r2]
:∼ no_reviewer(r3). [-log(0.3)@1,r3]
:∼ no_reviewer(r4). [-log(0.8)@1,r4]
Listing 1: Brave MPE in ASP(Q).
According to the coherence of ASP(Q), a quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) is an optimal answer set of P 1 P_1 P 1 (i.e., M 1 ∈ A S ∗ ( P 1 ) M_1 \in AS^*(P_1) M 1 ∈ A S ∗ ( P 1 ) ) such that by fixing it in the following program, then remaining ASP(Q) is coherent (i.e., ∃ s t P 2 ∪ f i x P 1 ( M 1 ) : C : C ω \exists^{st} P_2 \cup fix_{P_1}(M_1) : C : C^{\omega} ∃ s t P 2 ∪ f i x P 1 ( M 1 ) : C : C ω is coherent). The program P 1 P_1 P 1 contains no weak constraints, so each answer set is also optimal. Specifically, an answer set of P 1 P_1 P 1 corresponds to a possible selection of probabilistic facts (i.e., 0.8 : : r e v i e w e r ( r 1 ) 0.8 :: reviewer(r1) 0.8 :: r e v i e w er ( r 1 ) , 0.1 : : r e v i e w e r ( r 2 ) 0.1 :: reviewer(r2) 0.1 :: r e v i e w er ( r 2 ) , 0.7 : : r e v i e w e r ( r 3 ) 0.7 :: reviewer(r3) 0.7 :: r e v i e w er ( r 3 ) , and 0.2 : : r e v i e w e r ( r 4 ) 0.2 :: reviewer(r4) 0.2 :: r e v i e w er ( r 4 ) ) as each rule of the form r e v i e w e r ( r ) ; n o _ r e v i e w e r ( r ) reviewer(r); no\_reviewer(r) r e v i e w er ( r ) ; n o _ r e v i e w er ( r ) either selects r r r as reviewer or not. Let us first consider the empty selection of reviewers and so M 1 = { n o _ r e v i e w e r ( r 1 ) , n o _ r e v i e w e r ( r 2 ) , n o _ r e v i e w e r ( r 3 ) , n o _ r e v i e w e r ( r 4 ) } ∈ A S ∗ ( P 1 ) M_1 = \{no\_reviewer(r_1), no\_reviewer(r_2), no\_reviewer(r_3), no\_reviewer(r_4)\} \in AS^*(P_1) M 1 = { n o _ r e v i e w er ( r 1 ) , n o _ r e v i e w er ( r 2 ) , n o _ r e v i e w er ( r 3 ) , n o _ r e v i e w er ( r 4 )} ∈ A S ∗ ( P 1 ) . We need to verify the coherence of ∃ s t P 2 ∪ f i x P 1 ( M 1 ) : C : C ω \exists^{st} P_2 \cup fix_{P_1}(M_1) : C : C^{\omega} ∃ s t P 2 ∪ f i x P 1 ( M 1 ) : C : C ω . We can observe that, since no reviewer is fixed by M 1 M_1 M 1 , then no paper can be assigned, and so the only optimal answer set is M 2 = M 1 ∪ { p a p e r ( p 1 ) , p a p e r ( p 2 ) } M_2 = M_1 \cup\{paper(p1), paper(p2)\} M 2 = M 1 ∪ { p a p er ( p 1 ) , p a p er ( p 2 )} . Thus, the query l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o is false in M 2 M_2 M 2 and so M 2 M_2 M 2 is such that the program C C C is incoherent. Since M 2 M_2 M 2 is the only optimal answer set of P 2 ∪ f i x P 1 ( M 1 ) P_2 \cup fix_{P_1}(M_1) P 2 ∪ f i x P 1 ( M 1 ) , then M 1 M_1 M 1 cannot be a quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) . Let us move on to another selection, for instance the one in which the reviewers r 1 r_1 r 1 and r 2 r_2 r 2 accept to serve as a reviewer and so M 1 = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 2 ) , n o _ r e v i e w e r ( r 3 ) , n o _ r e v i e w e r ( r 4 ) } M_1 = \{reviewer(r_1), reviewer(r_2), no\_reviewer(r_3), no\_reviewer(r_4)\} M 1 = { r e v i e w er ( r 1 ) , r e v i e w er ( r 2 ) , n o _ r e v i e w er ( r 3 ) , n o _ r e v i e w er ( r 4 )} . In this case, if we fix M 1 M_1 M 1 in the program P 2 P_2 P 2 (so we consider optimal answer set of P 2 ∪ f i x P 1 ( M 1 ) P_2 \cup fix_{P_1}(M_1) P 2 ∪ f i x P 1 ( M 1 ) ), then we have three optimal answer sets, namely M 2 1 M_2^1 M 2 1 , M 2 2 M_2^2 M 2 2 , and M 2 3 M_2^3 M 2 3 , where:
M 2 1 M_2^1 M 2 1 is such that both papers are assigned to both reviewers;
M 2 2 M_2^2 M 2 2 is such that paper p 1 p1 p 1 (resp. p 2 p2 p 2 ) is assigned to reviewer r 1 r1 r 1 (resp. p 2 p2 p 2 ); and
M 2 3 M_2^3 M 2 3 is such that paper p 1 p1 p 1 (resp. p 2 p2 p 2 ) is assigned to reviewer r 2 r2 r 2 (resp. p 1 p1 p 1 ).
All the papers are covered (i.e., weak constraints at level 1 do not fire) and each reviewer has the same number of papers (i.e., weak constraints at level 0 do not fire either). For M 2 1 M_2^1 M 2 1 we can note that each reviewer has two papers assigned, and so l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o is false in M 2 1 M_2^1 M 2 1 . Here M 2 1 M_2^1 M 2 1 makes the program C C C incoherent and so it cannot be used to prove that M 1 M_1 M 1 is a quantified answer set. Conversely, for M 2 2 M_2^2 M 2 2 (resp. M 2 3 M_2^3 M 2 3 ) both reviewers have less than two paper assigned, and so l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o is true in M 2 2 M_2^2 M 2 2 (resp. M 2 3 M_2^3 M 2 3 ). Thus, M 2 2 M_2^2 M 2 2 is an optimal answer set of P 2 ∪ f i x P 1 ( M 1 ) P_2 \cup fix_{P_1}(M_1) P 2 ∪ f i x P 1 ( M 1 ) that satisfies the constraint in C C C and so M 1 M_1 M 1 is quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) .
Global weak constraints assign a cost to M 1 M_1 M 1 according to whether the reviewers accepted or not. Since r e v i e w e r ( r 1 ) reviewer(r_1) r e v i e w er ( r 1 ) and r e v i e w e r ( r 2 ) reviewer(r_2) r e v i e w er ( r 2 ) are true in M 1 M_1 M 1 , whereas r e v i e w e r ( r 3 ) reviewer(r_3) r e v i e w er ( r 3 ) and r e v i e w e r ( r 4 ) reviewer(r_4) r e v i e w er ( r 4 ) are false in M 1 M_1 M 1 , then the corresponding weak constraints fires, and so the cost of M 1 M_1 M 1 is − log ( 0.8 ) − log ( 0.1 ) − log ( 0.3 ) − log ( 0.8 ) = − log ( P ( σ ) ) -\log(0.8)-\log(0.1)-\log(0.3)-\log(0.8)=-\log(P(\sigma)) − log ( 0.8 ) − log ( 0.1 ) − log ( 0.3 ) − log ( 0.8 ) = − log ( P ( σ )) , with σ = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 2 ) } \sigma=\{reviewer(r_1),reviewer(r_2)\} σ = { r e v i e w er ( r 1 ) , r e v i e w er ( r 2 )} . At the same time, we can observe that w σ w_\sigma w σ admits an optimal answer set where paper p 1 p1 p 1 is assigned to reviewer r 1 r1 r 1 and p 2 p2 p 2 is assigned to reviewer r 2 r2 r 2 and so the query l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o is bravely entailed. At this point σ \sigma σ is a brave MPE state if its probability P ( σ ) P(\sigma) P ( σ ) is maximal. Since the cost of M 1 M_1 M 1 is equal to − log ( P ( σ ) ) -\log(P(\sigma)) − log ( P ( σ )) and optimal quantified answer sets are those quantified answer sets with the minimum cost, then optimal quantified answer sets are those who maximize the probability of the corresponding selection. More precisely, an optimal quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) is M 1 ∗ = { r e v i e w e r ( r 1 ) , n o _ r e v i e w e r ( r 2 ) , r e v i e w e r ( r 3 ) , n o _ r e v i e w e r ( r 4 ) } M_1^*=\{reviewer(r_1),no\_reviewer(r_2),reviewer(r_3),no\_reviewer(r_4)\} M 1 ∗ = { r e v i e w er ( r 1 ) , n o _ r e v i e w er ( r 2 ) , r e v i e w er ( r 3 ) , n o _ r e v i e w er ( r 4 )} , which corresponds to the brave MPE state σ = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 3 ) } \sigma=\{reviewer(r_1),reviewer(r_3)\} σ = { r e v i e w er ( r 1 ) , r e v i e w er ( r 3 )} .
Cautious MPE. Cautious MPE states can be computed in a similar fashion by computing optimal quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) . Thus, let us assume that we want to compute cautious MPE for l e s s _ t h a n _ t w o less\_than\_two l ess _ t han _ tw o , then in this case A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) is of the form ∃ s t P 1 ∀ s t P 2 : C : C ω \exists^{st}P_1\forall^{st}P_2:C:C^{\omega} ∃ s t P 1 ∀ s t P 2 : C : C ω where P 1 P_1 P 1 , P 2 P_2 P 2 , C C C , and C ω C^{\omega} C ω are the same as in Listing 1. Let us now compute a quantified answer set of A S P Q ( P ∼ ) ASPQ(\mathcal{P}^{\sim}) A S P Q ( P ∼ ) . Consider M 1 = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 2 ) , n o _ r e v i e w e r ( r 3 ) , n o _ r e v i e w e r ( r 4 ) } ∈ A S ( P 1 ) M_1=\{reviewer(r_1),reviewer(r_2),no\_reviewer(r_3),no\_reviewer(r_4)\}\in AS(P_1) M 1 = { r e v i e w er ( r 1 ) , r e v i e w er ( r 2 ) , n o _ r e v i e w er ( r 3 ) , n o _ r e v i e w er ( r 4 )} ∈ A S ( P 1 ) . From the previous example, we know that by fixing M 1 M_1 M 1 in the program P 2 P_2 P 2 (so we consider optimal answer set of P 2 ∪ f i x P 1 ( M 1 ) P_2\cup fix_{P_1}(M_1) P 2 ∪ f i x P 1 ( M 1 ) ), we obtain three optimal answer sets, namely M 2 1 M_2^1 M 2 1 , M 2 2 M_2^2 M 2 2 , and M 2 3 M_2^3 M 2 3 , where:
M 2 2 M_2^2 M 2 2 is such that paper p 1 p1 p 1 (resp. p 2 p2 p 2 ) is assigned to reviewer r 1 r1 r 1 (resp. p 2 p2 p 2 ); and
M 2 3 M_2^3 M 2 3 is such that paper p 1 p1 p 1 (resp. p 2 p2 p 2 ) is assigned to reviewer r 2 r2 r 2 (resp. p 1 p1 p 1 ).
In this case, program P 2 P_2 P 2 is universally quantified, and therefore the constraint program C C C must be coherent for every answer set M 2 i M_2^i M 2 i , with 1 ≤ i ≤ 3 1 \leq i \leq3 1 ≤ i ≤ 3 . This condition is not satisfied, as M 2 1 M_2^1 M 2 1 assigns all papers (i.e., p 1 p1 p 1 and p 2 p2 p 2 ) to all selected reviewers (i.e., r 1 r1 r 1 and r 2 r2 r 2 ), thereby violating C C C . Hence, M 2 1 M_2^1 M 2 1 makes C C C incoherent, and consequently M 1 M_1 M 1 is not a quantified answer set of A S P Q ( P ∼ ) \mathit{ASPQ}(P^{\sim}) ASPQ ( P ∼ ) .
Conversely, consider the following answer set of P 1 P_1 P 1
M 1 = { r e v i e w e r ( r 1 ) , n o _ r e v i e w e r ( r 2 ) , r e v i e w e r ( r 3 ) , r e v i e w e r ( r 4 ) } M_1 = \{reviewer(r1), no\_reviewer(r2), reviewer(r3), reviewer(r4)\} M 1 = { r e v i e w er ( r 1 ) , n o _ r e v i e w er ( r 2 ) , r e v i e w er ( r 3 ) , r e v i e w er ( r 4 )}
corresponding to the selection of reviewers r 1 r1 r 1 , r 3 r3 r 3 , and r 4 r4 r 4 . By fixing M 1 M_1 M 1 in P 2 P_2 P 2 , we obtain six optimal answer set, each assigning one paper to two of the selected reviewers and the other paper to the remaining reviewer. In all these cases, each reviewer is assigned exactly one paper, and thus every optimal answer set satisfies the constraint program C C C . Therefore, M 1 M_1 M 1 is a quantified answer set of A S P Q ( P ∼ ) \mathit{ASPQ}(P^{\sim}) ASPQ ( P ∼ ) , and the corresponding selection of reviewers represents a candidate cautious MPE state.
Finally, global weak constraints, also in this case, assign a cost to M 1 M_1 M 1 corresponding to the negative logarithm of the probability of the corresponding selection σ = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 3 ) , r e v i e w e r ( r 4 ) } \sigma= \{reviewer(r1), reviewer(r3), reviewer(r4)\} σ = { r e v i e w er ( r 1 ) , r e v i e w er ( r 3 ) , r e v i e w er ( r 4 )} , namely − log ( 0.8 ) − log ( 0.9 ) − log ( 0.7 ) − log ( 0.2 ) = − log ( P ( σ ) ) -\log(0.8) - \log(0.9) - \log(0.7) - \log(0.2) = -\log(P(\sigma)) − log ( 0.8 ) − log ( 0.9 ) − log ( 0.7 ) − log ( 0.2 ) = − log ( P ( σ )) . Since no better quantified answer set exists, M 1 M_1 M 1 is also optimal. Note that optimal quantified answer sets are obtained by minimizing the cost associated with quantified answer sets and so we are indeed maximizing the log probability of the corresponding selection, and so σ = { r e v i e w e r ( r 1 ) , r e v i e w e r ( r 3 ) , r e v i e w e r ( r 4 ) } \sigma= \{reviewer(r1), reviewer(r3), reviewer(r4)\} σ = { r e v i e w er ( r 1 ) , r e v i e w er ( r 3 ) , r e v i e w er ( r 4 )} is a cautious MPE state.
Experimental Evaluation
Implementation. The proposed approaches for the inference and MPE problems in optPASP have been implemented on top of existing systems. More precisely, for the inference problem, we propose two implementations: one that leverages a knowledge-compilation ([27 ] ) based solver, namely aspmc ([37 ] ), and one based on enumeration. We call the approaches aspmc and enum, respectively. The aspmc tool allows us to specify only the structure of the required semirings, leaving all the remaining parts unchanged. In a nutshell, aspmc converts the input program into an arithmetic circuit, and then the probability of a query can be computed by traversing this graph and applying the corresponding semiring operations at every node. The probability values associated to probabilistic facts do not influence the execution time, as the size of the compiled programs depends only on the structure of the deterministic part. For the enumeration-based approach, we developed a tool which converts the input optPASP into an ASP and, for each possible selection (exponentially many), calls an ASP solver, namely clingo ([43 ] ) v 5.8.0, to compute the optimal answer sets. Whereas, for the MPE problem, we implemented the proposed encoding in ASP(Q) and then use the CASPER2 system [25 ] to evaluate the resulting programs.
Dataset Description. We performed an experimental evaluation on three different datasets, which extend the application scenarios discussed in § 4 . For the viral datasets (which models the viral marketing problem), we generate instances with an increasing number of people involved in the network. Here, the edges (representing friendship relations) are generated according to a Barabási Albert network structure (using the NetworkX library [45 ] with parameter n n n set to the number of people involved and m m m set to 2). For the paper dataset (which models the paper assignment problem) we generated instances by iteratively increasing the number of papers p p p and the number of reviewers r r r . Lastly, for the scheduling dataset (which models the scheduling under no show behavior problem), we generated instances by iteratively increasing the number of exams e e e , people p p p , and resources r r r . All probabilistic facts are assigned random probabilities. For all instances, we fixed the seed for reproducibility.
The experiments3 were executed on a machine running at 3.7 GHz with 32 GB of RAM and a time limit, for each instance, of 3600 seconds (1 hour). We used the bash command time to extract the execution time and collected the real values.
Results
Inference. Table 3 shows the results for the paper dataset. Here, the approach based on enumeration (enum ) seem to be effective when the number of articles is small, providing better performance w.r.t. aspmc for 2 and 3 papers. Then, for the remaining cases, aspmc can solve significantly more instances. The largest solvable instance for enum is with 6 papers and 5 reviewers while with aspmc it is possible to get up to 10 papers and 7 reviewers.
Table 3. Results on the paper dataset. The columns include: the number of articles considered (# \# # papers ), the number of reviewers associated with the largest solvable instance for a fixed number of papers (n n n rev max), the runtime associated with the largest solvable instance for a fixed number of papers (runtime largest ), and the cumulative runtime (i.e., the sum of all runtime for all instances) for a fixed number of papers (cumulative runtime ), for both aspmc and enum . A dash indicates that none of the instances where solved for the fixed number of papers. All times are in seconds.
Table 4 shows the results for the scheduling dataset and reports the cumulative runtime obtained by adding up the execution time of all instances with number of resources and exams ranging from 2 to 10, with a fixed number of people. Here, both approaches can solve all instances. Then, we further increase the size of the instances to better assess aspmc (Table 5 ). As for the previous dataset, enum is more effective for small instances. However, as the size grows, the benefits of KC-based approaches become evident. The largest number of people that can be handled with aspmc is 15. With 16, it can handle up to 5 resources and 10 exams, requiring approximately 20 minutes.
Table 4. Results on the scheduling dataset. The columns include: the number of considered people (# \# # people ) and the cumulative runtime (in seconds) of all instances with a fixed number of people and an increasing number of resources and exams (from 2 to 10). Both solvers can solve all instances.
Table 5. Results on the scheduling dataset. The columns include: the number of considered people (# people) and the cumulative runtime (in seconds) of all instances with a fixed number of people and an increasing number of resources and exams (from 2 to 10). Only aspmc can solve these instances (enum always timeouts).
Lastly, Table 6 shows the results for the viral dataset. Also in this case the approach based on aspmc is much more effective w.r.t. enumeration for larger instances.
Table 6. Results on the viral datasets. A dash indicates that the instance cannot be solved.
For all datasets, enum stops due to timeout, while aspmc due to a knowledge compilation error, possibly due to excessive memory requirements. Overall, enumeration-based approaches are effective for small instances. However, as the size of the dataset increases, enumeration becomes unfeasible. There is a crucial point to consider: enum computes only optimal answer sets while aspmc computes all answer sets and then only considers optimal ones. Thus, the number of answer sets considered in aspmc may be much larger than the number considered with enum .
MPE. For MPE, we focus on ASP(Q Q Q ) only. This is because enum enumerates all answer sets, so the execution time to solve either inference or MPE is the same. Similar considerations apply to aspmc as it consider all answer sets and then filters them according to the semiring operations. Furthermore, ASP(Q Q Q ) has been already been proven much more effective than aspmc to solve MPE in plain PASP [12 ] .
Figures 1, 2 and 3 show the results for computing the MPE with ASP(Q Q Q ) for the three datasets. For paper and scheduling , the reported results are computed by summing the execution times over all instances with the considered number of reviewers (for paper ) and people (for scheduling ). For paper , the we note that, once the number of reviewers is fixed, the number of papers does not seem to influence the execution time. Thus, the figure reports only the results with 10 articles, as the other are similar. For scheduling , we considered exam and resources both ranging from 10 to 100 with step 10.
For the paper dataset, computing the lower MPE state is much slower than computing the upper MPE state, as the largest solvable instance within the time limit is the one with 100 reviewers. On the contrary, we can compute the upper MPE state for the instance with 200 reviewers within 800 seconds. For the viral dataset, computing the MPE state is almost instantaneous (less than 0.5 seconds) for all instances. The computation of the lower MPE state, however, requires a bit more time, but still less than 3 minutes. Lastly, we have a different trend for the scheduling dataset, as there the computation of the upper MPE state is slower w.r.t. the computation of the lower MPE state. Still, in both cases, we can handle the instance with 100 people within 100 seconds for the upper and 40 for the lower.
More in details, for lower MPE, CASPER directly applies the CEGAR (Counterexample-Guided Abstraction Refinement) approach without any additional translation, since the ASP(Q) encoding is alternating (i.e., of the form ∃ s t P 1 ∀ s t P 2 : C : C ω \exists^{st} P_1 \forall^{st} P_2 : C : C^{\omega} ∃ s t P 1 ∀ s t P 2 : C : C ω ). In contrast, for upper MPE, CASPER relies on a preprocessing step that eliminates weak constraints via the translation proposed by Mazzotta et al. [54 ] , as the CEGAR methodology cannot be directly applied to uniform ASP(Q) programs (i.e., ∃ s t P 1 ∃ s t P 2 : C : C ω \exists^{st} P_1 \exists^{st} P_2 : C : C^{\omega} ∃ s t P 1 ∃ s t P 2 : C : C ω ).
These two approaches exhibit different strengths and limitations, which explain the trends observed in the experimental results. On the one hand, the translation required for uniform ASP(Q) programs introduces a duplication of the second program within the first one and enforces optimality checks in the second quantifier. As a consequence, the search space increases, since candidate quantified answer sets correspond to pairs σ ∪ M \sigma\cup M σ ∪ M , where σ \sigma σ is a selection and M M M is an answer set of w σ w_\sigma w σ . This overhead is particularly evident in the scheduling dataset, where CASPER takes a longer execution time for solving the upper MPE problem compared to lower MPE one.
Figure 1. Results of ASP(Q) for computing the lower and upper MPE states for the paper dataset.
Figure 2. Results of ASP(Q) for computing the lower and upper MPE states for the viral dataset.
On the other hand, for lower MPE, no such translation is not required, and CEGAR can be applied directly. The method explores the space of quantified answer sets by iteratively identifying counterexamples (i.e., optimal answer sets of the second program that invalidate candidate quantified answer set) and refining the original program accordingly. This approach proves to be highly effective on the scheduling datasets, while showing some overhead on the paper dataset due to the large number of counterexamples that must be discovered before converging to a quantified answer set.
Overall, the results highlight that both upper and lower MPE in optimal PASP are computationally-hard tasks. Unlike plain PASP, the two problems share the same computational complexity in the optimal PASP setting, in fact both problems are Σ 2 P \Sigma^{P}_{2} Σ 2 P -complete.
Despite this inherent complexity, CASPER is very effective in computing the lower and upper MPE state for optimal PASP program, as the majority of the considered instances can still be solved within few minutes. Lastly, if we compare the results obtained with ASP(Q) with aspmc, we note that ASP(Q) is much more efficient.
Figure 3. Results of ASP(Q) for computing the lower and upper MPE states for the scheduling dataset.
Related Work
Related works mainly follows two different directions: alternative semantics for expressing uncertainty within a logic-based language and tasks that can be considered in PASP/PLP frameworks.
Alternative Semantics. The credal semantics imposes no preference over the distribution of the probability mass of a world over its answer sets, introducing probability bounds (lower and upper) for each query. Here, we specialize this by considering only the optimal answer sets, according to a set of constraints, but we still keep the two bounds. The smProbLog (Totis et al. [59 ] ) semantics is closely related: here, the probability of a world is uniformly distributed over the answer sets. That is, for a world w w w , each of its answer set has a probability of P ( w ) / ∣ A S ( w ) ∣ P(w)/|AS(w)| P ( w ) /∣ A S ( w ) ∣ where P ( w ) P(w) P ( w ) is computed as in Equation (1) . Then, the probability of a query is computed as the sum of the probabilities of the answer sets where the query is true. However, smProbLog only considers plain PASP (without weak constraints) for worlds. Extending this semantics considering weak constraints is an interesting direction for future work.
Both CS and smProbLog require each world to be coherent (i.e., with at least one answer set). If this does not hold, there is a loss of probability mass. The L-credal semantics (Rocha and Cozman [56 ] ) tries to overcome this by introducing a “undefined” truth value. Another possibility is to normalize the probability (Azzolini et al. 2025), i.e., dividing the probability of the query by 1 minus the sum of the probabilities of incoherent worlds. Another possibility is to “repair” the program ([38 , 22 ] ).
Other semantics for PASP include LPMLN (Lee et al. [51 ] ) that extends ASP with weighted rules and atoms. Furthermore, there is the possibility of handling infinite weights that represent hard constraints. In LPMLN, there is no concept of world. Rather, each answer set is associated with a weight, and the probability of a query is the sum of the probabilities (obtained by dividing the weight of an answer set by the total weight) of the answer sets containing the query. Another approach is P-log (Baral et al. [14 ] ), where it is possible to define random attributes and a probability distribution over the answer sets. The relationship between LPMLN an P-log has been extensively explored in [52 ] .
If worlds are plain answer set programs composed of normal rules only and every such program has a unique stable model (which also coincides with the unique well-founded model [61 ] ), we fall into the Probabilistic Logic Programming (PLP) field [29 , 55 ] .
Related Tasks. In this paper, we focus on inference and computation of the MPE state in optPASP. MPE has also been studied for plain PASP and PLP [57 , 12 ] . In PLP, the task can be solved with a plain ASP, by converting probabilistic facts into choice rules and considering log-probabilities. However, for PASP, saturation [36 , 26 ] or more advanced approaches such as Answer Set Programming with Quantifiers [6 , 54 ] are needed. MPE is closely related to Maximum-a-Posteriori, which has been studied for both PLP [16 ] and PASP [11 ] . In brief, in MAP some probabilistic facts are denoted as query probabilistic facts and the goal is to compute a subset of such facts (called MAP state) such that the probability of the given evidence is maximized. This generalizes MPE, as in MPE all probabilistic facts are considered as query probabilistic facts. Computing the MAP state is harder than solving MPE Mauá and Cozman [53 ] and standard approaches are based on knowledge compilation.
Decision theory (DT) tasks can be framed in the PLP and PASP frameworks [60 , 9 ] . Here, the PLP/PASP is extended with utility attributes, which specify costs/utilities associated with some of the atoms of the program, and decision atoms, which can be selected or not. Each selection of decision atoms identifies a PLP/PASP which is associated with an expected cost by considering the probability and the utilities of the different literals. The goal is to find the set of decision atoms that maximizes the expected utility. This is different w.r.t. inference in optPASP, as in DT the maximization is on the outer level (over the decision atoms) while in optPASP, weak constraints impose an optimality criterion over answer sets (so, in the inner level) and then these are considered for the computation of the probability. Similarly, the MPE also differs, as it aims to find the optimal solution over all probabilistic facts, not only a subset of it (as may happen in DT with decision atoms). Furthermore, the result of DT is a tuple composed of a real number and a set of atoms, while for MPE we have a probability.
Lastly, another related task is abduction in PLP [8 ] : here, a PLP is extended with abducible facts and integrity constraints. Each selection of abducible facts identifies a PLP. Given a query q q q , the goal is to find the minimal set (where minimality is considered under set-inclusion) of abducible facts that maximizes the probability of q q q . Extending all these tasks to the optPASP framework is also an interesting direction for future work.
The inference, MPE, MAP, and decision theory problems, for both PLP and PASP, have been all formalized in the AMC framework. For PLP, inference and MPE can be effectively encoded with AMC [49 , 12 ] , while MAP and decision theory with 2AMC [48 ] . For PASP, inference and MPE can be effectively encoded with 2AMC [12 ] while MAP and decision theory with 3AMC [11 a] . Overall, in this paper we frame inference in optPASP within the AMC spectrum, thus providing a connection with existing works.
Conclusion
In this paper, we propose optimal Probabilistic Answer Set Programming (optPASP), an extension of Probabilistic Answer Set Programming that incorporates weak constraints, a standard and powerful ASP construct for modeling preferences. After presenting the syntax and semantics of optPASP, we illustrated its modeling capabilities through three real-world–inspired applications: the paper assignment problem, the viral marketing problem, and scheduling under no-show behavior. These case studies demonstrate the expressiveness and practical potential of our framework. On the theoretical side, we studied the computational complexity of the main task associated with optASP: inference and most probable explanation (MPE). On the practical side, we encoded these tasks as instances of Algebraic Model Counting, and we also proposed an implementation in Answer Set Programming with Quantifiers. We evaluated the resulting implementations on real-world-inspired benchmark problems, demonstrating the practical viability of our approach.
Several directions for future work can be envisaged. On the one hand, it would be interesting to extend other semantics for PASP to accommodate weak constraints, thereby broadening the applicability of optimization in probabilistic settings. On the other hand, further investigation of additional reasoning tasks in optPASP, such as Maximum-a-Posteriori (MAP) inference, represents a natural and promising direction.
Competing Interests
Competing interests: The authors declare none.