Upload
aliknf
View
231
Download
4
Embed Size (px)
Citation preview
١
Engineering Engineering Engineering Engineering Systems Systems Systems Systems Design and Analysis Design and Analysis Design and Analysis Design and Analysis (ENG (ENG (ENG (ENG 504504504504))))
أحمد محمد حلميأحمد محمد حلمي/ / ددقسم هندسة الحاسبات و المنظومات قسم هندسة الحاسبات و المنظومات
جامعة الزقازيقجامعة الزقازيق––كلية الهندسة كلية الهندسة
Email: [email protected] / [email protected]
Webpage: http://www.staff.zu.edu.eg/amhm/
Lecture Lecture Lecture Lecture 5555
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
1
�Branch and bound algorithm
� Examples:
� Travelling Salesman Problem
� Scheduling Problems
� Expert systems
� Propositional logic
In the previous lectureIn the previous lectureIn the previous lectureIn the previous lecture
٢
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
2AgendaAgendaAgendaAgenda
� Expert systems
� Predicate logic
Predicate LogicPredicate LogicPredicate LogicPredicate LogicPredicate LogicPredicate LogicPredicate LogicPredicate Logic
٣
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
3Limitations of Propositional Logic Limitations of Propositional Logic Limitations of Propositional Logic Limitations of Propositional Logic
� Statements about similar objects and relations need to be enumerated:
� Doesn’t deal with relations.
� Can’t combine evidences.
� Statements referring to groups of objects require exhaustive enumeration
of objects:
� Can’t express quantification.
� Can’t deal with uncertain information.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
4
� It is called also First-Order Logic (FOL).
� In English, the predicate is the part of the sentence that tells you something
about the subject.
� A predicate is a verb phrase template that describes a property of objects,
or a relationship among objects represented by the variables.
� Example 1: "The car Tom is driving is blue",
“The sky is blue“,
"The cover of this book is blue"
� Predicate: “x is blue“ which describes the property of being blue.
� We can give this predicate a name, i.e., B(x)
� Thus, “x” is an arbitrary object and B(x) reads as “x is blue”.
Predicate Logic Predicate Logic Predicate Logic Predicate Logic
٤
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
5Predicate Logic Predicate Logic Predicate Logic Predicate Logic
�Example 2: "John gives the book to Mary",
"Jim gives a toy to Tom",
"Jane gives a lecture to Mary",
� Predicate: “x gives y to z“ which describes a relationship bet. 3 objects.
� Name: G(x,y,z)
� x,y,z are variables, while “John”, “Mary”, ”Jane”, ”Jim” and “Tom” are
objects.
Notice that a predicate becomes a proposition when specific
values (objects) are assigned to its variables.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
6Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� As we did when studying propositional logic, we have to look on:
� Syntax.
� Semantics.
� Inference rules.
� Syntax:
� Symbols:
� Constants: objects.
� Functions: to check a property of its variables.
� Predicate: a true/false relationships bet. objects.
� Connectives : AND, OR, NOT,.. (as in propositional logic).
� Quantifiers: i.e., “∃∃∃∃” which means “there exists” and “∀∀∀∀” which means
“for all”.
٥
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
7Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Each predicate variable has a Domain or Universe which is the set of values that
can be assigned to the variable.
� Thus, If P(x) is a predicate and x has domain U, the truth set of P(x) is the set
of all elements in U such that P(t) is true.
� Example:
� U={1,2,3,4,5,6,7,8,9,10}
� P(x): “x is prime”
� The truth set is {1,2,3,5,7}
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
8Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Quantifiers:
� “∀∀∀∀x” which means “for all x in its domain” is called the universal quantifier.
� Example: “All Human are Mortals”, here is its FOL translation:
� predicate: “All x are y”
� H(x): x is a human
� M(y): y is mortal
� ∀∀∀∀x, H(x) ⇒⇒⇒⇒ M(x)M(x)M(x)M(x)
� “∃∃∃∃x” which means “at least, there exists one value of x from its domain” is
called the existential quantifier.
� Example: “Some numbers are prime”
� P(x): “x is prime”
�∃∃∃∃x, P(x)
٦
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
9Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Example 1: Translate the following quantified statements into English:
1. U(x) = ℝ,
P(x): x2 > 0
∀x, P(x)
Answer: For every rational number, the quadratic function gives positive value.
2. U(x) = ℝ,
M(x): x > 3
B(x): x3 > 27
∃x, M(x) ∧ B(x)
Answer: There exists one rational number such that it is greater than 3 and its
cubic is greater than 27.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
10Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Example 2: Write the FOL representation:
1. No School bus is black
Answer: Predicate: “No x is y”
S(x): “x is a school bus”
B(y): “y is black”
ᄀ ∀x, S(x) ⇒⇒⇒⇒ B(x) or ∀x, S(x) ⇒⇒⇒⇒ ᄀ B(x)
2. Some uncles are younger than their nephews
Answer: Predicate:”x is younger than y” S(x,y): “x is younger than y”
P(x): “x is an uncle”
N(y): “y is a nephew”
∃x,y, S(P(x),N(y))
٧
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
11Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Notice that: If U={1,2,3}, then
∀∀∀∀x, P(x) is equivalent to P(1) ∧ P(2) ∧ P(3)
∃∃∃∃x,P(x) is equivalent to P(1) ∨ P(2) ∨ P(3)
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
12Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� DeMorgan’s low for quantifiers:
ᄀ∀∀∀∀x, P(x) ⇔ ⇔ ⇔ ⇔ ∃∃∃∃x ,ᄀP(x)
ᄀ∃∃∃∃x,P(x) ⇔⇔⇔⇔ ∀∀∀∀x, ᄀP(x)
� Exercise 1: Write the FOL representation for:
� Some drivers do not obey the speed limit
� Not all dogs are dangerous
٨
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
13Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Quantifiers plus ∧ and ∨:
� ∀ distributes over ∧ :
∀∀∀∀x, (P(x) ∧ Q(x)) ⇔⇔⇔⇔∀∀∀∀x,P(x) ∧ ∀∀∀∀x,Q(x)
� ∃ distributes over ∨:
∃x,(P(x) ∨ Q(x)) ⇔⇔⇔⇔∃x,P(x) ∨ ∃x,Q(x)
� But notice that: ∃x,(P(x) ∧ Q(x)) ⇒⇒⇒⇒ ∃x,P(x) ∧ ∃x,Q(x) is True.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
14Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Rules of inference:
1. Universal Modus ponens:
where “c” is some element in P’s domain.
∀∀∀∀x, (P(x) ⇒⇒⇒⇒ Q(x))
P(c)
∴∴∴∴ Q(c)
Given
Conclusion
٩
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
15Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Rules of inference:
2. Universal Modus Tollens :
∀∀∀∀x, (P(x) ⇒⇒⇒⇒ Q(x))
ᄀQ(c)
∴∴∴∴ ᄀP(c)
Example:
All dogs bark
Roy does not bark
∴∴∴∴ Roy is not a dog
U = all living creatures,
P(x): x is a dog,
Q(x): x barks.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
16Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Rules of inference:
3. Universal Hypothetical Syllogism:
like the chain rule!
∀∀∀∀x, (P(x) ⇒⇒⇒⇒ Q(x))
∀∀∀∀x, (Q(x) ⇒⇒⇒⇒ R(x))
∴∴∴∴ ∀∀∀∀x, (P(x) ⇒⇒⇒⇒ R(x))
١٠
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
17Predicate Logic Predicate Logic Predicate Logic Predicate Logic
� Problem formulation in general:
� Given: a story that describes properties and relations between objects.
� Questions:
� A query which requires an answer
(i.e., is there an object that has such and such?)
� Check if a proposition is true or false.
� Proof a proposition.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
18Predicate Logic Predicate Logic Predicate Logic Predicate Logic
Example Example 33::
A horse that is registered for today’s race is not a thoroughbred.
Every horse registered for today’s race has won a race this year.
Therefore a horse that has won a race this year is not a thoroughbred. Proof?
Solution:
� Predicates: P(x): x is registered for today’s race
Q(x): x is a thoroughbred
R(x): x won a race this year
� Domain: all horses.
� FOL representation: ∃x, (P(x) ∧ ᄀQ(x))
∀∀∀∀x, (P(x) ⇒ ⇒ ⇒ ⇒R(x))
∃x, (R(x) ∧ ᄀQ(x))
١١
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
19Predicate Logic Predicate Logic Predicate Logic Predicate Logic
Example Example 33: : Solution:
� To proof that ∃x, (R(x) ∧ ᄀQ(x)) we use the inference rules:
ReasonStep
Given∃x, (P(x) ∧ ᄀQ(x))1
From 1P(a) ∧ ᄀQ(a), for some a 2
From 1P(a) 3
From 1ᄀQ(a)4
Given∀∀∀∀x, (P(x) ⇒ ⇒ ⇒ ⇒R(x))5
From 5R(a) ⇒ ⇒ ⇒ ⇒P(a)6
From 3,6R(a)7
From 4,7R(a) ∧ ᄀQ(a)8
From 8∃x, (R(x) ∧ ᄀQ(x)) 9
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
20Predicate Logic Predicate Logic Predicate Logic Predicate Logic
Example Example 44::
Tony, Shi-Kuo and Ellen belong to the Hoofers Club. Every member of the
Hoofers Club is either a skier or a mountain climber or both. No mountain
climber likes rain, and all skiers like snow. Ellen dislikes whatever Tony likes and
likes whatever Tony dislikes. Tony likes rain and snow.
Query: Is there a member of the Hoofers Club who is a mountain climber but
not a skier?
١٢
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
21Example Example 44: : Solution:
� Predicates: S(x) : x is a skier , Domain: Hoffers club
M(x) : x is a mountain climber, Domain: Hoffers club
L(x,y) : x likes y, Domain of y: snow and rain.
� FOL representation: ∀∀∀∀x,S(x) v M(x)
M(x) ⇒⇒⇒⇒ ᄀL(x, Rain)
∀∀∀∀x,S(x) ⇒⇒⇒⇒ L(x, Snow)
ᄀL(Tony, x) ⇒⇒⇒⇒ L(Ellen, x)
L(Tony, x) ⇒⇒⇒⇒ ᄀL(Ellen, x)
L(Tony, Rain)
L(Tony, Snow)
M(x) ∧ ᄀS(x) ? If true, who is x?
Predicate Logic Predicate Logic Predicate Logic Predicate Logic
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
22
Step
∀x,S(x) v M(x) 1
M(x) v S(x)2
M(x) ⇒⇒⇒⇒ᄀL(x, Rain) 3
∀∀∀∀x,S(x) ⇒⇒⇒⇒ L(x, Snow) 4
ᄀL(Tony, x) ⇒⇒⇒⇒ L(Ellen, x) 5
L(Tony, Snow) 6
ᄀL(Ellen, Snow) 7
ᄀS(Ellen) 8
M(Ellen)9
M(Ellen) ∧ ᄀS(Ellen) 10
Predicate Logic Predicate Logic Predicate Logic Predicate Logic
Example Example 44: : Solution:
Reason
given
From 1
given
given
given
given
From 5,6
From 7,4
From 9,2
From 10
Answer is Ellen
١٣
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
23Applications Applications Applications Applications
� There are programming languages that are built upon the concepts of predicate
logic, i.e., PROLOG (programming in logic).
� There are numerous examples of Expert Systems that are based on rule-based
reasoning:
� DENDRAL : Infers molecular structure from the information provided by
a mass spectrometer
� MYCIN: Diagnosis of blood infections, 450 rules; performs as well as
experts
� PROSPECTOR: Correctly recommended exploratory drilling at geological
site
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504) Zagazig Univ-Eng. Faculty 2013/2014Eng. Sys. Design and Analysis (ENG 504)
24
� Given the following paragraph:
“Jack owns a dog. Every dog owner is an animal lover.
No animal lover kills an animal. Either Jack or Curiosity killed the
cat, who is named Tuna. Did Curiosity kill Tuna? ”
Answer the query using predicate logic rules, your answer should
include:
1. Predicate statements.
2. FOL representation.
3. Inference steps.
4. Answer to the query.
Assignment #Assignment #Assignment #Assignment #2 2 2 2
١٤
ThanksThanks