# Programowanie zbiorów odpowiedzi (ASP)

EN: **Answer set programming (ASP)** · id `answersetprog` · aliases: answer set programming, ASP, programowanie zbiorów odpowiedzi

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Fundamenty i rozumowanie](https://aiatlasgraph.com/t/foundations.md) › [Logika i reprezentacja wiedzy](https://aiatlasgraph.com/t/logic.md) › [Programowanie logiczne](https://aiatlasgraph.com/t/logicprogramming.md) › Programowanie zbiorów odpowiedzi (ASP)

## Description

- PL: Deklaratywne programowanie logiczne oparte na semantyce modeli stabilnych; problemy kombinatoryczne zapisuje się jako reguły, a rozwiązania to zbiory odpowiedzi.
- EN: Declarative logic programming based on stable-model semantics; combinatorial problems are written as rules and solutions are answer sets.

## In one sentence

- PL: Opisujesz, jak ma wyglądać dobre rozwiązanie i czego nie wolno, a program sam znajduje wszystkie pasujące warianty.
- EN: You describe what a good solution looks like and what is forbidden, and the program finds every fitting option.

## Problem it solves

- PL: Układanie grafików, konfiguracji i planów z dziesiątkami warunków ręcznie albo zwykłym kodem jest żmudne i pełne pomyłek.
- EN: Building rosters, configurations and plans with dozens of conditions by hand or in ordinary code is tedious and error-prone.

## What it does

- PL: Jak ogłoszenie z wymaganiami zamiast instrukcji: mówisz „każdy dyżur obsadzony, nikt dwa razy z rzędu”, a solwer szuka układów.
- EN: Like a job ad listing requirements instead of instructions: 'every shift covered, nobody twice in a row', and the solver searches layouts.

## Everyday example

- PL: Szpital układa miesięczny grafik pielęgniarek z urlopami i zasadami odpoczynku, a program podaje gotowe, zgodne z regułami warianty.
- EN: A hospital builds a monthly nurse roster with holidays and rest rules, and the program offers ready options that obey them.

## This concerns you if you…

- PL: układasz grafiki, plany lub konfiguracje z wieloma warunkami
- PL: chcesz zestawić model językowy z precyzyjnym rozwiązywaniem reguł
- EN: build rosters, plans or configurations with many conditions
- EN: want to pair a language model with precise rule solving

## Keywords

clingo · gringo · clasp · Potassco · DLV · stable models · choice rules · ASP-Core-2 · LLM+ASP

## How it works

- PL: Program składa się z faktów, reguł z negacją przez porażkę, reguł wyboru i ograniczeń integralności. Grounder zastępuje zmienne stałymi, tworząc program zdaniowy, a solwer oparty na uczeniu klauzul z konfliktów, jak w SAT, wylicza modele stabilne; optymalizacja wybiera najlepsze według wag.
- EN: A program consists of facts, rules with negation as failure, choice rules and integrity constraints. A grounder replaces variables with constants to produce a propositional program, and a conflict-driven clause-learning solver, as in SAT, computes stable models; optimisation statements pick the best by weights.

## Limits

- PL: Ugruntowanie może eksplodować rozmiarem przy dużych dziedzinach liczbowych. Modelowanie wymaga wprawy, a wydajność silnie zależy od sposobu zapisu reguł; ASP nie radzi sobie natywnie z niepewnymi danymi.
- EN: Grounding can explode with large numeric domains. Modelling takes skill, performance depends heavily on how rules are written, and ASP does not natively handle uncertain data.

## Key terms

- PL: **model stabilny**: Zbiór faktów spójny z regułami i niczego nie zakładający bez powodu.
- PL: **ograniczenie integralności**: Reguła wykluczająca rozwiązania, w których dzieje się coś zakazanego.
- PL: **reguła wyboru**: Pozwala solwerowi zdecydować, które z opcji włączyć.
- EN: **stable model**: A set of facts consistent with the rules, assuming nothing without reason.
- EN: **integrity constraint**: A rule ruling out solutions where something forbidden happens.
- EN: **choice rule**: Lets the solver decide which options to switch on.

## Know first

- [Solwery SAT i SMT (SAT and SMT solvers)](https://aiatlasgraph.com/t/satsmt.md)

## Related topics

Untyped, symmetric "see also" links.

- [Rozumowanie niemonotoniczne i domyślne (Non-monotonic and default reasoning)](https://aiatlasgraph.com/t/nonmonotonic.md)

## Sources

- [Non-monotonic Logic — Stanford Encyclopedia of Philosophy](<https://plato.stanford.edu/entries/logic-nonmonotonic/>) `sep-nonmonotonic-logic` · by G. Aldo Antonelli
- [Potassco Guide — gringo, clasp and clingo (answer set programming)](<https://potassco.org/guide/>) `potassco-guide` · by Potassco (University of Potsdam)

---

AI Atlas revision 125 (2026-11-01) · HTML: https://aiatlasgraph.com/t/answersetprog · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-11-01
