Presentation is loading. Please wait.

Presentation is loading. Please wait.

1- Logic Programming with Prolog AI.....(A.Abeer Alshihri)1.

Similar presentations


Presentation on theme: "1- Logic Programming with Prolog AI.....(A.Abeer Alshihri)1."— Presentation transcript:

1 1- Logic Programming with Prolog AI.....(A.Abeer Alshihri)1

2 Introduction Logic Programming is the name given to a distinctive style of programming, very different from that of conventional programming languages such as C++ and Java. Fans of Logic Programming would say that 'different' means clearer, simpler and generally better! Although there are other Logic Programming languages, by far the most widely used is Prolog… The name stands for Programming in Logic. AI.....(A.Abeer Alshihri)2

3 There are only two components to any program: facts and rules. The Prolog system reads in the program and simply stores it. The user then types in a series of questions (strictly known as queries), which the system answers using the facts and rules available to it. AI.....(A.Abeer Alshihri)3

4 Used prolog in …..! Prolog has been used for a wide variety of applications. Many of these are in Mathematics and Logic. Some examples of the second type of application are :: programs for processing a 'natural language' text, to answer questions about its meaning, translate it to another language etc. applications for training. maintaining databases for the Human Genome project. AI.....(A.Abeer Alshihri)4

5 Environment of prolog ….! There are many versions of Prolog available for PC, Macintosh and Unix systems, including versions for Microsoft Windows, to link Prolog to an Oracle relational database and for use with 'object- oriented' program design. These range from commercial systems with many features to public domain and 'freeware‘ versions. Some of these are listed (in alphabetical order) below, together with web addresses at which more information can be found. These range from commercial systems with many features to public domain and 'freeware‘ versions. Some of these are listed (in alphabetical order) below, together with web addresses at which more information can be found. AI.....(A.Abeer Alshihri)5

6 Amzi! Prolog http://www.amzi.com/products/prolog_products.htm B-Prolog http://www.probp.com/ GNU Prolog http://gnu-prolog.inria.fr/ SWI Prolog http://www.swi-prolog.org/ Turbo Prolog (an old version that only runs in MS-DOS) http://www.fraber.de/university/prolog/tprolog.html Visual Prolog http://www.visual-prolog.com/ AI.....(A.Abeer Alshihri)6

7 SWI prolog SWI prolog SWI-Prolog is an open source implementation of the programming language Prolog, commonly used for teaching and semantic web applications. It has a rich set of features, libraries for constraint logic programming,multithreading, unit testing, GUI, interfacing to Java, ODBC and others..open sourceprogramming languagePrologsemantic weblibrariesconstraint logic programmingmultithreadingunit testingGUIJavaODBC SWI-Prolog runs on Unix, Windows and Macintosh platforms.UnixWindowsMacintosh SWI-Prolog has been under continuous development since 1987. Its main author is Jan Wielemaker. The name SWI is derived from Sociaal-Wetenschappelijke Informatica ("Social Science Informatics"), the former name of the group at the University of Amsterdam, where Wielemaker is employed.Jan WielemakerUniversity of Amsterdam AI.....(A.Abeer Alshihri)7

8 8

9 SWI-Prolog's website has lots of information about SWI-Prolog, a download area, and documentation. The upkeep for SWI-Prolog is excellent. The link... http://www.swi-prolog.org/ AI.....(A.Abeer Alshihri)9

10 Simple example.. This is a simple example, a series of queries and answers about animals...dog(fido).dog(rover).dog(henry).cat(felix).cat(michael).cat(jane).animal(X):-dog(X). AI.....(A.Abeer Alshihri)10

11 queries ?- dog(fido). yes ?-dog(jane). No [Is jane a dog? No - a cat] ?- animal(fido). Yes [Is fido an animal?] [yes - because it is a dog and any dog is an animal] ?- dog(X). X = fido ; X = rover ; X = henry [Is it possible to find anything, let us call it X, that is a dog?] [All 3 possible answers are provided] ?-animal(felix). No [felix is a cat and so does not qualify as an animal,as far as the program is concerned] AI.....(A.Abeer Alshihri)11

12 You have now seen all three elements needed for logic programming in Prolog: facts, rules and queries. There are no others. Everything else is built from them. There are no others. Everything else is built from them. AI.....(A.Abeer Alshihri)12

13 Starting SWI-Prolog Starting SWI-Prolog Under Windows, SWI-Prolog installs a start icon that can be double-clicked to initiate the interpreter. The interpreter then starts in its own command window. Interactive goals in Prolog are entered by the user following the '?- ' prompt. Many Prologs have command-line help information. SWI Prolog has extensive help information. This help is indexed and guides the user. To learn more about it, try ?- help(help) AI.....(A.Abeer Alshihri)13

14 abeeralshihri.weebly.com AI.....(A.Abeer Alshihri)14


Download ppt "1- Logic Programming with Prolog AI.....(A.Abeer Alshihri)1."

Similar presentations


Ads by Google