Weighted Answer-Set Programming (WASP)
- Weighted Answer-Set Programming (WASP) is a generalization of ASP that integrates weighted formulas and semiring-based constraints for quantitative and optimized logic modeling.
- It employs here-and-there logic and algebraic evaluation to systematically handle optimization and probabilistic reasoning, adapting complexity based on semiring choice.
- WASP supports applications such as shortest-path, scheduling, and resource allocation through advanced solver techniques and stratified optimization methods.
Weighted Answer-Set Programming (WASP) is a generalization of classical answer-set programming (ASP) that augments logic programs with quantitative reasoning, enabling the specification, analysis, and optimization of properties expressible via (commutative) semiring-valued annotations, algebraic constraints, or weighted aggregations over answer sets. WASP encompasses a broad spectrum of techniques, including semiring-based extensions, optimization through weak constraints, algebraic model counting, and reasoning over annotated facts with uncertainty. The resulting framework supports expressive modeling for optimization, probabilistic reasoning, provenance, resource allocation, and more—all under equilibrium semantics compatible with nonmonotonic logic programming.
1. Algebraic Foundations and Syntax
At the core of WASP is the extension of propositional logic programs by integrating weighted formulas and algebraic constraints built over a commutative semiring , with and denoting the additive and multiplicative semiring operations, respectively. Weighted formulas are constructed recursively as:
- where is a semiring element and an atom.
Rules in WASP may have weighted formulas in both head and body positions. Specifically, a rule can be formulated as: where each is an atom or an algebraic constraint (0), and each 1 is a weighted formula.
This algebraic syntax generalizes standard ASP “weight constraints,” encapsulates aggregates, and admits arbitrary semiring semantics (e.g., booleans, integers, reals, tropical, provenance semirings) (Kiesel, 2021, Eiter et al., 2020).
2. Semantics via Here-and-There Logic and Equilibrium Models
The semantics of WASP are given by adapting the Here-and-There (HT) logic, an intermediate semantics between intuitionistic and classical logic, to the weighted setting. An HT-interpretation is a pair 2 with 3.
Weighted formulas are evaluated in a world 4 via functions 5 that lift semiring structure to formulas:
- 6
- 7 if 8 9 otherwise
- 0
- 1
Satisfaction of a rule involves computing a weighted reduct relative to 2, removing negated body literals not falsified in 3 and evaluating positive bodies. A weighted answer set is a propositional interpretation 4 such that 5 is an HT-model, and no strict subset 6 is an HT-model (Kiesel, 2021, Eiter et al., 2020).
3. Complexity, Tractability, and Algorithmic Techniques
The principal computational task in WASP is algebraic answer-set counting (AASC), i.e., computing
7
where 8 is typically a product of atomic weights. The complexity of AASC parameterizes over the semiring:
- NP-complete in the boolean case,
- 9-complete for the counting semiring,
- OptP-complete under the tropical (min, 0) semiring.
A general result is that AASC is complete for NP(1), a semiring-parametrized complexity class that instantiates NP, 2, OptP, etc., depending on 3. Moreover, a treewidth-aware translation compiles non-disjunctive programs to propositional formulas 4 such that 5, where 6 is a backdoor measure; the weighted model count over 7 then matches the answer-set count (Kiesel, 2021).
Tractability depends not only on bounded treewidth but also on bounds on constraint-width or unary-encoded weights. Without these restrictions, even programs of treewidth one are NP-complete for consistency (Pichler et al., 2012). For bounded treewidth 8 and bounded constraint-width 9, model-checking and consistency fall to fixed-parameter tractable cases via either monadic second-order (MSO) techniques (Courcelle's theorem) or dynamic programming (Pichler et al., 2012).
Solver implementations for WASP exploit incremental SAT solving, clause learning across optimization strata, and binary search for single-level soft constraint optimization. Preprocessing steps such as zero-weight elimination and level normalization are justified at the abstraction level (Lierler, 2022).
4. Optimization via Weak Constraints and Extended Weight Systems
The most common form of optimization in WASP is via weak constraints, which penalize (or reward) answer sets exhibiting certain properties via associated weights. Weak constraints can be captured as extended weight (EW) systems, in which each weak constraint induces an "ew-condition"—a triple 0, where 1 is a theory in an extended logic, 2 is its propositional weight, 3 a coefficient function, and 4 its optimization level.
Optimization semantics are given by lexicographic minimization over levels: stratify constraints, optimize higher strata first, and recurse to lower ones. EW-system properties directly imply key solver optimizations: zero-weight elimination, level normalization, levelwise independence (stratum-by-stratum optimization), and duality between minimization and maximization via weight sign flip. The complexity of optimizing over EW-systems is 5 for single-level and 6 for multi-level tasks (Lierler, 2022).
5. Algebraic Approaches to Probabilistic and Provenance Semantics
A distinct algebraic approach treats weights annotating facts as probability-like or provenance information, with the program specifying constraints on model generation. Here, each total choice over weighted facts induces a weight, and stable models are partitioned accordingly. Ambiguity in mapping choices to models is parameterized by symbolic variables 7, yielding an expression for the probability or weight of events as polynomials over atomic weights and 8-parameters. This construction supports both explicit marginalization over events (not just answer sets) and algebraic manipulation for learning and inference (Coelho et al., 26 Mar 2025).
Theoretical properties include:
- Coherence: events sharing the same stable core (set of relevant stable models) receive identical weights.
- Soundness when facts with weight one are promoted to hard constraints.
- σ-additivity at the level of stable models. This algebraic separation permits principled overlay of probabilistic or provenance semantics atop stable-model logic, supporting both prior and posterior reasoning.
6. Comparative Analysis and Related Frameworks
Weighted HT ASP and its variants generalize traditional ASP extensions:
- Traditional weight and cardinality constraints are expressible as special cases under suitable semirings.
- Frameworks like LP9 support MLN-style weighting but are tied to real-valued optimization.
- ProbLog and aProbLog support model counting in restricted (non-disjunctive, aggregation-limited) fragments.
- Hybrid ASP allows integration with arbitrary constraint theories but does not provide a uniform algebraic syntax.
- Temporal ASP (telingo) incorporates time but not arbitrary semiring-weighted quantitative reasoning.
By contrast, WASP provides:
- Full semiring parameterization for both quantitative model aggregation and algebraic constraints.
- Preservation of HT-based strong equivalence and splitting properties.
- Support for constructs such as minimized choice constraints not previously available.
- Uniform extension to provenance, probabilistic, optimization, and resource-tracking use cases in one logical framework (Kiesel, 2021, Lierler, 2022, Coelho et al., 26 Mar 2025).
7. Illustrative Examples and Applications
WASP operationalizes a broad set of applications:
- Optimization: Given weighted alternatives (e.g., cost of evening activities), WASP computes (possibly in a lexicographically stratified manner) optimal sets under resource constraints.
- Shortest-path: Over tropical semirings, WASP models the shortest path problem via cost-minimizing algebraic constraints.
- Provenance: Using provenance semirings 0, it enables bag semantics and derivation counting for datalog programs.
- Probabilistic reasoning: Weighting facts with probabilities, WASP marginalizes event or answer set probabilities algebraically while preserving nonmonotonic dependencies.
- Scheduling, planning, and combinatorial optimization: Weighted aggregates and constraints, stratified for multi-objective optimization, are naturally encoded.
Empirical studies demonstrate that careful compilation and optimization rewriting (e.g., through comparator networks) can yield exponential improvements in answer-set optimization performance (Bomanson et al., 2020). Depth-bounded and sparsity-controlled network constructions provide an additional algorithmic lever to balance expressiveness and computational cost.
References:
- (Kiesel, 2021) Quantitative and Stream Extensions of Answer Set Programming
- (Lierler, 2022) Unifying Framework for Optimizations in non-boolean Formalisms
- (Eiter et al., 2020) ASP(AC): Answer Set Programming with Algebraic Constraints
- (Pichler et al., 2012) Tractable Answer-Set Programming with Weight Constraints: Bounded Treewidth is not Enough
- (Bomanson et al., 2020) Boosting Answer Set Optimization with Weighted Comparator Networks
- (Coelho et al., 26 Mar 2025) An Algebraic Approach to Weighted Answer-set Programming