Upload
cheche
View
47
Download
0
Tags:
Embed Size (px)
DESCRIPTION
4.0 Knowledge Representation. Outline 4.1 Introduction 4.2 Knowledge Representation schemes. 4.3 Propositional Calculus (PC) 4.3.1 PC Symbols and Sentences 4.3.2 Syntax of the propositional calculus 4.3.3 Semantics of PC 4.3.3.1 logic Laws and inference rules - PowerPoint PPT Presentation
Citation preview
1
4.0 Knowledge RepresentationOutline
4.1 Introduction4.2 Knowledge Representation schemes. 4.3 Propositional Calculus (PC) 4.3.1 PC Symbols and Sentences 4.3.2 Syntax of the propositional calculus 4.3.3 Semantics of PC 4.3.3.1 logic Laws and inference rules4.3.3.2 Classification of Compound Propositions4.3.4 Exercises4.4 Predicate Calculus 4.4.1 Syntax of predicate calculus4.4.2 Some predicate calculus equivalences 4.4.3 Inference rules 4.5 Semantic Networks
4.5.1 Representation of Some Relations 4.5.2 Inheritance in Semantic Networks 4.6 Conceptual Graphs4.6.1 Types and individuals 4.7 Frame Structure4.7.1 Examples
2
4.1 Introduction
AI System
Knowledge Base (KB) Inference Mechanism
Facts about objects: properties and relations
Rules,Procedures, Theories
Set of procedures to examine the KB in an orderly manner to answer questions, solve problems, or make decisions within the KB domain
3
4.2 Knowledge Representation schemes
Logic Representation
Network Representation
Structural Representation
Propositional Calculus
Predicate Calculus
Semantic Networks
Conceptual Graphs
Frame Structures
4
4.3 Propositional Calculus• Proposition:
is a statement about the world that is either true or false.
It is a declarative sentence.
Examples : P= “It is hot”& Q =“The earth orbits the sun” are propositions. R=“can you play tennis” is not a proposition.
• Premise: is a proposition which is assigned a logical value( true or false).
Example : P is true
• Rules are used to draw new propositions from known premises
• Example Q=“We are in summer”, P=“It is hot”• Rule: QP
Premise or antecedent
conclusion or consequent
Interpretation of P = assertion of its truth value
5
4.3.1 Propositional Calculus Symbols and Sentences
4.3.1.1 Symbols:• Propositional
symbols:P,Q,R,S,…..
• Truth symbols: true, false
• Connective symbols:Not(┐,!,~), AND(^)OR(v), Imply()Equivalence(↔)
The shown truth table gives their meaning
PQP^QPvQPQP↔Q
TTTTTT
TFFTFF
FTFTTF
FFFFTT
A sentence in PC can be a symbol or a collection of symbols connected legally by the connective symbols (^,v,!,, ↔). Symbols ( ) and [ ] are used to group symbols into subexepressions.
6
4.3.1.2 Examples for using connectives• 1-Although Ali and Samy are not young, Ali has a better chance of
winning the next tennis match, despite Samy’s considerable experience.
• The above is a complex sentence that can be broken into the following propositions:
• S =“Ali is young”• G =“Samy is young”• B =“Ali has a better chance of winning the next tennis match”• E =“Samy has a considerable experience in tennis”• Formalization is done using connectives as follows:• (~S) ^(~G) ^B^E• 2- If Ali is not in a hospital then Ali is wellC =“Ali is in a hospital”W =“Ali is well”Formalization:(~C)W
7
4.3.2 Syntax of the propositional calculus • The syntax provides us with a set of rules for generating complex
formulae as follows:• 1- An identifier is a proposition (e.g. A,B, p, q).• 2-If p and q are propositions then so are ~P, (P), p^q, pvq, pq,
pq.
• Example: if A, B and C are propositions then • A C is a grammatically correct formula and, therefore• AC v B is also correct.
• Terminology• Formula that contains only symbols of the agreed alphabet and
obey grammatical rules given in the definition are called well-formed formulae (wffs).
• Note that when mixing connectives, the rules of precedence should be taken into consideration.
• Precedence from higher to lower :(),~,^,v, ,• Hence A^BvC means (A^B)vC not A^(BvC).
8
4.3.3 Semantics of PC
• Semantics deal with the meaning of compound propositions.
• Meaning of a propositional sentence isThe determination of its truth value
≡ Mapping it into T or F ≡Interpretation of it• This is done by using truth tables or by applying the
laws and rules of propositional logic listed in the following section.
4.3.3.1 Logic laws and inference rulesCumulative laws: (P^Q) ≡(Q^P) and (PvQ) ≡(QvP)
Associative Laws: ( (PvQ)vR) ≡(Pv(QvR)) and
( (P^Q)^R) ≡(P^(Q^R))
Distributive laws: Pv(Q^R) ≡(PvQ)^(PvR) and
P^(QvR) ≡(PvQ)v(P^R)
9
~(~P) ≡ P(PvQ) ≡(~PQ) and (~PvQ) ≡ PQ
Contrapositive law: (PQ) ≡(~Q~P)
de Morgan’s law: ~(PvQ) ≡~P^~Q and ~(P^Q) ≡~Pv~Q
An example of an inference rule:Modus Ponens rule: if P is true and PQThen Q is trueThe validity (correctness or
soundness) of this rule can be proven using truth tables as shown.
Prime propositions
PremisesConclusion
pqpqpq
TTTTTTTT
TFFTF
FTTFT
FFTFF
10
List of inference rules: each introduces or eliminates a connectiveNote that : _I means introduction of a connective. _E means Elimination of a connective.
• Conjunction: ^_Ip
q
p^q
• Simplification: ^_Ep^q
p
• Addition: v_Ip
p v q
• Disjunctive syllogism: v_Ep v q
~p
q
• Modus ponens: _EPq
p
q
• Modus tollens: _EPq
~q
~p
• Double negation: ~_E~~p
p
• Transivity of equivalence: _Ep q p q
pq qp
11
4.3.3.2 Classification of Compound Propositions• Compound propositions can be classified based on the
truth value each proposition can take under all possible interpretations of its constituent prime proposition as follows:
1. Tautology: is true under all possible assignments of truth values to its prime propositions always true
– Example p v ~p is a tautology.
2. Contradiction: always false– Example: p ^ ~p is a contradiction.
3. Contingent: sometimes true and sometimes false.– Example: p~p
12
4.3.4 Exercises
1- Build the truth table for the following expression and deduce an expression equivalent to it:
(PQ)^(QP) ≡ P….Q
PQPQQP(PQ)^(QP)
2-Determine the type of the following expressions:
a- p v qp ^ q b- pqqp
c-~p v ~q ~(p^q) d-~p ^ ~q v p ^ q
3-Demonestrate the validity of modes tollens’ rule:
If pq and ~q then ~p
13
4.4 Predicate Calculus• In Propositional Calculus, each symbol denotes a proposition. There
is no way to access the components of an individual assertion. Predicate calculus provides this ability.
• For Example in Propositional Calculus the symbol P may represent the proposition: P=“Ali is the father of Salem”
• In Predicate calculus, the same proposition can be represented as
father (ali , salem).By dividing the proposition into its internal components, predicate
calculus allows inference of another information such as :Ali is a father,Salem is the son of Ali,And many other conclusions can be derived if combined with other
predicates. • Predicate calculus also allows expressions to
contain variables.Ex: X alive(X)drinks(X, water).
14
• Constatns specific names of objects, properties, or relations.
Must begin with small letters:Ex: ali, book, red, father, above.• Variables unknown or general classes of objects.Represented by symbols beginning with capital letters.X, Y, Z, Man…• Functions: maps its arguments from the domain into
a unique object in the range (co-domain):Examples:
fatherof(ali): maps ali to his father. plus(3,5): maps 3,58
price (banans): maps banans to price value.
4.4.1 Syntax of predicate calculus
1-arity function
2-arity function
15
• Term: is a constant, variable, or function: Examples: cat, X, times(2,3),• Predicate: names a property of an object or a
relationship between zero or more objects in the world: Examples: tall, likes, equal, on, near , part_of,….etc.• A predicate expression consists of a predicate symbol
followed by n terms equal to its arity: predicate_symbol( term 1, term 2,… term n)Examples:likes (ali, football)friends (ali, father_of(ibrahim))likes (X,Y)• Atomic sentence: includes truth symbols or predicate
expression:true , falsefriends (ali, khaled)
16
• Sentences: Every atomic sentence is a sentence. A legal combination of sentences using logical
operators ( connectives of propositional calculus).
• Quantifiers: – constrains the meaning of a sentence containing a
variable to make it a proposition (can be T or F).– If X is a variable and S is a sentence then
X S is a sentence, and X S is a sentence.
– The universal quantifier , for all: the sentence is true for all values of its variable.
– The existential quantifier , there exist: the sentence is true for at least one value of its variable.
– For complex expressions “()” are used to indicate the scope of quantification.
17
– Free variables are not allowed in quantified expressions.
• Examples:– Ali is a teacher and a good man
• goodman (ali) ^ isa (ali, teacher)
– Nobody likes taxes: X likes (X , taxes)
– Every dog is an animal:X ( dog (X) animal (X))
– Every student has a pen:X (Y(student(X) (pen (Y) ^ owns (X,Y))))
18
More examples• Everybody is an adult or a child
X ( adult(X) v child (X))• Everybody is an adult or there are children
• (X adult(X)) v (X child (X))• Everybody is tall but there are children
• (X tall(X)) ^ (X child (X))• Although all adults are tall, they are not clever.
X (( adult(X)tall(X)) ^ (adult (X)~clever (X)))• All first-year students are clever.
X ( first_year(X)^student (X)clever(X) )• No one can be clever without being hardworking
• ~X (clever (X) ) ^ ~hardworking (X))• Not being lazy is equivalent to being hardworking.
X (~lazy(X)hardworking (X))
19
Examples for expressing predicate formulae in EnglishX (child(X)^ clever(X)Y loves(Y,X) ):
– Clever children are loved.X (child(X)^ clever(X)Y (adult (Y) ^loves(Y,X))):
– Clever children are loved by adults.X (clever(X)Y cleverer(X,Y) ):
– One can not be clever without being cleverer than someone.
• Tall(samir) ^ ~Y loves(Y,samir) ^ X (respects( X, samir)) :
– Samir is tall and nobody loves him although everybody respects him.
• ~ X ( person (X) ^ (X/=samir) ^ speaks_slowly(X):– Nobody, except Samir, speaks slowly.
•
20
• Scope of the quantifier– the variable X may refer to different objects in the same argument as
follows: X distant(X)^ planet (X)X moon(X)
• Bound and free variables:
X .p(X,Y)
• Types of values• When a variable is quantified, we should associate it with
a type or domain as follows:
Y:person. mortal (Y)
XOne object Xanother object
Important notes
bound variable free variable
21
4.4.2 Semantics of predicate logicInterpretation of universal quantification• Assuming we deal with finite domain of individuals X.p(X) p(x1)^p(x2)^….^p(Xn)• Example: assume the human society H consist of the individuals samir, samy, ali, salma,
amira, and let the following propositions hold true :• male(samir) greedy (samir) kind(ali) • male (samy) greedy (samy) kind (amira)• male (ali)
Let these predicate be false for individuals not mentioned above.Is the following formula (Z) true in the given context?
X:H.male(X) greedy(X) v kind (X)To validate this argument we build a truth table as follows:
(1)
X
(2)
male (X)
(3)
greedy (X)
(4)
Kind (X)
(5)
(3) v (4)
(6)
(2)(5)
samirTTFTT
samyTTFTT
aliTFTTT
salmaFFFFT
amiraFFTTT
From the same table we can deduce that X:H. greedy(X) v kind (X) is false.
Z is T
22
Semantics of predicate logicInterpretation of Existential quantification• Assuming we deal with finite domain of individuals
• X.p(X) p(x1) v p(x2) v….v p(Xn)• Example: assume the human society H mensioned in the previous example
and consider the truth value of the formula Z
X:H.male(X)^(~ greedy(X) kind (X))
To validate this argument we build a truth table as follows:
(1)
X
(2)
male (X)
(3)
greedy (X)
(4)
Kind (X)
(5)
~(3)
(6)
(5)(4)(7)
(2) ^(6)
samirTTFFTT
samyTTFFTT
aliTFTTTT
salmaFFFTFF
amiraFFTTTF
Z is T
23
4.4.2 Some predicate calculus equivalencesAssume p and q are predicates and X,Y are variables:
1. X p(X) X p(X)2. X p(X) X p(X) 3. X p(X) Y p(Y) 4. X p(X) Y p(Y)5. X ( p(X) ^ q(X) ) X p(X) ^ Y q(Y)6. X ( p(X) v q(X) ) X p(X) v Y q(Y)
24
4.4.3 Inference rules
• Modus Ponens:Given :PQ and P are true Conclusion: Q is trueExample:PQ: “If I am in Jeddah then I’m in Saudi Arabia”P=“I am in Jeddah “Q=“I’m in Saudi Arabia” added to PQ and P
• Modus Tolens:Given :PQ and Q is false Conclusion: P is falseExample:PQ: “If I am in Jeddah then I’m in Saudi Arabia” Q=“I’m not in Saudi Arabia” P=“I am not in Jeddah “ added to PQ and Q
Predicate calculus equivalence:
Given:
X p(X) q(X) and
p(a)
Conclusion: q(a)
Using substitution X=a
Predicate calculus equivalence:
Given:
X p(X) q(X) and
q(a)
Conclusion: p(a)
Using substitution X=a
25
4.5 Semantic Networks
• Network representation provides a means of structuring knowledge.
• Semantic networks are :Directed graphs with labeled nodes and arcs ( arrows, or
links).• Nodes corresponds to objects (physical as book or
nonphysical such as concepts, events, or actions)• Links corresponds to relationships between objects.
Examples: IS_A, MEMBER_OF, SUBSET_OF, AKO (a kind of), HAS_PARTS, INSTANCE_OF, SHAPED_LIKE, OWNS
26
4.5. 1 Representation of some Relations
• In our course we will limit the use of these links to definite relations.
• IS_A : to represent inheritance :subclass to superclass relationship:Example: a lion is an animal
• Instance_of: To represent object to its class relationship:
Example :Ali is a student
lion
studentInstance_of
ali
animalIS_A
27
• HAS_PARTS: to represent composition or aggregation
• Example: A computer is an electronic device consisting of CPU unit, screen, keyboard
computer
Electronic Device
IS_A
keyboardscreen
CPU UNIT
HAS_PARTS HAS_PARTS
HAS_PARTS
28
• HAS_ATTRIBUTE: to link an object to a property.
Example : A person named Ahmad has a red car
ahmad carowns
red
person
has_color
instance_of
Important Not : links insemantic networks can represent binary relations only.
29
4.5.2 Inheritance in Semantic Networks
Inheritance is represented with the IS_A And instance_of links. This allows unstated information to be inferred.
Example:
mammal
rodent
hair milk
mouse
Has_parts drinks
IS_A
IS_A
From the shown net, using inheritance, we can infer that a mouse has hair and drinks milk.
30
4.6 Conceptual Graphs• It is a Network scheme in which both
concepts and conceptual relations are represented by nodes in a directed graph. The links are not labelled. They indicate the direction of the relation only.
• Concepts are represented with labelled rectangles.
• Relations are represented by labelled ellipsis.
• Example: the pen is redpen redcolor
2-ary conceptual relation
conceptsconcepts
31
• A concept may represent concrete or abstract objects.
• Concrete concepts are like cat, telephone , or anything that we can imagine its shape.
• Abstract concepts include concepts such as love, beauty….that do not correspond to images in our minds.
• A conceptual relation has 1 to n- ary.
flies is a 1-ary relation
parents is a 3-ary relationbird flies
child parents
father
mother
32
4.6.1 Types and individuals• A concept symbol may be individual (as instance
objects) or generic) as classes).• Individual concepts have a type field followed by a
referent field. • Example: the concept
has type ‘person’ and referent ‘ali’• Each conceptual graph represents a single proposition.
The shown graph represents the proposition “ali gave ahmad the book”
Person: ali
giveagent object
recipient book
Person: ali
Person:ahmad
33
4.7 Frame Structure• Extends network by allowing each node to be a
complex data structure.• The main advantage is that knowledge about an
object or event is stored together in memory as a unit.
• Each frame consists of named slots with attached values.
• The slot values may be – Numeric data.– Symbolic data– Pointers to other frames– Procedures for performing a particular task.
34
• Frames are general record-like structures, consisting of a collection of slots.
• The slots may be of any size and type• Slots also may have subfields called facets.• Facets may also have names and any number of values.• A general frame structure is as follows:• (<frame name>
(<slot 1> (<facet 1> <value 1> ……<value k1>)(<facet 2> <value 1> ……<value k2>)--
)(<slot 2> (<facet 1> <value 1> ……<value km>)----
)
35
4.7.1 Examples• To define a frame which describes the shown
screen:) screen
(object 1 (shape (value pyramid))
(color (value yellow))
(supported_by (value object2)))
(object 2 (shape (value cube))
(color (value red))
(supported_by (value object3)))
(object 3 (shape (value cube))
(color (value blue))
(supported_by (value nil)))).
Frame name
slotsslotsslots
slotsslotsfacets
36
• Another example: to describe a type(Cressida ( ako ( value car))
( color ( value white, blue, black))
( speed (value 220 km/hr)) ( model ( value 4-doors)).
( Mycar ( instance_of (value Cressida )) ( color ( value white))).
Pointer to another frame to allow inheritance (subclass-superclass relationship)
Pointer to another frame to allow object-class relationship
37
Problem Set 2• Construct truth tables for the compound proposition:
– p v (q ^ r) (p ^q) v r
• Test Validity of the following rule– (p v q) ^ ~pq
• Express the following in predicate logic– Although the tree is tall, it has no leaves.
– If x is the father of y or mother of y then x is a parent of y
– If y and x have same parent then they are sibling
– If x and y are parents of z then they are married.
– Every Muslim does prayer.
– Nobody likes taxes
– All students like AI
• Evaluate the truth of the following, assuming the data is given in section 4.2– X:H.male(X)^(~ greedy(X) v ~kind (X))
– ( X:H.~male(X) ^ kind (X))(X:H.male(X)~kind (X))