AI - Lecture ch-4
AI - Lecture ch-4
AI - Lecture ch-4
Chapter - 4
Knowledge and Reasoning
Content
• Knowledge Representation
• Knowledge-Based Systems
• Logical Agents
• Propositional Logic
• Predicate (First-Order)Logic
KBA begins with some knowledge of the world and of its actions.
• It uses logical reasoning to maintain a description of the world as new percepts arrive
• Learn new facts/knowledge that are inferred and unseen by current percepts
• Deduce a course of actions that will achieve its goals
4
Knowledge engineering (KE)
KE is the process of building a knowledge base through extracting the knowledge from
the human expert.
Knowledge engineering is the process of
• Extracting the knowledge from the human expert.
• Choose knowledge representation formalism
• Choose reasoning and problem solving strategy.
Knowledge Knowledge
acquisition Representation
(Extract knowledge (Choose KR Method & Knowledge Base
of Human Expert) reasoning strategy)
7
Logic as KR
A Logic is a formal language in which knowledge can be represented such that
conclusions can easily be drawn.
• It is a declarative language to declare sentences and deduce from sentences.
Components of a formal logic include syntax, semantics, reasoning and inference
mechanism.
• Syntax: Describes how to make sentences
E.g. mycar (red) is ok, but mycar(grey or green) is not.
• Semantics: Express what sentences mean, in terms of a mapping to real world.
E.g. mycar (red) means that my car is red.
• Reasoning: done using a set of rules. It helps to draw new conclusions from existing
statements in the logic.
8
Logic as KR
Logic is a language for reasoning and collection of rules are used while doing
logical reasoning
Why formal languages (Logic) ?
An obvious way of expressing or representing facts and thoughts is by writing them in a
natural language such as English, Amharic, etc. However,
• The meaning of a sentence depends on the sentence itself and on the context on which the
sentence was spoken
E.g. Look!
• Natural languages show ambiguity. A single sentence can usually be interpreted in more than
one way. E.g. Small dogs and cats.
11
Propositional logic (PL) sentences
A sentence: is made by linking prepositional symbols together using logical
connectives.
• There are atomic and complex sentences.
• Atomic sentences consist of propositional symbol (E.g. p, q, true, false)
• Complex sentences are combined by using connectives or parenthesis:
• While S and T are atomic sentences, S T, (S T), (S T), (S T), and (S T) are
complex sentences.
Examples: Given the following sentences about the “weather problem” convert them
into PL sentences:
• “It is humid.”: Q
• “If it is humid, then it is hot” : Q P
• “If it is hot and humid, then it is raining”: (P Q) R
12
Exercise
Examples: Convert the following English sentences to Propositional logic
Let A = Lectures are active and R = Text is readable, P = Kebede will pass the exam,
then represent the following:
The lectures are not active: A
The lectures are active and the text is readable: A R
Either the lectures are active or the text is readable: A V R
If the lectures are active, then the text is not readable: A R
The lectures are active if and only if the text is readable: A R
If the lectures are active, then if the text is not readable, kebede will not pass the exam:
A (R P )
13
Inference In PL
• Modus Ponens
• Modus Tollens
• Hypothetical Syllogism
• Disjunctive Syllogism
• Addition
Terminology
Valid sentence: A sentence is valid sentence if and only if it is True under all possible
interpretations in all possible worlds.
• Example: “It’s raining or it’s not raining.” (R R).
16
Logical equivalence
Two sentences are logically equivalent if and only if they are true in same models
18
Cont.
First Order Logic
FOL is type of PC (Predicate calculus)
20
FOL: Basic elements
• Constants: names (like Jons, Kebede, …), numbers (like 1, 2, … n), ...
• Predicates: Predicates used to relate one object with another. E.g. brotherOf, >,...
• Functions: sqrt, leftLegOf,...
• Variables: x, y, a, b,... Important to increase generalization capability of KB
• Connectives: ¬, ⇒, ∧, ∨, ⇔
• Equality: =
• Quantifiers: ∀, ∃
• Specify whether all or some objects satisfy properties or relations between objects
• Two standard quantifiers:
• Universal - ∀ - (for all, for every) and Existential - ∃ - (there exists, some)
FOL represents objects and relations between objects, variables, and quantifiers in
addition to propositions
FOL Sentence structure
In FOL the basic unit is a predicate structure also called sentence which represent facts.
predicate (argument/terms)
A predicate is the one that says something about the subject. E.g., Abebe is tall
• Subject: Abebe, represented as: tall(Abebe)
Predicate also refers to a particular relation between objects
• Example: likes(X, richard)
A predicate statement takes the value true or false
Terms/arguments refer to objects and can be any of:
Constant symbol, such as ‘chocolate’, Example: likes(abebe, chocolate);
Variable symbol, such as X ,
Functions, such as motherof(fred), father-of( father-of( john))
E.g. friends(motherof(jonas), motherof(semu))
22
Sentences
Atomic sentences: formed from a predicate symbol followed by a parenthesized list of terms
Atomic sentence = predicate (term1,...,termn)
Example: Brother(John, Richard)
Atomic sentences can have arguments that are complex terms (e.g. term = function (term1,...,termn) )
Example: married(fatherof(Richard),motherof(John))
Complex sentences: complex sentences are made by combining atomic sentences using connectives:
S, S1 S2, S1 S2, S1 S2, S1 S2,
Example. likes(john, mary) tall(mary)
tall(john) handsome(john)
Sibling(John, Richard) Sibling(Richard, John)
Sentences can also be formed using quantifiers to indicate how to treat variables:
• Universal quantifier: x lovely(x) - Everything is lovely.
• Existential quantifier: x lovely(x) - Something is lovely. 23
Universal quantification
24
Existential quantification
Makes statements about some objects in the universe
<variables> <sentence>
• Someone at UoG is smart: x At(x,UoG) Smart(x)
• There is a white cat: x (cat(X) ^ white(X))
25
Nested quantifiers
x,y parent(x,y) child(y,x)
•For all x and y, if x is the parent of y then y is the child of x.
x y Loves(x,y)
•There is a person who loves everyone in the given world
y x Loves(x,y)
• Everyone in the given universe is loved by at least one person
Properties of quantifiers
• x y is the same as y x
• x y is the same as y x
• x y is not the same as y x
26
Cont.
Quantifier duality: each can be expressed using the other, using negation ()
• x Likes(x,icecream)
• x Likes(x,icecream)
• Everyone likes ice cream means that there is nobody who dislikes ice cream
• x Likes(x,cake)
• x Likes(x,cake)
• There is someone who likes cake means that there is no one who dislikes cake
Example
Sentences can have several quantifiers, e.g.,
x y loves(x, y)
x handsome(x) y loves(y, x)
28
The End