Clingo (ASP)

Clingo is the flagship system of Answer Set Programming (ASP): you model a combinatorial problem as rules, and clingo — the gringo grounder plus the clasp solver — finds every answer set, i.e. every solution. You describe the problem; the solver does the search.

Purpose

ASP is declarative problem solving for NP-hard search: the programmer writes what a solution is, and the solver computes it.

The Problem It Solves

Scheduling, configuration, planning, and graph problems are easy to describe and hard to search. ASP captures the “easy to describe” part: facts, rules, and choice constructs (e.g. “assign exactly one color per node”) with negation-as-failure, and the solver handles the search with industrial-strength SAT/CDCL technology. Unlike Prolog, the semantics are whole-program (stable models), so the order of rules never matters.

Where It Fits

ASP is the search-oriented member of the logic family: Prolog for interactive reasoning, Datalog for database-style inference, MiniZinc for constraint optimization with solver choice, Clingo for logic-based combinatorial search with defaults and preferences.

History

ASP turned a 1980s logic semantics into competition-winning software.

Origins

Michael Gelfond and Vladimir Lifschitz defined stable model (answer set) semantics in 1988, giving logic programs with negation a precise meaning. The 1990s brought the first solvers; the field grew with the smodels system (1999) and centralized in the ASP competition era.

Milestones

  • 2004–2009 — the Potassco group at the University of Potsdam (Gebser, Kaminski, Kaufmann, Schaub) builds the gringo grounder and the clasp CDCL solver.
  • 2011–2014 — clingo unifies grounding and solving with incremental computation; version 4 aligns with the ASP-Core-2 standard.
  • 2019+ — Spack, the HPC package manager, adopts clingo for dependency resolution — ASP solving inside everyday developer tooling.

Current Status

Active and stable (clingo 5.x), MIT-licensed, with rich APIs (Python, C, Rust, Java) and packages for every major platform. It remains the reference system for ASP research and the engine behind several production configurators.

Stage

Clingo is a mature research tool with a growing production footprint.

Maturity

Solid and stable: clingo 5.x is the benchmark ASP system, with incremental solving, Python/C APIs, and a formal language specification.

Governance & Maintenance

Developed by the Potassco team (University of Potsdam) and contributors; MIT-licensed; packaged for conda, pip, Homebrew, Debian, and Arch.

Popularity & Usability

Strong in knowledge-representation research and in configuration tooling.

Adoption

Standard in academic AI (ASP competitions, planning, robotics), plus real production uses: Spack’s dependency solver, configurators, and decision-support systems built on clingo’s Python API.

Learning Curve

Model-first thinking: rules, choice constructs ({...}), and cardinality constraints replace loops and recursion. The semantics are intuitive for puzzles, but grounding must be mastered before scaling up.

Tooling

Command-line clingo, Python and C APIs, the clorm ORM-style library, VS Code syntax highlighting, and an in-browser playground on the Potassco site.

Use Cases

ASP wins where the problem is combinatorial and solutions must satisfy many logical constraints.

Primary Domains

  • Scheduling and rostering with hard and soft rules.
  • Configuration validation and dependency resolution (Spack).
  • Planning, game solving, and graph problems (Hamiltonian paths, coloring).
  • Decision support and belief/argumentation reasoning in research systems.

Strengths

Whole-program semantics (rule order irrelevant), clean handling of defaults and exceptions, enumeration of ALL solutions, and a competition-winning solver.

Weak Spots

Grounding can exhaust memory on large instances; numeric constraints are weaker than dedicated CP/SAT tools; debugging requires understanding stable-model semantics.

Performance

Performance is the solver’s job — and the solver is state of the art.

Execution Model

gringo grounds the first-order program into propositional rules; clasp solves with conflict-driven clause learning (CDCL), the technology behind modern SAT solvers. Incremental mode reuses learned clauses across similar queries.

Published Claims

The Potassco publications report clasp consistently winning answer-set programming competitions. The honest bottleneck is grounding, not solving: keep the grounded program small and clingo scales to industrial instances.

Example

Map coloring: assign one of three colors to each region so neighboring regions differ — a classic ASP model in seven lines.

3-Coloring

% coloring.lp — three-color a small map (answer set programming)
region(a). region(b). region(c).      % the regions
neighbor(a,b). neighbor(b,c). neighbor(a,c).

% choice rule: every region gets exactly one of three colors
{ color(R, red); color(R, green); color(R, blue) } = 1 :- region(R).

% integrity constraint: neighbors must not share a color
:- neighbor(X, Y), color(X, C), color(Y, C).

The {...} = 1 block is a choice construct: “pick exactly one color per region.” A rule with :- on the left is an integrity constraint that forbids bad solutions.

How to Run

pip install clingo        # or: conda install -c conda-forge clingo
clingo coloring.lp        # prints answer sets: color(a,red) color(b,green) color(c,blue)

For a no-install first try, use the browser playground on the Potassco site.

Learn More

Official sources and free materials; the full categorized catalog is on the References & Downloads page.

Official Docs & Downloads

Learning Material