0% found this document useful (0 votes)
37 views

ISP622 CHAPTER 3 Knowledge Representation and Reasoning

lecturer note
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

ISP622 CHAPTER 3 Knowledge Representation and Reasoning

lecturer note
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

ISP 622

What is Knowledge Reasoning?

Knowledge
Representation and
Reasoning (KRR)
Chapter 3
G E T S TA R T E D !
ISP 622 : INTELLIGENT SYSTEMS

Learning Objectives
Chapter 3

• 1 Able to determine logic and propositional logic


• 2 Able to explain Knowledge Reasoning
• 3 Able to explain Inference Techniques
• 4 Able to determine Predicate Calculus
• 5 Able to determine Resolution Refutation
Sub-topic in Chapter 3

1.Logic and Propositional Logic


2.Knowledge Reasoning
3.Inference Techniques
4.Predicate Calculus
5.Resolution Refutation
ISP 622 : INTELLIGENT SYSTEMS

WHAT IS LOGIC?
1. Logic is one of the basic disciplines of computer
science.
2. Logic is primarily concerned with reasoning about the
truth of statements.
3. Logic is used to reason about the truth values of a
sentence.
4. Logic concerned with the truthfulness of a chain of
statements.
ISP 622 : INTELLIGENT SYSTEMS

All mice have four legs.


Premises
Minnie is a mouse.
Therefore, Minnie has four legs. Conclusion

Two kind of logic to be discussed in


this chapter are propositional logic
and predicate logic.
Propositional Logic
Proposition is commonly used to refer to a statement. A proposition (or statement) can
be assigned truth values: true (T) or false (F). Propositional logic is the simplest of
logic. The smallest entity to which a value of true or false can be assigned is called an
atomic proposition (or known as atom). Two or more atomic propositions can be
combined together with a connective to produce a compound proposition. For
example, the following are propositions:

Siti is a teacher. : atomic proposition


Zubaidah is a teacher. : atomic proposition
Siti and Zubaidah is a teacher : compound proposition

Each of the propositions has a truth value of ‘true’ or ‘false’. For example,
consider the first sentence. If I happen to know a person named Siti who worked
as a teacher and the proposition is referred to the particular person, then the
value of the proposition would be ‘true’. In the situation, where Siti in the first
sentence is referring to Datuk Siti Nurhaliza, this proposition would have a value
of ‘false’.
Propositional Logic
The formal language of propositional logic defines a set of symbols for representing
propositions and a set of symbols for representing the logical connectives (or also
referred to as logical operators).

English sentences that we use in daily life can be formalized using propositional logic.
The process involves identifying the smallest parts of the sentence that can be assigned
truth values and denote these parts using propositional symbols. Link the small parts
using the connectives. For example, given the following sentences and their symbols:

Muzaffar is an astronaut. p
Faiz is an astronaut. q
From the example above, the sentence below can be structured
by using the connective and (which symbol is Ù).
Muzaffar is an astronaut and Faiz is an p Ù q
astronaut.
Propositional Logic
Consider another example:

Amin’s keys are in the car or hung up in the office.

The smallest parts identified in this sentence are:


• Amin’s keys are in the car.
• Amin’s keys are hung up in the office.

Denote these parts as propositional symbols:


• Amin’s keys are in the car. p
• Amin’s keys are hung up in the office. q

Link these symbols using connective or to produce an expression:


pÚq
Connectivity
The connectives (or also known as logical operator) are defined using truth tables. Connectives can be unary
or binary connectives.

Unary connectives: the connective with only one argument. The only unary connective is not.

Binary connectives: the connective which take two arguments. A binary connective connects two propositions
together.

Below are some connectives used in propositional logic:

Connective Symbol
and Ù, ∩, &
or Ú, È
not ¬,~
implies →, É
equivalent ≡,↔

[email protected]
Connectivity
Not connective (negation)

Not connective has the effect of inverting the truth value of the argument.
The negation of true is false and vice versa.

A sentence of a form ¬A is true, if A is false and vice versa. (As shown in truth
table).

And connective (conjunction)

The compound proposition which consist of two arguments and connected with
an and, will only be true if both arguments are true.

A sentence of a form A Ù B will only be true if A and B is both true. (As shown
in truth table 1).
[email protected]
Connectivity
Example: ‘I have a million ringgit and a house in Kuala Lumpur’. This
sentence is only true if I have a million ringgit and the house. If I have a
million ringgit, but don’t have the house, this sentence is false.

Or connective (disjunction)

The compound proposition which consist of two arguments and connected


with an or, will be true if one or both arguments are true.

A sentence of a form A Ú B will be true if either A or B is true. (As shown


in truth table 2).

Example: ‘I want to buy the red dress or the blue blouse’. This sentence
[email protected] can be interpreted as ‘I want to buy the red dress or the blue blouse, or
both the red dress and the blue blouse’.
Connectivity
Implies connective

In an expression of the form p → q, p and q are known as follows.


p antecedent, evidence
q consequent, hypothesis
The compound proposition which consist of two arguments and connected with an implies,
will be true if one or both arguments are true.

In a sentence of a form A → B, A is known as the antecedent and B is the consequent. This


sentence is only false when the antecedent is true but the consequent is false. (As shown
in truth table 4).

Example: ‘If I am hungry, then I will eat’. Imagine the situation where you are visiting a
friend, and she ask you whether you want to taste her new recipe. Assuming you make the
given statement and you still do not eat when you are hungry. Then you have lied to your
friend about your statement.
[email protected]
Connectivity
Consider another example: ‘If the battery is dead (A), then the car can’t
start (B)’. We could translate the statement into A → B. There are four
possible condition of this statement:

A B
Battery is dead (T) → car can’t start (T) T
Battery is dead (T) → car can start (F) F
Battery not (F) → the car can’t (T) T
dead start
Battery not (F) → car can start (F) T
dead

[email protected]
Truth Table
The truth table for a connective defines what is the truth value should be
assigned to a compound proposition, given each combination of truth values
for the component propositions. For example, in the sentence p Ù q. Both p
and q can have values of T or F. The truth tables for all four connectives are
shown as below.

Any expression can be categorized as tautology, contradiction and


contingency. Each of which as explained below:

Tautology: is a condition when all values are TRUE.


Contradiction: is a condition when all values are FALSE.
Contingency: is a condition when some values are TRUE and some others
are FALSE.
Truth Table
p q pÙq p q pÚq
T T T T T T
T F F T F T
F T F F T T
F F F F F F

p ¬p p q p→q
T F T T T
F T T F F
F T T
F F T

p q p≡q
T T T
T F F
F T F
F F T
Truth Table
Tips Box . Truth table

Procedure to find the truth table for an


expression can be described as several basic
steps:

1.Count the number of atomic propositions, n.


2.Calculate number of rows needed, 2n.
3.Fill in the columns with T and F.
4.Form the other columns by breaking the
expression into simple component parts.
Example (p Ú q) Ù (p Ú r)
Truth Table
Solutio 1. Number of atomic propositions is 3 : p, q and r.
n 2. Number of rows needed : 2n = 23 = 8
3. Fill in the columns:
1 2 3
p q r
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F

4. Form the other columns by


breaking the expression into simple
component parts.
1 2 3 4 5 4Ù 5
p q r pÚq pÚr (p Ú q) Ù (p Ú r)
T T T T T T
T T F T T T
T F T T T T
T F F T T T
F T T T T T
F T F T F F
F F T F T F
F F F F F F
Equivalences
If two expressions have the same truth table, they are said to be
equivalent. The symbol ≡ is used to denote equivalence. For example:

(p Ú q) Ù (p Ú r) ≡ p Ú (q Ù r)
This can be checked by the following truth table, showing that the resultant
columns (in grey) are the same.
1 2 3 4 5 4Ù 5 6 7
p q r pÚq pÚr (p Ú q) Ù (p Ú r) (q Ù r) p Ú (q Ù r)
T T T T T T T T
T T F T T T F T
T F T T T T F T
T F F T T T F T
F T T T T T T T
F T F T F F F F
[email protected] F F T F T F F F
F F F F F F F F
Equivalences
Equivalence can also be proven by using several laws. This is shown in the following table.

Idempotent A®Bº¬AÚB

¬(¬A) ≡ A
De Morgan’s ¬(A Ú B) ≡ ¬A Ù ¬B
¬(A Ù B) ≡ ¬A Ú ¬B

(A Ú B) Ú C ≡ A Ú (B Ú C)
Association (A Ù B) Ù C ≡ A Ù (B Ù C)

(A Ú B) Ù C ≡ (A Ù C) Ú (B Ù C)
Distributive (A Ù B) Ú C ≡ (A Ú C) Ù (B Ú C)

Contradiction A Ù ¬A ≡ F

Tautology A Ú ¬A ≡ T

AÚB≡ BÚA
Commutative AÙB≡ BÙA

[email protected]
A Ù (A Ú B) ≡ A
Absorption A Ú (A Ù B) ≡ A
Equivalences
Example Prove that the following expressions are equivalent.
p → ( q →r ) ≡ ( p Ù q ) → r

Solution
p → ( q →r )
≡ ¬p Ú ( q →r ) Idempotent Law
≡ ¬p Ú (¬q Ú r ) Idempotent Law
≡ (¬p Ú ¬q ) Ú r Association Law
≡ ¬(p Ù q ) Ú r De Morgan’s Law
≡(pÙq)→r Idempotent Law

Tips Box . Order of precedence

The order of precedence is as follows:


1. brackets
2. ¬
3. Ù
[email protected]
4. Ú
5. →
AND/OR Graph
Logical operators AND and OR could be represented in a
graph called AND/OR graph. This graph connects nodes by
sets of arcs. This is shown in the figure below:

AND CONNECTOR C
AC
AÙB→C
BC

OR CONNECTOR C
AC
AÚB→C
BC
AND/OR Graph
Example Given the following rules and fact:

AÙB→C
A
B

Solution C
A
B

If the truth value of the fact is known, a box is drawn to represent its value.
Reasoning

Reasoning is a process of working with knowledge,


facts and problem solving strategies to draw
conclusion. Reasoning is similar to the process done
by human when they are trying to solve problems.
In making decision, we always have to infer to
several rules that we have stated earlier.

There are several strategies of reasoning as


discussed as follows:
[email protected]
Reasoning
Deductive reasoning

This type of reasoning involves process used by humans to deduce new information from
logically related known information. Human usually uses problem facts (axioms) and related
knowledge which are in the form of rules in problem solving. These rules and facts should have
been proven or accepted before they can be compared to the axioms in order to conclude new
axioms.

Example:
Premise : I will get wet if I am standing in the rain (A → B)
Premise : I am standing in the rain (A)
Conclusion : I will get wet (B)

This type of reasoning is logically appealing and become one of the most common problem
solving techniques used by humans. The modus ponen inference technique is the basic form of
deductive reasoning

[email protected]
Reasoning
Inductive reasoning

Inductive reasoning derives a general conclusion about the environment as


a whole, from specific facts, or a set of observed cases. This type of
reasoning is always used when there is limited number of cases (or
observations) to use, and conclusions are made by assuming the cases can
be applied to all related problem.

Humans use inductive reasoning to make a general conclusion by


generalizing what they have observed.

Example :
Premise : Monkeys in the National Zoo eat bananas
Premise : Monkeys in the Taiping Zoo eats bananas
Conclusion : All monkeys eat bananas
[email protected]
Reasoning
Abductive reasoning

This is another type of reasoning where conclusion is made based on available


information. However, the conclusion might be right or might be wrong.

Example:
Premis : If a person has hypertension, he has heart attack
Premis : My grandfather has heart attack
Conclusion : My grandfather has hypertension

From the example given above, conclusion made is might be right or


wrong even though those two premises are true. The heart attack might
not being caused by the hypertension. It might be triggered by any other
reason.
[email protected]
Reasoning
Analogical reasoning is a reasoning type where human takes note of the fact
that two or more things are similar in some respects and concludes that they
are probably also similar in some further respect. In analogical reasoning, an
analogy for a given thing or situation is found, where the analogy is like the
given thing in some way. Other attributes of the analogical situation are then
taken to also represent other attributes of the given thing

Example:
Premis : MyVi is one of Perodua’s car.
Premis : MyVi is sold at a reasonable price.
Premis : MyVi is a very good car.
Premis : Viva is one of Perodua’s car.
Conclusion : Viva is a very good car and sold at a reasonable price.

In the example given above, an analogy is built about Perodua MyVi, and using
the same analogy the conclusion about Perodua Viva is achieved.
[email protected]
Reasoning
Common-sense reasoning

Through experience, humans learn to solve problems


efficiently. It relies more on good judgment rather than precise
logic. This kind of knowledge is also referred to as a heuristic
or rule-of-thumb, which helps making decision much faster.

Example:
An experienced chess player plays chess based on
experiences and observations. While a novice player plays
chess without any knowledge. This kind of reasoning involves
obtaining facts by observation, experience and use them in
solving problem.
[email protected]
Reasoning
Non-monotonic reasoning

Several terminologies:

Monotonic: something static and during execution the fact remain constant.

Non-monotonic: changing information during execution (human can adapt with


changes).

Non- monotonic reasoning deals with dynamic situations, where particular facts can
change as new information during execution. There are so many non-monotonic
factors that might effect the conclusion, for example, the weather, stock process,
foreign exchange, etc.

[email protected]
Inference Techniques
Inference is reasoning
mechanisms that are used to
relate between facts and
rules, to derive new
conclusions or facts.
Inference used to determine
when and how to retrieve,
match and execute what and
which knowledge.

There are four inference


techniques to be discussed in
this chapter, which are as
follows:
Inference Techniques
Inference Techniques
Predicate Calculus
In propositional calculus, each atomic symbol (P,Q, etc) denotes a proposition
of some complexity. There is no way to access the components of an
individual assertion. This is because the propositional logic is the simplest
form of logic. Propositional logic is limited in expressiveness and it is not
good in representing situations.

For example, instead of representing the whole sentence ‘it rained on


Tuesday’ with a single symbol, we can create a predicate weather that
describes the relationship between a date and the weather:
weather(tuesday,rain).

Another fall back of using propositional logic is some symbolized argument


might not be valid. For further understanding of this deficiency, the following
example illustrates the problem.

[email protected]
Predicate Calculus
Every dog has a master.
Sadie is a dog.
Therefore, Sadie has a master.

Using propositional calculus, the sentences above might be represented as :

Every dog has a master. P


Sadie is a dog. Q
Therefore, Sadie has a master. R

The symbolized argument is not valid and yet we can see that the original
premises must surely imply the conclusion Sadie has a master.

First Order Predicate Calculus (FOPC) is a more expressive type of logic,


builds upon propositional logic. Most of what presented previously in this
chapter carries over to FOPC.
[email protected]
Predicate Calculus
Several symbols are used in FOPC. Several terminologies to understand before constructing
the FOPC are as follows:

Predicate
The word used in FOPC to describe the symbols used when we make claims about the
object or relations between objects. Predicates are symbol expression which having
the first character lowercase.

Argument
The symbol representing the object enclosed within the parenthesis. An argument can
be a constant or variable symbol.

Arity
The number of arguments enclosed within the parenthesis. A predicate which has arity
= 1, is called unary predicates. While binary predicates has arity of 2.

Constant
The set of names used to refer to particular objects. These symbol expressions have
first character lowercase.
[email protected]
Predicate Calculus
Variable
The set of names used to any object. These symbol
expressions begin with an uppercase character.
Quantifier
A variable quantifier used to constrain the meaning of a
sentence containing a variable. There are two types of
quantifiers: universal quantifier (") and existential quantifier
($).

A valid symbol to be used for predicates, and arguments must only


consists of alphabets (a,b,c,… and A,B,C,…), digits (0, 1, … , 9)
and underscore (_). Any other characters is not allowed in
representing the symbols.
[email protected]
Predicate Calculus

[email protected]
Predicate Calculus
Consider the sentence below:

All children like Linda.

In this sentence, there are several objects to be considered. All children describe every child that
exists, while Linda is only one particular person named Linda. Therefore, we need a variable to
describe any children, and a constant to describe Linda.

Suppose that we are talking about children in a kindergarten, which are named in the following set:

{Alia, Anita, Daniel, Amir}

The previous set defines the domain of objects within the world, which we are concerned. If All
children like Linda, it can also be represented as:

likes(alia,linda) Ù likes(anita,linda) Ù likes(daniel,linda) Ù likes(amir,linda)


Concisely, it can be represented as:

"X child(X) → likes ( X, linda)

The symbol quantifier helps in defining which object in the domain involves in the sentence. The
[email protected] symbol " is called universal quantifier, and defines everything or all. While symbol $ is called
existential quantifier defines at least one or some.
Predicate Calculus
QUANTIFIERS AND NEGATION

The meaning of a sentence with quantifiers has also some effect upon the usage of negation in the
same sentence. Try to understand the following example:

Everyone loves chocolate. "X loves(X,chocolate)

This sentence has the same meaning as saying:

There is no one who doesn’t love chocolate. ¬$X ¬loves(X,chocolate)

De Morgan’s law expresses the equivalence between both two quantifiers.

Tips Box . De Morgan’s law

¬ ( "X p(X) ) ≡ $X ¬p(X)


¬ ( $X p(X) ) ≡ "X ¬p(X)
[email protected]
Reasoning &Inference Techniques in Predicate Calculus

As discussed in propositional logic, there are several inference techniques could be used. The same reasoning
strategies and inference techniques may be applied with predicate logic. However, the focus of the following
chapter is only on resolution refutation in predicate calculus.

Unification

Unification means a process that computes the appropriate substitution. The objective of unification is to find a
substitution that will allow two sentences to look the same. Once we make two sentences look the same, it is
possible to apply resolution.

In propositional logic, substitution is easier to be done. Propositions which are written with the same symbol are
considered as substitutes. However, the process is much complicated for predicates because of the existence of
variables and constants.

The basic idea of unification is variables can be replaced by:


• other variables
• constants
• function expressions

The high level algorithm below helps to understand unification clearly.


Reasoning &Inference Techniques in Predicate Calculus
Resolution Refutation
The only technique to be discussed for predicate calculus is resolution refutation. The other inference
techniques in propositional calculus can simply be applied with predicates as well. However, some
differences appear for predicate calculus. There are several steps involved in refutation.

1. Convert all predicates of F to clause form.


There are 9 sequential steps to be followed for this part:

Step 1: Eliminate the logical connectives →and ↔


a ↔ b ≡ (a → b) Ù (b → a)
a → b ≡ ¬a Ú b

Step 2: Reduce the scope of negation


¬ (¬a) ≡ a
¬ (a Ù b) ≡ ¬a Ú ¬b
¬ (a Ú b) ≡ ¬a Ù ¬b
¬ ($X) a(X) ≡ ("X) ¬a(X)
¬ ("X) b(X) ≡ ($X) ¬b(X)

Step 3: Standardize by renaming all variables so that variables bound by different quantifiers
have unique names.
("X) a(X) Ú ("X) b(X) ≡ ("X) a(X) Ú ("Y) b(Y)

Step 4: Move all quantifiers to the left to obtain a prenex normal form.
[email protected]
("X) a(X) Ú ("Y) b(Y) ≡ ("X)("Y) a(X) Ú b(Y)
Resolution Refutation
Step 5: Eliminate existential quantifiers by using skolemization.

Skolem constant
• ($X)(dog(X)) may be replaced by dog(fido) where the name fido is picked from the domain of
definition of X to represent that individual X.

Skolem function
• If the predicate has more than one argument and the existentially quantified variable is within the
scope of universally quantified variables, the existential variable must be a function of those other
variables.
• Example:
("X)($Y) (mother(X,Y))
≡ ("X)mother(X,m(X))

("X)("Y)($Z)("W)(foo (X,Y,Z,W))
≡ ("X)("Y)("W)(foo(X,Y,f(X,Y),w))

Step 6: Drop all universal quantifiers

Step 7: Convert the expression to the conjunction of disjuncts form


(a Ù b) Ú (c Ù d)
≡ (a Ú (c Ù d)) Ù (b Ú (c Ù d))
≡ (a Ú c) Ù (a Ú d) Ù (b Ú c) Ù (b Ú d)
[email protected]
Resolution Refutation
Step 8: Call each conjunct a separate clause
(a Ú c) Ù (a Ú d) Ù (b Ú c) Ù (b Ú d)
(a Ú c)
(a Ú d)
(b Ú c)
(b Ú d)

Step 9: Standardize the variables apart again.


Variables are renamed so that no variable symbol appears in more than one clause.
Clause 1: mother(X) Ù female(X)
Clause 2: father(X) Ù male(X)

Clause 1: mother(X) Ù female(X)
Clause 2: father(Y) Ù male(Y)

1. Negate the goal and convert result to clause form. Add the result to the clauses obtained in step 1.

1. Repeat until either a contradiction occurs or no progress can be made.


a) Select two clauses call these parent clauses
b) Resolve the clauses using disjunction if any pairs of literal L or ~L occur in the two parent clauses
pick one and eliminate it from the result
[email protected] c) If the result is empty then the contradiction has been found otherwise add the result to the set of
clauses
Example
Example
ISP622

Chapter 3 ENDED

Thank You
SEE YOU IN NEXT
CHAPTER

You might also like