Logic Programming
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
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.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.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…