In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s....
-
Upload
hilary-holmes -
Category
Documents
-
view
220 -
download
0
description
Transcript of In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s....
1
In The Name Of Allah
Lab 03
Tahani Aldweesh
Tahani Aldweesh 2
objectivesSearching for the solution’s.Declaration.Query.Comments.Prolog Concepts.Unification.Disjunction.Conjunction.
Tahani Aldweesh 3
Searching for the solution’s
Consider the query : is there a person who likes both reading and swimming?
Tahani Aldweesh 4
cont
Likes(Person , reading) likes(Person , Swimming).
The solution are found through searching, matching and backtracking.
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.
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.
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
Tahani Aldweesh 8
Examples
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).
Tahani Aldweesh 10
Comments
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.
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.
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).
Tahani Aldweesh 14
Unification Examples
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).
Tahani Aldweesh 16
Disjunction “or”;“ – ”
Tahani Aldweesh 17
Conjunction “and”,“ – ”
Tahani Aldweesh 18
Steps for create new project
1 -)Open prolog program. 2 -)project new
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.
Tahani Aldweesh 20
Doubleclick
Class FactsClass Predicates
Run Statement
Tahani Aldweesh 21
Application in this lecture
Tahani Aldweesh 22
Execute the program
Tahani Aldweesh 23
Any Question
Tahani Aldweesh 24
ا�ال�ب�ت�س�ا�م�ة� ل�غ���������ة
ت�ح�ت�ا�ج� ال�إ�ل���������ى�
ت�ر�ج�م�����������ة� ...