100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

Prolog

AdvancedLanguage9.8K learners

Prolog is a declarative, logic-based programming language in which programs are expressed as facts and rules, and computation proceeds by the language's engine searching for answers that satisfy logical queries.

Definition

Prolog is a declarative, logic-based programming language in which programs are expressed as facts and rules, and computation proceeds by the language's engine searching for answers that satisfy logical queries.

Overview

Unlike imperative or object-oriented programming languages that describe step-by-step instructions, Prolog programs describe relationships and rules using formal logic; the programmer states what is true, and Prolog's built-in inference engine uses unification and backtracking search to determine what follows from those statements when queried. A simple Prolog knowledge base might declare that `parent(tom, bob)` and a rule that `grandparent(X, Z) :- parent(X, Y), parent(Y, Z)`, after which the system can automatically answer queries about grandparent relationships it was never explicitly told. Developed in the early 1970s and closely associated with the field of artificial intelligence, Prolog became a foundational language for symbolic AI, expert systems, and natural language processing research through the 1980s, and it was notably chosen as the implementation language for Japan's Fifth Generation Computer Systems project. Its declarative, rule-based style also made it well suited to constraint satisfaction problems, theorem proving, and other domains where the problem is more naturally expressed as logical relationships than sequential steps. While Prolog is no longer mainstream for general software development, it persists in niche applications — some expert systems, certain natural language and knowledge-representation tools, and academic courses on logic programming and artificial intelligence — where its declarative approach to reasoning over facts and rules remains uniquely well suited compared to purely procedural or object-oriented approaches. It is often mentioned alongside Recursion in this space. It is often mentioned alongside Functional Programming in this space.

Key Features

  • Declarative, logic-based programming model built on facts and rules
  • Automatic search via unification and backtracking
  • Queries return all solutions that satisfy given logical constraints
  • Strong historical ties to symbolic artificial intelligence research
  • Well suited to constraint satisfaction and rule-based reasoning
  • Distinct execution model from imperative and object-oriented languages

Use Cases

Expert systems and rule-based reasoning engines
Natural language processing and parsing research
Academic instruction in logic programming and AI
Constraint satisfaction and combinatorial search problems
Symbolic AI and automated theorem proving

Frequently Asked Questions