Logic Programming

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Logic Programming

Logic programming is a programming paradigm that uses rules and facts to describe the problem to be solved. It's based on formal logic, which is a branch of mathematics that deals with statements that are either true or false. In logic programming, you define a set of rules and facts, and the program uses these rules and facts to derive new information.

It is one type of declarative programming paradigm, which means that you describe what you want to happen, rather than how to make it happen.

Here's an example of logic programming in Prolog, a popular logic programming language:

% Facts
likes(goku, chichi).
likes(chichi, gohan).
likes(gohan, goku).

% Rules
likes_each_other(X, Y) :- likes(X, Y), likes(Y, X).

In this example, we have three facts and a rule. The rule says that if X likes Y and Y likes X, then they like each other. From these facts and this rule, Prolog will be able to determine if Gohan likes Goku, or if Goku likes Gohan:

?- likes_each_other(goku, gohan).
true.
Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!