prolog installation, hello world program and run it

Prolog is a programming language developed by Alain Colmerauer in 1972. It is a logic programming language associated with artificial intelligence and computational linguistics. Unlike any other programming languages, prolog’s program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations. Its source code files are often with the extension “.pl”.

Note: prolog statements or expressions or functions end with a period .

Download From

Installation for Mac users
After you’ve downloaded the installer zip package, unpack it and run the installer, and it will install the binary to


To launch the prolog, type swipl in the Terminal.


To quit, press Ctrl-z

Prolog helloworld program,

/*Prolog Hello World Program*/
hello :- write('Hello World, This is my first program in Prolog!!!').

To run the prolog hello world program
1. Assume the above code is in a file called, launch the prolog console from Terminal by


2. In prolog console, type the following to load the hello program


And then type the following to run it


3. To print the string directly in the prolog console, type the following

write('Hello World, This is my first program in Prolog!!!').

4. To quit prolog console, press Ctrl-z

Search within Codexpedia

Custom Search

Search the entire web

Custom Search