in the name of allah lab 03 1tahani aldweesh. objectives searching for the solution’s....
DESCRIPTION
Searching for the solution’s Consider the query : is there a person who likes both reading and swimming? 3Tahani AldweeshTRANSCRIPT
![Page 1: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/1.jpg)
1
In The Name Of Allah
Lab 03
Tahani Aldweesh
![Page 2: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/2.jpg)
Tahani Aldweesh 2
objectivesSearching for the solution’s.Declaration.Query.Comments.Prolog Concepts.Unification.Disjunction.Conjunction.
![Page 3: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/3.jpg)
Tahani Aldweesh 3
Searching for the solution’s
Consider the query : is there a person who likes both reading and swimming?
![Page 4: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/4.jpg)
Tahani Aldweesh 4
cont
Likes(Person , reading) likes(Person , Swimming).
The solution are found through searching, matching and backtracking.
![Page 5: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/5.jpg)
Tahani Aldweesh 5
Declaration in visual prologPredicate and their argument must be declared.They are declared in predicate section.Clauses for the predicate are given in clauses section.Dynamic facts can be given in the facts section.Execution starts in the Goal section.
![Page 6: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/6.jpg)
Tahani Aldweesh 6
Query: true / falseIn natural language we ask you :
Does Bill Like Cindy?
In prolog syntax, we ask prolog: Likes(bill, cindy).
Given this query , prolog would answer: Yes.
![Page 7: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/7.jpg)
Tahani Aldweesh 7
Queries : getting answersWe could ask you in natural language: What does bill like?
In prolog syntax , we ask prolog : Likes ( bill, What).
Prolog will return: What=cindyWhat=dog
2 Solutions
![Page 8: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/8.jpg)
Tahani Aldweesh 8
Examples
![Page 9: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/9.jpg)
Tahani Aldweesh 9
Using Underscore as a variable
The anonymous can be used in place of any other variable. The difference is that the anonymous
variable will never get set to value :GOAL Parent(Parent, _ ).But it can also be used in facts!
owns(_ , shoes).GOAL owns(bill,shoes).GOAL owns(gane,shoes).
![Page 10: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/10.jpg)
Tahani Aldweesh 10
Comments
![Page 11: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/11.jpg)
Tahani Aldweesh 11
Prolog ConceptsUnification :
passing parameter ,dealing with assignment , Case selection ,etc.
Search principle:Searching for success (or failure).Top-down, right to left.
Backtracking: Providing multiple solutions.Non-determisme, determinism and cut.
Recursion.
![Page 12: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/12.jpg)
Tahani Aldweesh 12
UnificationUnification is performed when a goal or sub-goal
Is matched against a suitable fact or left hand side of rule.
Unification is made between : The 1st parameter in the goal (sub-goal).And 1st parameter in fact/rule-head.
“=“means Unification.
![Page 13: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/13.jpg)
Tahani Aldweesh 13
Unification and matchingIdentical values match each other:Parent(joe,tammy)matches parent(joe,tammy).A free variable can match with any value:Parent(joe, X)matches parent(joe,tammy).A bound variable matched only with it is bound to:
X=tammy, Parent(joe,X)matches parent(joe,tammy).Two free variable s unifies each other:Parent(joe,X)matches parent(joe,Y).
![Page 14: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/14.jpg)
Tahani Aldweesh 14
Unification Examples
![Page 15: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/15.jpg)
Tahani Aldweesh 15
Unification and calculation
Visual Prolog support the most know used mathematical functions. They can be tried out
by : Unifying a free variable with various calculation ,for example:
GOAL X=sqrt(4)*7+1Visual Prolog support logical expressions like:GOAL not(2<=4).
![Page 16: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/16.jpg)
Tahani Aldweesh 16
Disjunction “or”;“ – ”
![Page 17: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/17.jpg)
Tahani Aldweesh 17
Conjunction “and”,“ – ”
![Page 18: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/18.jpg)
Tahani Aldweesh 18
Steps for create new project
1 -)Open prolog program. 2 -)project new
![Page 19: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/19.jpg)
Tahani Aldweesh 19
3 -)Build Build .4 -)Build Execute.
5 -)Look at the project tree a file is created named “same name your proj.pro”, double click on it and put your code.
![Page 20: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/20.jpg)
Tahani Aldweesh 20
Doubleclick
Class FactsClass Predicates
Run Statement
![Page 21: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/21.jpg)
Tahani Aldweesh 21
Application in this lecture
![Page 22: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/22.jpg)
Tahani Aldweesh 22
Execute the program
![Page 23: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/23.jpg)
Tahani Aldweesh 23
Any Question
![Page 24: In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction](https://reader036.vdocument.in/reader036/viewer/2022062413/5a4d1b517f8b9ab0599a7d80/html5/thumbnails/24.jpg)
Tahani Aldweesh 24
ا�ال�ب�ت�س�ا�م�ة� ل�غ���������ة
ت�ح�ت�ا�ج� ال�إ�ل���������ى�
ت�ر�ج�م�����������ة� ...