Professional Documents
Culture Documents
PCPF Experiment No - 11 Prolog: Steps For Installing SWI Prolog in Windows
PCPF Experiment No - 11 Prolog: Steps For Installing SWI Prolog in Windows
PCPF Experiment No - 11 Prolog: Steps For Installing SWI Prolog in Windows
PROLOG
Steps for installing SWI Prolog in Windows.
Mouse over Download.
Click SWI-Prolog
This will take you download page: https://www.swi-prolog.org/Download.html
a. Select I understand
b. Click Download swipl-8.3.6-1.x64.exe
This will open a Save As dialog on Windows. Select a directory and click Save.
Then click Yes.
This will start the installation wizard.
Click Next
Click Next
B) Steps to write, compile & execute Prolog code using simple example.
D) Observe trace in Prolog for same example and also for predicate.
THEORY :
Recursion in any language is a function that can call itself until the goal has been succeed. Recursion
is an extremely powerful tool and one which is widely used in Prolog programming. In Prolog,
recursion appears when a predicate contain a goal that refers to itself. In Prolog and in any language,
a recursive definition always has at least two parts.
A first fact that acts like a stopping condition and a rule that call itself simplified. At each level the first
fact is checked. If the fact is true then the recursion ends, if not the recursion continue.
A recursive rule must never call itself with the same arguments, if that happens then the program will
never end.
Lists in Prolog are themselves terms, and consist of a sequence of terms separated from one-another
by commas and enclosed at each end by matching square brackets.
The first element of a list is called the head of the list, and the remainder is called the tail of the list.
Note that the last element of every non-empty list is the empty list; although the normal Prolog
notation suppresses this fact.
Because of the importance of the distinction between the head and tail of a list, Prolog provides a
convenient notation that can be used to match against the head and tail of any list.
[X | Y]
Where X will match against the head, and Y against the tail.
CODE :
OUTPUT :
CODE :
OUTPUT :
CODE :
OUTPUT :
CONCLUSION :