You are on page 1of 61

Chapter Four and Five

Knowledge, Uncertain
Knowledge and Reasoning
Faris A.
College of Computing
Debre Berhan University, Ethiopia

2010 1
Introduction

• The objective of intelligent machines is to


produce systems which can reason with
available knowledge and so behave
intelligently.
• One of the major issues then is how to
incorporate knowledge into these
systems.
The Problem Of Knowledge
Representation
• How is the whole abstract concept of
knowledge reduced into forms which can
be written into a computers memory.
• This is called the problem of Knowledge
Representation.
Knowledge

Declarative Procedural

• Declarative knowledge deals with factoid questions


(what is the capital of Ethiopia? Who won the
Olympic in 2005? Etc.)
• Procedural knowledge deals with “How”
• Procedural knowledge can be embedded in
declarative knowledge
Example: Employee knowledge base

Employee record
Emp id : 1124
Age : 27
Salary : 10L / annum
Tax : Procedure to calculate tax from basic salary,
Loans, medical factors, and # of children
Representation Knowledge
Should be able to represent
Structured (Eg: tables)
everything in scope
(expressive power)

Correct Semi-structured (Eg: Xml


database)

Efficient Unstructured (Eg: Plain text)


Knowledge Representation
• What to represent?
– Objects?
• Facts about objects in our world domain. E.g. guitar have strings.
– Events
• Actions that occur in our world e.g. Steve played a guitar
– Performance
• A behavior like playing the guitar involves knowledge about how
to do things
– Meta-Knowledge
• Knowledge about what we know

2010 7
Knowledge Engineering
• The process of Eliciting, Structuring, Formalizing,
and operationalzing the Expert knowledge.
– Maps human knowledge into knowledge base.
– Phase to build the knowledge base
• Two important people play the major role
– Domain Expert:
• Person with extensive experience in application
domain.
• Needs to be cooperative.
• Can provide plan for domain familiarization.
• Is a knowledge provider

2010 8
Cont.….
– The knowledge Engineer:
• Specific kind of system analyst
• Plays an important role between the application
domain and the system
• Should have a general knowledge about the
domain
• Should avoid acting as an expert.
• Work with an expert to build the knowledge base.
• Decides on a vocabulary of predicates, functions,
and constants

2010 9
Cont.….
• Some issues to consider in selecting an
expert:
– The expert should be experienced in the
actual problem solving activities.
• If your goal is an expert system that will diagnose why a
car won't start, a mechanic is probably going to be more
useful than a mechanical engineer. The expert system
will encode rules-of-thumb for providing the advice, not
theoretical explanations.

2010 10
– The expert should be available when needed.
• Experts tend to be busy people, and convincing
management that you need access to their time may be
difficult. To design an application to automate a process
you need access to the people who actually accomplish the
process. But, the people who best understand how the
process works are overworked -- that's why the process is a
candidate for automation in the first place.
– Once your human expert and other forms of expertise
are identified and available, you are ready to begin
creating the knowledge base.
– The knowledge provider and the Knowledge Engineer
should share a common view on the problem solving
process
2010 11
• Activities of Knowledge Engineering
– Knowledge Acquisition
– Knowledge Analysis
– Knowledge Validation
Knowledge Acquisition
• The process of acquiring knowledge from the domain expert.
• Techniques include
• Interview and Observation
• Text analysis
• Group discussion
– Difficulties of Knowledge Acquisition
• Domain experts store their knowledge sub consciously
• Usually, domain experts have effective communication problem.
• Most of the experts are basically acquire the knowledge by doing and
watching not by verbal instruction.

2010 12
• Knowledge Analysis
– During the knowledge analysis, the Knowledge Engineer analyzes the
scripts and transfer it into a systematic and manageable form
– The knowledge engineer has to decide which portion of the
knowledge should be represented in what form, depending on the
nature of the knowledge and the efficiency of its use.
• Knowledge Validation
– It is necessary to verify the knowledge against the
Knowledge source.
• The knowledge engineer presents the documented knowledge base
to the expert and validates its correctness.
• Problems of Knowledge engineering.
• Complex knowledge are difficult to observe.
• Experts and other source may differ.
• Multiple representation of a specific knowledge may exist.
2010 13
Knowledge Base

• The knowledge base contains the domain-


specific knowledge required to solve the
problem. It is a collection of knowledge
required for problem solving.
• The knowledge base is created by the knowledge
engineer, who conducts a series of interviews with
the expert and organizes he knowledge in a form
that can be directly used by the system.

2010 14
• Classification of knowledge:
– Compiled knowledge:
• Knowledge resulting from the experience of experts in a domain,
knowledge gathered from handbooks, old records, standard
specifications
• Qualitative knowledge:
• knowledge consists of rules of thumb, approximate theories, causal
models of processes and common sense
– Quantitative knowledge:
• deals with techniques based on mathematical theories, numerical
techniques
*Development of an expert system in an engineering domain
would require use of all these forms of knowledge
• E.x.
– Compare knowledge base with database

2010 15
Knowledge Representation
• Knowledge Representation: describes how knowledge is actually
symbolized and how effectively it resembles representation of human
brain.
• It deals with finding a means of encoding knowledge so that a machine
can use it.
• Kinds of knowledge to represent:
– Objects: facts about objects in our world domain.
– Events actions that occur in the world
– Performance knowledge about how to do things in the world
– Meta Knowledge- knowledge about the knowledge
– Some features of good representation
• Complete: we can represent what is being said
• Concise: we can say what we need to say efficiently
• Suppress irrelevant details
• Fast: store and retrieve knowledge rapidly
• Different knowledge representation schemes can be adopted for
developing one application. The knowledge engineer has to decide
which portion f the knowledge should be represented in what form,
depending on the nature of the knowledge and the efficiency of its use
2010 16
• Issues in Knowledge Representations.
– Important Attributes
• Are there any attribute that occur in many different
types of problem.
– Relationships
• What about the relationship between the attributes of
an object
– Granularity
• Choosing which words as our primitive in a series of
situations in most languages.
 The same piece of knowledge can be represented using more than one
formal scheme, but with varying degrees of difficulty. The difficulty is
not in the representation of the knowledge, but in its usage. The decision
on selection of a scheme primarily depends on the type of application
being built. Also, different knowledge representation schemes can be
adopted for developing one application.

2010 17
Inference mechanism
• Inference mechanisms are control strategies or search
techniques, which search through the knowledge base to
arrive at decisions
• The knowledge base is the state space and the inference
mechanism is a search process.
• As expert systems predominantly process symbols, the
inference process manipulates symbols by selection of rules,
matching the symbols of facts and then firing the rules to
establish new facts.
• This process is continued like a chain until a specified goal is
arrived at. In an expert system, inference can be done in a
number of ways.

2010 18
• Logical inference is used to create new sentences that
logically follow from a given set of sentences in the KB.
– It captures patterns of inferences that occur over and
over again.
– Once a rule is established it can be used to make
inferences without going through the tedious process of
building truth tables

2010 19
Inference
using Prepositional logic (PL)
• Formal language
• It deals with facts
• It is declarative i.e. pieces of syntax corresponds to
facts
• A well-formed formula (wff) in propositional logic is:
(1) An atom is a wff
(2) If P is a wff, then ~P is a wff.
(3) If P and Q are wffs then PQ, PQ, PQ , PQ are
wffs.
(4) The set of all wffs can be generated by repeatedly
applying rules (1)..(3).
– A sentence is valid iff its truth value is t in all interpretations
• Valid sentence: all truth value assignments for the
variables make the sentence true.
• Algorithm? Try all possible assignments and check that
they all work.
– A sentence is satisfiable iff its truth value is t in at least one
interpretation
• Satisfiable sentence: there exists a truth value assignment
for the variables that makes the sentence true (truth value
= t).
• Algorithm? Try all the possible assignments to see if one
works.
– A sentence is unsatisfiable/contadiction iff its truth value is
false in all interpretations
– everything that's valid is also satisfiable.
– Syntax: allows facts about the world to be represented as
sentences formed from

2010 21
Propositional Logic…
• Logical constants: True, False
– Proposition symbols (P, Q, R, …) are used to represent
facts about the world
e.g.: P means "It is hot“, Q means "It is humid“, R means
"It is raining“
– Logical connectives: not (), and (), or (), implies (),
is equivalent, if and only if ().
– Precedence from highest to lowest is: , ,,, 
• The sentence P v Q  R  S is equivalent to ((P) v
(Q  R))  S

2010 22
• Semantic: Specify the interpretation of the
proposition symbols and constants, and the
meanings of the logical connectives
A sentence is made by putting symbols together. There
are atomic and complex sentences.
– Atomic sentences: consist of a single symbol (e.g. P)
• If S is a sentence, then S is a sentence
– Complex sentences are combined by using connectives or
parenthesis:
• If S and T are sentences, then S  T, (S  T), (S  T), (S  T),
and (S  T) are complex sentences, and are called conjunction,
disjunction, implication, and equivalent, respectively

2010 23
• Example: Consider the problem of representing the
following information:
– Every person is mortal.
– Abebe is a person.
– Abebe is mortal.
• How can these sentences be represented so that we can
infer the third sentence from the first two?
• In PL use propositional symbols to stand for all or part
of each sentence. Hence, P = “person”; Q = “mortal”; R
= “Abebe”
• So the above 3 sentences are represented as: P  Q; R
 P; R  Q
2010 24
• Although the third sentence is entailed by the first two, we needed
an explicit symbol, R, to represent an individual, Abebe, who is a
member of the classes “person” and “mortal.”
• To represent other individuals we must introduce separate symbols
for each one, with means for representing the fact that all
individuals who are “people” are also "mortal.”
• Use the following atoms to translate the sentences below
into propositional logic.
– T- there is traffic
– L- I am late
– E- I am early
– B- I take a bus
– C- I take a car
– If I take the car and there is no traffic, I am early. I take the bus
or the car.Therefore,if I don’t take the bus, I am early or late.

2010 25
PL…
• Weaknesses of prepositional inference
– It cannot handle even a domain with small
world. The problem is that there are just too
many propositions to handle since it only
has one representational device: the
proposition

2010 26
Equivalence rules

Idempotenta PP  P PP  P

Asociativitate (P  Q)  R  P  (Q  R) (P  Q)  R  P  (Q  R)

Comutativitate PQ  QP PQ  QP PQQP

Distributivitate P  (Q  R)  (P  Q)  (P  R) P  (Q  R)  (P  Q)  (P  R)

De Morgan ~ (P  Q)  ~ P  ~ Q ~ (P  Q)  ~ P ~ Q
Eliminarea
implicatiei P  Q ~ P  Q
Eliminarea
implicatiei duble P  Q  (P  Q)  (Q  P)
Inference rules
P
PQ
• Modus Ponens Q

PQ
QR
• Chain rule PR

P
• AND introduction Q
PQ

PQ
• Transposition ~ Q ~ P
Example

• Abebe has money


• The car is white
• The car is nice
• If the car is white or the car is nice and Abebe has
money then Abebe goes to the mountain
• B
• A
• F
• (A  F)  B  C
Inference First-Order Logic (FOL)
• It is expressive enough to concisely
represent this kind of situation.
• Better to represent the world
– Some important symbols
• Connectives , , , ,  (retains such
connectives from PL)
• Quantifiers , 
– Quantifiers are used to express properties of entire
collection of objects.
– Two standard quantifiers: Universal (" for all, for every)
and Existential ($ there exists, some)

2010 30
• Predicates of arity n
• Atom or atomic formula.
• Literal
A well formed formula (wff) in first order predicate logic is defined
as:
(1) A atom is an wff
(2) If P[x] is a wff then ~P[x] is an wff.
(3) If P[x] and Q [x] are wffs then P[x]Q[x],
P[x] Q[x], PQ and PQ are wffs.
(4) If P[x] is an wff then x P[x], x P[x] are wffs.
(5) The set of all wffs can be generated by repeatedly applying
rules (1)..(4).
Inference First-Order Logic (FOL)
• Universal Quantifiers: makes statements about
every object <variables> <sentence>
– Everyone at DBU is smart: x At(x, DBU) 
Smart(x)
– Every elephant is gray:  x (elephant(x) → gray(x))
• A common mistake to avoid
– Typically,  is the main connective with 
– Common mistake: using  as the main connective
with :
x At(x, DBU)  Smart(x) means “Everyone is at
AMU & everyone is smart”

2010 32
• Existential Quantifiers: makes statements about some
objects in the universe <variables> <sentence>
– Someone at DBU is smart: x At(x,DBU)  Smart(x)
– There is a white horse:  x (horse(X) ^ white(X))
• Common mistake to avoid
– Typically,  is the main connective with 
– Common mistake: using  as the main connective with :

• 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

2010 33
• Sentences in FOL
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.
– So we can use variables and quantifiers to represent things like:
• Everything in the garden is lovely -- x in(x, garden)  lovely(x)
• Everyone likes ice cream -- "x likes(x, icecream)
• Abel has some friends -- y friends(y, Abel)
• Example
– Every person is mortal.
– Abebe is a person.
using logical inferences we can deduce that:
Abebe is mortal.
x man(x) mortal(x)
man(Abebe)
so we can conclude that mortal(Abebe)
– This involves matching man(x) against man(Abebe) and binding the variable
x to the symbol something.

2010 34
First-Order Predicate Logic…
• Predicate logic provides mechanisms for representation of
facts and reasoning based on syntactic manipulation of logic
formulae. It uses predefined rules of inference for assertion or
deduction of facts.
• In the first-order predicate logic, the formulae are
manipulated purely based on their form or structure
• Example: Consider a bridge system consisting of two girders
and three piers

A B

C D E

A bridge configuration with two girders and three piers


2010 35
• The following statements can be written to state the facts
regarding the bridge system.
A is-a girder;
B is-a girder;
C is-a pier; In this, the terms is-a and supports
D is-a pier; are called predicates and A, B, C, D
E is-a pier; and E are called symbols.
C supports A;
D supports A;
D supports B;
E supports B;
An inference rule is specified as given below:
Another predicate gets-load-from is introduced in the inference rule.
Any symbol of proper type can be substituted for the place holders x
and y for assertion of facts. Using the given inference rule, the
following facts can be asserted. 2010 36
C gets-load-from A;
D gets-load-from A;
D gets-load-from B;
E gets-load-from B;
• It can also be modeled mathematically quantification
– Everybody loves somebody
• For all x, there exists a y such that loves(x,y)
– Everybody has a father
• For all x Exists y father(y,x)
– Everybody has a father
• For all x Exists yz. Such that F(y,x) and m(z,x)
– Whoever has a father has a mother
While first order predicate logic is better to represent knowledge as
compared to propositional logic, it doesn't entertain how human
perceive the problem.
• A good knowledge representation scheme should have the capability to
represent real-life situations (objects and relationships among them),
which can be exploited by efficient guided search strategies and which
better reflect the way humans perceive and think.
2010 37
Equivalence
Echivalenta of quantifiers
cuantificatorilor

(Qx)F[x]  G  (Qx)(F[x]  G) (Qx)F[x]  G  (Qx)(F[x]  G)

~ (( x)F[x])  ( x)(~ F[x]) ~ (( x)F[x])  ( x)(~ F[x])

( x)F[x]  ( x)H[x]  ( x)(F[x]  H[x]) ( x)F[x]  ( x)H[x]  ( x)(F[x]  H[x])

(Q1x)F[x]  (Q2 x)H[x]  (Q1x)(Q2 z)(F[x]  H[z]) (Q1x)F[x]  (Q2 x)H[x]  (Q1x)(Q2 z)(F[x]  H[z])
Inference using Production Rules:
Rules in prepositional and predicate logic indicate with Rules say
what is TRUE given some conditions.
• Rule based systems (Production systems) are based on rules that
say what to DO, given various conditions.
– IF <this is the case> THEN <do this>
– Many forms:
• IF condition THEN action
• IF premise THEN conclusion
• IF proposition p1 and proposition p2 are true THEN proposition p3 is true
• Features of if-then rules:
– Modularity: Each rule defines a small, relatively independent
piece of knowledge
– Incrementability: New rules can be added to the knowledge
base relatively independently of other rules
– Modifiability: Old rules can be changed relatively
independently of other rules
2010 39
Examples
• All apples are red
• All objects are red apples
• There is a red apple
• All packages in room 27 are smaller than any package in
room 28
 All purple mushrooms are poisonous
 x (Purple(x)  Mushroom(x))  Poisonous(x)
 x Purple(x)  (Mushroom(x)  Poisonous(x))
 x Mushroom (x)  (Purple (x)  Poisonous(x))
(x)(y) loves(x,y)
(y)(x)loves(x,y)
• Production rules:
– Production rules are simple but powerful
forms of knowledge representation
providing the flexibility of combining
declarative and procedural representation
for using them in a unified form
– A production rule has a set of antecedents
and a set of consequents. The antecedents
specify a set of conditions and the
consequents a set of actions

2010 41
• Production rules:
– It is a conditional statement that consists of
condition/hypothesis followed b an action or
conclusion parts
– It is “IF A then B” form of knowledge
representation. That means. If the IF part of the rule
is satisfied, the THEN part can be concluded.
• Example1: If light is coming on AND NOT engine is
turning on THEN problem is with the starter
– The rule states that is two facts are satisfied, then the system
recommends that the problem be on the starter. This is a new
fact derived from the exiting facts
• Example2: If the fuel tank is empty then the recommended action
is refill the tank

2010 42
– Rules involve proven facts and hypothetical facts. The latter
provide a means of using coefficient of certainty.
– Uncertainty in Rules
• In practice we rarely conclude things with absolute certainty. To
allow for this sort of reasoning in production rule we often add
certainty values to a rule, and attach certainties to any new
conditions
• Example: Suppose your knowledge base has the following rule that
can determine a value for the recommended action goal variable: If
the fuel tank is empty then the recommended action is refill the tank
• Could your expert determine whether or not the fuel tank is empty
when the user does not know? The expert might suggest adding the
following rule:
If the starter operates and a gasoline smell is not present then the
fuel tank is empty with 90% confidence
If the user answers the "is the fuel tank empty" question, this rule
isn't needed.

2010 43
• MYCIN’s “knowledge base” consisted of set of IF-THEN
rules, e.g.,
IF the infection is primary-bacteremia
AND the site of the culture is one of the sterile sites
AND the suspected portal of entry is the gastrointestinal tract
THEN there is suggestive evidence (0.7) that infection is bacteroid.
IF the identity of the germ is not known with certainty
AND the germ is gram-positive
AND the morphology of the organism is "rod"
AND the germ is aerobic
THEN t the germ is of type enterobacteriacae
• Rule-based systems provide way of reasoning on
knowledge based on Condition-Action rules.

2010 44
• Production rules are easy to construct; most importantly
can be linked to each other so that the conclusion of one
rule can form the hypothesis of the other.
• Reflect the “rules of thumb” that experts use in their day-
to-day work.
• Drawbacks:
– These systems have been restricted when applied to large
problems. Having a knowledge base that consists of hundreds or
thousands of rules can cause a problem with management and
organization of rules
– They are limited to represent causal knowledge
• Semantic Network and Frames
– Semantic network is a node-and-arc graphical notation
that represents knowledge about objects that contain
real world meaning about the objects, actions, or
events.
– It is very suitable to represent object-oriented scheme
of knowledge . 2010 45
• The most important relations between concepts are:
– Subclass relations between classes and subclasses
– Instance relations between particular objects and their parent
class.
– Other relations such as has-part, color are allowed
The subclass and instance relations may be used to derive new
information which is not explicitly represented, by inheriting
information from their parent class.

2010 46
Semantic and Frames…

mammals bear-a-child bear-a-child(mammals)


bear-a-child(dogs)
Is-a bear-a-child(bobi)
dogs barks barks(dogs)
barks(bobi)…
Is-a
owns Abebe
bobi

2010 47
• Semantic networks normally allow efficient inheritance-based
inferences
• Semantic networks are most suitable for data representation
such as representing knowledge about relationships, knowledge
about objects, etc.
• Frames
– Are variant of Semantic Network
– A frame is defined as a unit of a knowledge source described
by a set of slots
• Mammals and reptiles are animals, mammals have heads,
elephant is a large gray mammal, X and Y are both
elephants, and Y likes apples
Sometimes, even when using a logic-based language,
it is useful to be able to define inheritance rules, and
group object attributes together in a frame-like
structure.
2010 48
• Mammals
Subclass: animal
Has:head
• Elephant
Subclass: mammal
Color: gray
Size:large
• X
Instance: elephant
• Y
Instance: elephant
Likes: apple

2010 49
Temporal logic
• Deals with facts, objects, relations, and
time
• It is similar to first order predicate logic,
except that it adds temporal factor.
Probability theory
• It is one method of dealing with uncertainty
• It deals with randomness
• Its value ranges from 0 to 1 inclusive.
• It doesn’t consider the grade of confidence

2010 50
Fuzzy logic
• Fuzzy logic is an approach to computing based on
“degree of truth” rather than the usual “truth or
false ” (1 or 0) Boolean logic on which modern
computer is based
– It deals with an associated degree of confidence.
– Fuzziness examined by membership values
– The membership is an attribute expressed by single
numerical number ranging from 0 to 1 inclusive
– Fuzziness is dealt with possibility rather than
probability. It is expressed with possibility distribution
and closeness relations

2010 51
NO (0)

is Abebe Yes(1)
honest ?

Extremely
honest (1)
Very honest
(0.8)
is Abebe Honest at
honest ? time (0.4)
Extremely
Dishonest (0)
2010 52
Fuzzy logic
• The crisp set operators are extended to Fuzzy
sets as follows:
– An element u is said to be in the fuzzy set if and
only if membership function μ(u)>0, and to be a full
member of the set iff μ(u)=1
• E.g. is abebe happy
– Fuzzy union takes maximum membership values of
the given elements
– Fuzzy intersection takes minimum membership
values of the given elements
– Fuzzy complement takes 1-the membership value of
the element
2010 53
Fuzzy Logic, For AI Implementation

• First conceived by professor Zadeh, as a way of


processing data by allowing partial set
membership rather than crisp set membership or
non-membership
• HOW IS FL DIFFERENT FROM CONVENTIONAL
CONTROL METHODS?
– FL incorporates a simple, rule-based IF X AND Y
THEN Z approach to a solving control problem
rather than attempting to model a system
mathematically. The FL model is empirically-based,
relying on an operator's experience rather than their
technical understanding of the system
– it mimics human control logic

2010 54
– Example:
• "IF (process is too cool) AND (process is getting
colder) THEN (add heat to the process)" or "IF (process
is too hot) AND (process is heating rapidly) THEN
(cool the process quickly)" are used
– A fuzzy set A in X is characterized by a
membership function mA(x) which maps each
point in X onto the real interval [0.0, 1.0]. As
mA(x) approaches 1.0, the "grade of membership"
of x in A.

2010 55
Fuzzy Logic, For AI Implementation…
• Fuzzy Set Theory defines Fuzzy Operators on Fuzzy Sets. The
problem in applying this is that the appropriate Fuzzy
Operator may not be known. For this reason, Fuzzy logic
usually uses IF/THEN rules, or constructs that are equivalent,
such as fuzzy associative matrices.
• Rules are usually expressed in the form:
IF variable IS set THEN action
• For example, an extremely simple temperature regulator that
uses a fan might look like this:
IF temperature IS very cold THEN stop fan
IF temperature IS cold THEN turn down fan
IF temperature IS normal THEN maintain level
IF temperature IS hot THEN speed up fan
• Notice there is no "ELSE". All of the rules are evaluated,
because the temperature might be "cold" and "normal" at the
same time to differing degrees.

2010 56
Fuzzy Logic Operators
• Fuzzy Logic:
– NOT (A) = 1 - A
– A AND B = min( A, B)
– A OR B = max( A, B)

2010 57
Fuzzy Logic NOT

2010 58
Fuzzy Logic AND

2010 59
Fuzzy Logic OR

2010 60
End
2010 61

You might also like