2026-04-20·9 min read·sota.io team

Deploy Prolog to Europe — EU Hosting for SWI-Prolog Web APIs in 2026

In the summer of 1972, Alain Colmerauer and his colleagues at the Groupe d'Intelligence Artificielle at the Université d'Aix-Marseille in southern France invented a new way to program computers. Rather than telling the machine what steps to execute, you would describe what you knew — facts, relationships, rules — and let the machine figure out how to answer questions about that knowledge. They called the result Prolog, from PROgrammation en LOGique: programming in logic.

Colmerauer, born in Carcassonne in 1941, was working on natural language processing — the problem of getting computers to understand and generate human language. Prolog emerged from his attempt to represent grammatical rules in formal logic and use a theorem prover to parse sentences. The insight was profound: if you could express knowledge as logical clauses and queries as goals, the same machinery that proved mathematical theorems could answer questions about the world. Within a decade, Prolog had spread from Marseille to research labs across Europe, Japan, and the United States.

Today, the most widely deployed Prolog implementation carries a distinctly Dutch stamp. Jan Wielemaker at Vrije Universiteit Amsterdam — VU Amsterdam — has developed and maintained SWI-Prolog since 1987. What began as a research interpreter has grown into a mature system with a rich standard library, a package manager, and — crucially for backend developers — a full HTTP server stack with JSON support, WebSocket handling, CORS, session management, and ODBC database connectivity. SWI-Prolog runs in production at universities, biomedical research institutions, legal reasoning systems, and knowledge-graph applications across the EU.

Prolog is not a language you choose for performance benchmarks. You choose it when the problem is fundamentally about reasoning: when you have complex rules that change, when you need to query a knowledge base, when you are building an AI system that must explain its conclusions. For EU teams building regulatory compliance systems, medical decision support, semantic web backends, or natural language interfaces, Prolog offers something no imperative language does — the ability to express the domain logic directly, without translating it into procedures.

This guide shows how to build and deploy a SWI-Prolog HTTP API to EU infrastructure with sota.io.

Why Prolog for Production Backends

The case for Prolog in production is narrow but compelling for the right problems.

Logic is the data model. In a conventional backend, your domain knowledge lives in SQL schemas, class hierarchies, and if-chains. In Prolog, it lives in clauses. A rule like "a user is authorised for an action if they have the required role AND the resource is in their assigned region AND the action is not restricted during maintenance windows" translates directly into a Prolog clause with the same structure. When the compliance team updates the rule, you update the clause — not three files spread across the codebase.

Built-in backtracking and search. Prolog's execution model is built around search with backtracking. When you ask Prolog to prove a goal, it tries all matching clauses systematically and backtracks when a path fails. This makes it natural to implement constraint solving, scheduling, route finding, and configuration generation — problems that require exploring a search space and finding a solution that satisfies multiple constraints.

Definite Clause Grammars. DCGs are Prolog's notation for context-free grammars. They compile into standard Prolog clauses and can be mixed freely with arbitrary logic. For NLP preprocessing, protocol parsing, configuration file parsing, or structured text extraction, DCGs let you write parsers at a level of abstraction that parser combinator libraries aspire to.

Explanable AI before it was a requirement. Prolog's proof trees are inherently inspectable. When a Prolog system decides that a patient qualifies for a clinical trial or that a contract clause is non-compliant, you can trace the exact chain of rules that produced the conclusion. With the EU AI Act requiring transparency and explainability for high-risk AI systems, this is not a theoretical advantage.

EU provenance. Prolog was invented in France. SWI-Prolog is maintained in the Netherlands. The major European university research groups — INRIA in France, CWI in Amsterdam, Edinburgh, Leuven — have produced decades of Prolog research and tooling. For organisations evaluating supply chain provenance or preferring EU-originating open-source software, Prolog has deep European roots.

SWI-Prolog's HTTP Stack

SWI-Prolog includes a mature HTTP server library that supports everything a REST API needs. The core modules are:

A complete API server in SWI-Prolog:

% main.pl
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_json)).
:- use_module(library(http/http_parameters)).
:- use_module(library(http/http_cors)).

% Route registration
:- http_handler(root(.),          handle_root,   []).
:- http_handler(root(api/health), handle_health, []).
:- http_handler(root(api/users),  handle_users,  [method(get)]).
:- http_handler(root(api/reason), handle_reason, [method(post)]).

% Start server — called on initialisation
:- initialization(main, main).

main :-
    port(Port),
    http_server(http_dispatch, [port(Port)]),
    format("Server started on port ~w~n", [Port]),
    thread_get_message(stop).

port(Port) :-
    (   getenv('PORT', PortAtom)
    ->  atom_number(PortAtom, Port)
    ;   Port = 8080
    ).

% Root handler
handle_root(_Request) :-
    reply_json_dict(json{
        service: "prolog-api",
        status: ok,
        message: "SWI-Prolog HTTP API on sota.io"
    }).

% Health check
handle_health(_Request) :-
    reply_json_dict(json{status: ok}).

% List users (from in-memory knowledge base)
handle_users(_Request) :-
    findall(
        json{id: Id, name: Name, role: Role},
        user(Id, Name, Role),
        Users
    ),
    reply_json(Users, []).

% Reasoning endpoint — POST body with facts, returns conclusions
handle_reason(Request) :-
    http_read_json_dict(Request, Body),
    (   get_dict(query, Body, Query)
    ->  reason_about(Query, Conclusions),
        reply_json_dict(json{query: Query, conclusions: Conclusions})
    ;   reply_json_dict(json{error: "missing query field"}, [status(400)])
    ).

The knowledge base — your domain facts and rules — lives in a separate file:

% knowledge.pl

% Facts: user(Id, Name, Role)
user(1, "Anna Bergström", admin).
user(2, "Thomas Müller", developer).
user(3, "Sophie Lefebvre", viewer).

% Rules: authorised(UserId, Action)
authorised(UserId, Action) :-
    user(UserId, _, Role),
    role_permission(Role, Action).

role_permission(admin, _).
role_permission(developer, read).
role_permission(developer, write).
role_permission(viewer, read).

% Reasoning: given a user id string, return their permissions
reason_about(UserIdAtom, Conclusions) :-
    atom_number(UserIdAtom, UserId),
    findall(
        ActionStr,
        (authorised(UserId, Action), term_to_atom(Action, ActionStr)),
        Conclusions
    ).
reason_about(_, ["unknown user or no permissions"]).

PostgreSQL with SWI-Prolog

SWI-Prolog connects to PostgreSQL via ODBC or via the prosqlite pack. The ODBC approach is the most portable in a Docker environment:

% db.pl — PostgreSQL via ODBC
:- use_module(library(odbc)).

% Open a connection from environment variables
db_connect(Connection) :-
    getenv('DATABASE_URL', DatabaseURL),
    odbc_driver_connect(
        DatabaseURL,
        Connection,
        [null(null)]
    ).

% Close connection
db_disconnect(Connection) :-
    odbc_disconnect(Connection).

% Query users from database
db_users(Users) :-
    db_connect(Conn),
    odbc_query(Conn,
        "SELECT id, name, role FROM users ORDER BY id",
        Users,
        [types([integer, atom, atom])]
    ),
    db_disconnect(Conn).

% Single user lookup
db_user(UserId, Name, Role) :-
    db_connect(Conn),
    format(atom(SQL), "SELECT name, role FROM users WHERE id = ~w", [UserId]),
    odbc_query(Conn, SQL, row(Name, Role), []),
    db_disconnect(Conn).

The DATABASE_URL uses the standard connection string format: Driver={PostgreSQL Unicode};Server=localhost;Port=5432;Database=mydb;Uid=postgres;Pwd=secret

On sota.io, DATABASE_URL is injected automatically when you attach a PostgreSQL database to your project.

Dockerfile for SWI-Prolog

SWI-Prolog publishes official Docker images. A production Dockerfile that includes ODBC support:

FROM swipl:9.2.4-bullseye

WORKDIR /app

# Install ODBC and PostgreSQL ODBC driver
RUN apt-get update && apt-get install -y \
    unixodbc \
    odbc-postgresql \
    && rm -rf /var/lib/apt/lists/*

# Configure ODBC driver
RUN echo "[PostgreSQL Unicode]\n\
Description=PostgreSQL ODBC Driver\n\
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so\n\
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so\n\
FileUsage=1" > /etc/odbcinst.ini

# Copy application source
COPY . .

# Pre-compile for faster startup (optional but recommended)
RUN swipl -g "consult(main), halt" -t "halt(1)" 2>/dev/null || true

EXPOSE 8080

CMD ["swipl", "-g", "main", "main.pl"]

For a pure in-memory knowledge base (no database), the Dockerfile is simpler:

FROM swipl:9.2.4

WORKDIR /app
COPY . .

EXPOSE 8080

CMD ["swipl", "-g", "main", "main.pl"]

Test locally:

docker build -t prolog-api .
docker run -p 8080:8080 prolog-api

# In another terminal
curl http://localhost:8080/api/health
# {"status":"ok"}

curl http://localhost:8080/api/users
# [{"id":1,"name":"Anna Bergström","role":"admin"},...]

curl -X POST http://localhost:8080/api/reason \
  -H "Content-Type: application/json" \
  -d '{"query": "1"}'
# {"query":"1","conclusions":["read","write"]}

Deploy to EU with sota.io

sota.io is an EU-native PaaS that deploys containerised applications to German infrastructure. GDPR-compliant by default — your data never leaves the EU.

Install the CLI:

curl -fsSL https://sota.io/install.sh | bash

Deploy from your project directory:

cd your-prolog-project
sota deploy

sota.io detects the Dockerfile, builds the image, and deploys to EU infrastructure. The deploy typically completes in under two minutes.

Add PostgreSQL:

sota db create prolog-db
sota env set DATABASE_URL=$(sota db url prolog-db)

The DATABASE_URL is injected into your container at runtime. Your ODBC configuration reads it, and the connection is live.

Check deployment status:

sota status
sota logs --tail

Your Prolog API is now running on EU infrastructure — GDPR-compliant, managed PostgreSQL, automatic TLS, no DevOps required.

Prolog in the EU Research Ecosystem

Prolog has a strong institutional presence in European research that goes beyond its origins in Marseille.

INRIA (France) — the French national research institute for digital sciences — has produced significant Prolog tooling and research. The Constraint Logic Programming (CLP) extensions, which add constraint solving over finite domains, real numbers, and other structures, emerged largely from INRIA and related European groups. library(clpfd) in SWI-Prolog — written primarily by Markus Triska, an Austrian — implements constraint programming over finite domains and is used for scheduling, planning, and combinatorial problems.

KU Leuven (Belgium) maintains the CHR (Constraint Handling Rules) system, integrated into SWI-Prolog, which provides a high-level constraint language built on Prolog. KU Leuven's research group has produced work on probabilistic logic programming (ProbLog) and inductive logic programming (ILP) that feeds directly into modern AI systems.

Universiteit Amsterdam — Jan Wielemaker's institution — is the primary maintainer of SWI-Prolog. The SWI-Prolog semantic web libraries (library(semweb)) implement RDF, SPARQL, and OWL, making SWI-Prolog a serious platform for knowledge graph applications. These are used in biomedical ontology systems (including parts of the Gene Ontology infrastructure), digital humanities projects, and linked open data applications across European institutions.

Robert Kowalski at Imperial College London — British, and Prolog co-inventor alongside Colmerauer — formalised the theoretical basis for Prolog's execution model. His work on logic programming and the distinction between the "logic" and "control" components of a Prolog program remains foundational.

What Prolog Is Good For in 2026

The revival of interest in Prolog comes from several directions simultaneously.

Explainable AI. The EU AI Act creates a compliance requirement for transparency in high-risk AI systems. Prolog's proof trees are inherently transparent — every conclusion is backed by a traceable chain of rules. Hybrid systems that use neural networks for perception and Prolog for reasoning can satisfy explainability requirements that pure neural approaches cannot.

Knowledge graphs and semantic web. SWI-Prolog's RDF and SPARQL support makes it a natural backend for knowledge graph APIs. For EU biomedical, legal, or regulatory applications that consume linked open data, SWI-Prolog reduces the impedance between the data model and the query logic.

Configuration and policy engines. Complex business rules — pricing tiers, access control policies, eligibility criteria — are fundamentally logic problems. Expressing them in Prolog means the rules are readable by domain experts, testable independently of application code, and updatable without requiring redeployment of imperative logic.

Natural language processing pipelines. DCGs remain one of the cleanest ways to write context-free grammars that mix parsing and semantic construction. For building structured extraction pipelines — parsing regulations, contracts, clinical notes — Prolog's grammar notation reduces the gap between specification and implementation.

For teams where Prolog is the right tool, sota.io provides the simplest path to EU production.

Why EU Hosting for Prolog Applications

Prolog applications in enterprise environments typically handle sensitive data: medical records, legal documents, financial rules, personal data under GDPR. Hosting this workload on EU infrastructure is not just a compliance preference — for healthcare, legal, and financial applications in Germany, France, and the Netherlands, it is often a contractual or regulatory requirement.

German Datenschutz (BDSG + DSGVO). German enterprises subject to the Bundesdatenschutzgesetz require personal data to remain in German data centres. sota.io operates on German infrastructure.

French Health Data Hosting (HDS). Medical applications targeting French healthcare are subject to the Hébergeur de Données de Santé certification. EU-native infrastructure is a prerequisite.

GDPR Article 44. Transfers of personal data to third countries require adequacy decisions or standard contractual clauses. EU-native hosting eliminates the need for these mechanisms.

sota.io deploys to German infrastructure. Your Prolog knowledge bases, reasoning logs, and query data stay in the EU.

Summary

Prolog was born in Marseille in 1972, from Alain Colmerauer's work on natural language processing at the Université d'Aix-Marseille. SWI-Prolog, the most widely used implementation, was built by Jan Wielemaker at VU Amsterdam and has been maintained there for nearly four decades. The broader Prolog ecosystem — CLP(FD) from Markus Triska in Austria, CHR from KU Leuven in Belgium, semantic web libraries from Amsterdam — is deeply European.

For EU teams building AI reasoning systems, knowledge graph APIs, compliance engines, or natural language backends, Prolog offers an approach that no other language matches: domain logic expressed directly as logic, with built-in backtracking, constraint solving, and explainable proof traces.

Deploying SWI-Prolog to EU infrastructure with sota.io:

sota deploy          # build and deploy your Prolog app to EU infrastructure
sota db create       # managed PostgreSQL in Germany
sota env set KEY=VAL # inject DATABASE_URL and other config
sota logs --tail     # stream logs from your running container

Start deploying Prolog to Europe →


See also: Deploy Logtalk to Europe — object-oriented logic programming built on top of ISO Prolog (Paulo Moura 🇵🇹, University of Beira Interior), with protocols, categories, and EU AI Act explainability · Deploy ECLiPSe CLP to Europe — Prolog extended with CLP(FD) + ic interval constraints + CHR; ECRC Munich 🇩🇪, EU ESPRIT 1988, used industrially for airline crew rostering and rail scheduling · Deploy Mercury to Europe — logic-functional language with Haskell-style types and Prolog expressiveness · All languages on sota.io