CS 6795 Semantic Web Techniques

Lab 0


Syllabus
Assigns
Notes
Labs
Project
Resources

Installation and Testing of the SWI Prolog Development Environment

Install Instructions

1.    Download SWI Prolog from  http://www.swi-prolog.org/download/stable

E.g., in 2011 we downloaded this latest stable version for MSWindows: w32pl5105.exe

 

2.    Run w32pl5105.exe

 

3.    Download setup.zip from http://lakk.bildung.hessen.de/netzwerk/faecher/informatik/swiprolog/indexe.html

 

4.    Extract setup.zip.

E.g., choose C:\Program Files\SWIPrologEditor as the destination to extract into.

 

5.    Unzip the HTML Manual for XPCE from here http://www.swi-prolog.org/download/xpce/doc/userguide/userguide.html.tgz into the SWI-Prolog-directory /doc.

For us this meant that userguide.html is a file in the directory C:\Program Files\pl\doc

 

6.    Run the setup.exe file.

 

7.    You should be ready to go.

 

Test Examples

Adapted from Prolog tutorial, adding quicksort.

 

rules2.pl

 

mortal(X) :- human(X).

 

human(socrates).

 

 

rules5.pl

 

hold_party(X) :-

   birthday(X),

   happy(X).

 

birthday(tom).

birthday(fred).

birthday(helen).

 

happy(mary).

happy(jane).

happy(helen).

 

 

rules6b.pl

 

on_route_to_rome(rome).

on_route_to_rome(Place) :-

   move(Place,Method,NewPlace),

   on_route_to_rome(NewPlace).

 

move(gatwick,plane,rome).

move(halifax,train,gatwick).

move(home,taxi,halifax).

 

 

rules6c.pl

 

on_route_to_rome(rome, []).

on_route_to_rome(Place, [Method | Methods]) :-

   move(Place,Method,NewPlace),

   on_route_to_rome(NewPlace, Methods).

 

move(gatwick,plane,rome).

move(halifax,train,gatwick).

move(home,taxi,halifax).

 

 

quicksort.pl

 

quicksort([], []).

quicksort([Pivot|List], Sorted) :-

   partition(Pivot, List, L1, L2),

   quicksort(L1, L1S),

   quicksort(L2, L2S),

   append(L1S, [Pivot | L2S], Sorted).

 

partition(_Pivot, [], [], []).

partition(Pivot, [H | Tail], [H | L1], L2) :-

   H < Pivot,

   partition(Pivot, Tail, L1, L2).

partition(Pivot, [H | Tail], L1, [H | L2]) :-

   Pivot =< H,

   partition(Pivot, Tail, L1, L2).

 

append([], X, X).

append([H | T], T1, [H |T2]) :-

   append(T, T1, T2).

 

 


Maintained by Harold Boley