صفحه 1:
10016 0300 1

صفحه 2:
Prolog (Programming in Logic) Has been around since 70’s Prolog is an un-typed language Prolog is a declarative programming language Prolog is based on First Order (predicate) Logic Prolog was selected as the language of the fifth generation computers by the Japanese Prolog, is a suitable language for solving problems involving objects and relationships among these objects. A Prolog program consists of facts and rules.

صفحه 3:
Applications of Prolog AI programming Relational databases Natural languages Machine learning Robot planning Symbolic solution of equations Chemical structure analysis Expert Systems Mechanical Theorem Provers

صفحه 4:
olving a problem using Prolog involves Declaring facts Defining rules Asking questions iry likes john. ae john). cate(in lowercase) Arguments (in lowercase) 1e beginning with a lowercase letter is an atom ends with a full stop. nents are seperated with commas. rder of arguments is arbitrary but the order chosen must b consistently. -may have an arbitrary number of arguments.

صفحه 5:
All Prolog data objects are terms. For instance, mary likes(mary, john). and the variable X are all terms. A term may be simple or compound. A simple term may be An atom A number Or a variable. A compound term consists of a functor followed by a number of arguments. The number of arguments is referred to as the arity of the functor.

صفحه 6:
ugh we have to be consistent in the use of predicate and ol ‘s, they are arbitrary. We could have declared the above fa 1(m,j). would, however, make the program less readable. Other examples of facts interesting(declarative programming). useful(declarative programming). male(john). female(mary). father(john,mary). great(massey). has_a_job(mary). happy(john). plays(mary,john, tennis). valuable(money). gives(john,mary,money).

صفحه 7:
rolog database is a collection of facts (and rules). scree sea ‏را ت۱۱‎ likes(tom,mouse). 000 42 نا ل ا نا ‎likes(john, book).‏ ‎likes(mary,book).‏ ‎Likes(tom,john).‏ Now that we have some facts, we may ask ize). JB ere yee ery re

صفحه 8:
0 > getting a no answer because we do not have a fact in the se to indicate that mary and john know each other. This do ‘an that the statement is false in reality. It just means that : ased on the knowledge available. 17 ask questions involving variables. If we were interested i ; that like john, we would formulate the following query: ( 7 |

صفحه 9:
Prolog tries to resatisfy the question everytime we enter a semicolon “;”. Prolog uses a pointer called a place marker to keep track 01 ‏طعموعة عط‎ he Saeco anything. Every time the variable 0و a value like mary in the above example, we say that X is ‏ا ا‎ to that value. In the example above, X was instantiated ‏زتنس ند‎ ۱ ‏.مها مر‎ aN) ‏نا‎ abn Query ۳ ‏رازه۰ ور(‎ Y=jerry; ‏مت سنا‎ = i eas oe Y=john; ‏,0ع امسطصام) عسل‎ ‏صصص )صملا‎ ae Y=mouse; زا 0 i 1) 7

صفحه 10:

صفحه 11:
Saul ory In the above database we have a fact indicating that mary likes john. This however does not make the fact that john also likes mary true. If we wanted that to be true, we would have to add a ‏مات‎ ۱ make this a generalization by adding a rule ۳ ‏دهعت‎

صفحه 12:
Jther examples of rules: X):-valuable(X X is a bird if it is an animal and it has feathers. is_a_bird(X):- is_an_animal(X),has(X,feathers). is brother of Y if X is a male and X and Y have the same parents. is_brother_of(X,Y):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother).

صفحه 13:
Another database

صفحه 14:
-is brother of(greg,andrew). Yes ۱ 1 ‏وت الت ا ات‎ Yes ?- is brother _of(greg,X). X = greg; X = jennifer ; X = andrew ; No male(andrew). male(john). male(george). male(greg). male(adam). female(mary). female(jennifer). female(eve). parents(john,george,mary). parents(greg,adam,eve). parents(jennifer, adam,eve). parents(andrew, adam,eve). is_brother_of(X,¥):-male(X), parents(X, Father, Mother), parents(Y, Father, Mother). = greg is_sister_of(X,Y):-female(X), ‏كما ممح عد‎ = 2 arents(X, Father, Mother), ue andrew ; parents ۱۷, Mother ما اما امس مها

صفحه 15:
SWI-Prolog % d:/Prolog/sis.pl compiled 0.00 sec, 2,048 bytes Welcome to SWI-Prolog (Version 4.0.9) Copyright (c) 1990-2000 University of Amsterdam. Copy policy: GPL-2 (see www.gnu.org) For help, use ?- help(Topic). or ?- apropos(Word). ?-is_sister_of(X,Y). عكتسموز < 216 ز و۲ < ۷ 0 ا ا : ااعلمة ع لآ ‎No‏ 0 ل رم

صفحه 16:

صفحه 17:
Welcome to SWI-Prolog (Version 4.0.9) Copyright (c) 1990-2000 University of Amsterdam. Copy policy: GPL-2 (see www.gnu.org) For help, use ?- help(Topic). or ?- apropos(Word). y Prolog now.

صفحه 18:
?- append ([abc,def],[ghi,lmn],L). L = [abe, def, ghi, Imn] Yes ?- append([abc,def],L, [abc,def,ghi,lmn]). L = [ghi, Imn]

صفحه 19:
Consult mode You can enter consult mode by typing in “[user]” ‏قط خدج‎ ”2-” ۱3 forget the period at the end of your input. At the “|:” , type in what you want entered into your database. ale(john). male(mary). ther(john,mary). eat(massey). 1S_a_job(mary). 1e last fact is entered and at the “|:” prompt, enter a « » consult mode. An example is shown on the next slide

صفحه 20:
?- [user]. : likes(tom, jerry). : likes(mary,john). : likes(tom,mouse). : likes(tom,jerry). : likes(Gjerry,cheeze). : likes(mary, fruit). : likesGohn,book). : knows(mary,book). : knows(tom, john). % user compiled 0.01 sec, 64 bytes ‏كد‎ 0007 ۱۱۱ Tea ae .لططامز ,لقص )ىم 1ن[ ‎likes(tom, mouse).‏ .وز بحدهغ )م111 ‎likes(jerry, cheeze).‏ ‎likes(mary, fruit),‏ ‎likes(john, book).‏ ‎knows(mary, book).‏ .لصطه زيصدم]) دم دعل 0 ]| ۵5

صفحه 21:
Listing your predicates

صفحه 22:
?- listing(likes/2). /* we could have said “listing(likes).” in this case*/ likes(tom, jerry). likes(mary, john). likes(tom, mouse). likes(tom, jerry). likes(jerry, cheeze). likes(john, book). ?- listing(knows). knows(mary,book) knows(tom,john).

صفحه 23:

صفحه 24:
?- trace. Yes [trace] ?- likes(X,Y). Call: (7) likes(_G332, _G333) ? creep Exit: (7) likes(tom, jerry) ? creep X= tom = jerry; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(mary, john) ? creep X= mary Y = john Redo: (7) likes(_G332, G333) ? creep Exit: (7) likes(tom, mouse) ? creep X=tom Y = mouse ; Redo: (7) likes(_G332, _G333) ? creep : (7) likes(tom, jerry) ? creep

صفحه 25:
2 < 7 Y = cheeze ; Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(mary, fruit) ? creep X = mary Y= fruit, Redo: (7) likes(_G332, _G333) ? creep Exit: (7) likes(john, book) ? creep X = john Y = book; Fail: (7) likes(_G332, G333) ?

صفحه 26:

صفحه 27:
owns(john, book). owns(victoria, boo owns(george, book owns(john,book(prolog,clocksin_and_m\ owns(victoria, book(prolog,bratko)). owns(john,book(prolog,author(clocksin_and_mellish),year(1994 owns(victoria, book(prolog,author(bratko),year(2001),edit} ‎oe‏ 6 نخس 9 مسا ‎ ‎

صفحه 28:

صفحه 29:

صفحه 30:

صفحه 31:
?- concen(X,Y). X=us 91.6667 Y= Yes ?- concen(X,Y). X=us ; 91.6667 ‎china‏ ‏و وا nz Y= x Y= X= Y=16; X = india 304.136 ; Y= No

جهت مطالعه ادامه متن، فایل را دریافت نمایید.
34,000 تومان