ProLog
• Use any editor for writing the code of ProLog
• The extension of prolog file is .pl
Example 1:
1) Open SWI-Prolog, this window will open, here we execute the queries.
2) Now open “New Text Document” Editor, or any other editor for write the code and save the
file with .pl extension
3) Now load the file in Prolog using consult query, if it shows output “true”, its means file
loaded successfully.
4) Now if I write query language(urdu), it shows “False”. Reason is this is not present in data.
5) Now If I write query language(java), it shows true.
Example 2
Write the following code in editor.
% Facts
parent(john, mary).
parent(john, bob).
parent(susan, mary).
parent(susan, bob).
% Rule
sibling(X, Y) :- parent(Z, X), parent(Z, Y), X \= Y.
Write the following code on Prolog and run it
sibling(mary, bob).