# Programowanie logiczne

EN: **Logic programming** · id `logicprogramming` · aliases: logic programming, programowanie logiczne, programowanie w logice

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

## Description

- PL: Paradygmat deklaratywny: program to zbiór klauzul logicznych, a obliczenie to wnioskowanie (rezolucja, punkt stały lub modele stabilne).
- EN: Declarative paradigm: a program is a set of logical clauses and computation is inference (resolution, fixpoint or stable models).

## In one sentence

- PL: Programowanie przez opisanie faktów i reguł zamiast kroków; komputer sam dochodzi do odpowiedzi, wyciągając wnioski.
- EN: Programming by stating facts and rules instead of steps; the computer reaches answers by drawing conclusions itself.

## Problem it solves

- PL: Zasady biznesowe, przepisy i łamigłówki z wieloma warunkami trudno zakodować krok po kroku bez gubienia przypadków.
- EN: Business rules, regulations and puzzles with many conditions are hard to code step by step without missing cases.

## What it does

- PL: Podajesz jak w podręczniku: kto jest czyim rodzicem i kim jest dziadek, a system sam znajduje wszystkich dziadków.
- EN: You state, as in a textbook, who is whose parent and what a grandparent is, and the system finds every grandparent itself.

## Everyday example

- PL: System kadrowy z zapisanych reguł urlopowych sam wylicza, komu przysługuje dodatkowy dzień wolny.
- EN: An HR system works out from written leave rules who is entitled to an extra day off.

## This concerns you if you…

- PL: zapisujesz złożone reguły, które muszą być spójne
- PL: układasz plany lub grafiki z wieloma warunkami
- EN: write complex rules that must stay consistent
- EN: build plans or rosters with many conditions

## Keywords

Prolog · SWI-Prolog · Datalog · clingo · answer set programming · SLD resolution · negation as failure · Potassco · Soufflé

## How it works

- PL: Prolog odpowiada na zapytania rezolucją SLD z przeszukiwaniem w głąb i unifikacją termów. Datalog to podzbiór bez symboli funkcyjnych, wyliczany od dołu do punktu stałego, popularny w bazach danych i analizie programów. Programowanie zbiorów odpowiedzi najpierw ugruntowuje reguły do postaci zdaniowej, a potem solwer zbliżony do SAT wylicza modele stabilne jako rozwiązania problemów kombinatorycznych.
- EN: Prolog answers queries by SLD resolution with depth-first search and term unification. Datalog is a function-free subset evaluated bottom-up to a fixpoint, popular in databases and program analysis. Answer set programming first grounds rules into propositional form, then a SAT-like solver computes stable models as solutions to combinatorial problems.

## Limits

- PL: Kolejność reguł w Prologu wpływa na wynik i może prowadzić do nieskończonych pętli. Ugruntowanie w ASP potrafi eksplodować rozmiarem, a ręczne pisanie reguł słabo radzi sobie z niepewnymi, zaszumionymi danymi.
- EN: Rule order in Prolog affects results and can cause infinite loops. Grounding in ASP can explode in size, and hand-written rules cope poorly with uncertain, noisy data.

## Key terms

- PL: **unifikacja**: Dopasowanie dwóch wyrażeń przez dobranie wartości zmiennych.
- PL: **ugruntowanie**: Zastąpienie zmiennych w regułach wszystkimi konkretnymi wartościami.
- PL: **model stabilny**: Spójny zbiór faktów wynikający z reguł, traktowany jako rozwiązanie.
- EN: **unification**: Matching two expressions by choosing variable values.
- EN: **grounding**: Replacing rule variables with all concrete values.
- EN: **stable model**: A consistent set of facts following from rules, treated as a solution.

## Know first

- [Logika zdań i logika pierwszego rzędu (Propositional and first-order logic)](https://aiatlasgraph.com/t/fol.md)

## Related topics

Untyped, symmetric "see also" links.

- [Grafy wiedzy (Knowledge graphs)](https://aiatlasgraph.com/t/kgraphs.md)
- [Planowanie automatyczne (PDDL) (Automated planning (PDDL))](https://aiatlasgraph.com/t/classicalplanning.md)

## Sources

- [Potassco Guide — gringo, clasp and clingo (answer set programming)](<https://potassco.org/guide/>) `potassco-guide` · by Potassco (University of Potsdam)
- [SWI-Prolog · Glossary: SLD resolution and Prolog execution](<https://www.swi-prolog.org/pldoc/man?section=glossary>) `swi-prolog-sld-glossary` · by SWI-Prolog project
- [Soufflé · Datalog language documentation](<https://souffle-lang.github.io/docs.html>) `souffle-datalog-docs` · by Soufflé project

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/logicprogramming · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
