Download presentation
Presentation is loading. Please wait.
Published byHilary Holmes Modified over 9 years ago
1
In The Name Of Allah Lab 03 1Tahani Aldweesh
2
objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction. Conjunction. 2Tahani Aldweesh
3
Searching for the solution’s Consider the query : is there a person who likes both reading and swimming? 3Tahani Aldweesh
4
cont Likes(Person, reading) likes(Person, Swimming). The solution are found through searching, matching and backtracking. 4Tahani Aldweesh
5
Declaration in visual prolog Predicate 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. 5Tahani Aldweesh
6
Query: true / false In 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. 6Tahani Aldweesh
7
Queries : getting answers We could ask you in natural language : What does bill like ? In prolog syntax, we ask prolog : Likes ( bill, What). Prolog will return : What=cindy What=dog 2 Solutions 7Tahani Aldweesh
8
Examples 8Tahani 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). 9Tahani Aldweesh
10
Comments 10Tahani Aldweesh
11
Prolog Concepts Unification : 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. 11Tahani Aldweesh
12
Unification Unification 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 1 st parameter in the goal (sub-goal). And 1 st parameter in fact/rule-head. “=“ means Unification. 12Tahani Aldweesh
13
Unification and matching Identical 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). 13Tahani Aldweesh
14
Unification Examples 14Tahani 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+1 Visual Prolog support logical expressions like: GOAL not(2<=4). 15Tahani Aldweesh
16
Disjunction “or” – “;” 16Tahani Aldweesh
17
Conjunction “and” – “,” 17Tahani Aldweesh
18
Steps for create new project 1)- Open prolog program. 2)- project new Tahani Aldweesh18
19
Tahani Aldweesh19 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.
20
Tahani Aldweesh20 Double click Class Facts Class Predicates Run Statement
21
Application in this lecture Tahani Aldweesh21
22
Execute the program Tahani Aldweesh22
23
Any Question 23Tahani Aldweesh
24
24Tahani Aldweesh
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.