Tutorial by Examples

SWI-Prolog Windows and Mac: Download SWI-Prolog at the official website Simply install by following the installer instructions. Linux (PPA): Add the PPA ppa:swi-prolog/stable to your system’s software sources (developers may choose for ppa:swi-prolog/devel) : Open a terminal (Ctrl+...
append([], Bs, Bs). append([A|As], Bs, [A|Cs]) :- append(As, Bs, Cs). append/3 is one of the most well-known Prolog relations. It defines a relation between three arguments and is true if the third argument is a list that denotes the concatenation of the lists that are specified in the firs...
CLP(FD) constraints are provided by all serious Prolog implementations. They allow us to reason about integers in a pure way. ?- X #= 1 + 2. X = 3. ?- 5 #= Y + 2. Y = 3.
Prolog categorizes everything into: Atoms - Any sequence of characters that do not start with an uppercase alphabet. Eg - a, b, okay Numbers - There is no special syntax for numbers, no declaration is required. Eg 1, 22, 35.8 Variables - A string which starts with an uppercase character or unde...
Hello, World in the interactive interpreter To print "Hello, World!" in the Prolog interpreter (here we are using swipl, the shell for SWI Prolog): $ swipl <...banner...> ?- write('Hello, World!'), nl. ?- is the system prompt: it indicates that the system is ready for the user...

Page 1 of 1