ISP622 CHAPTER 3 Knowledge Representation and Reasoning
ISP622 CHAPTER 3 Knowledge Representation and 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
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
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:
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.
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).
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)
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
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.
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
(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
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
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
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
Example:
Premis : If a person has hypertension, he has heart attack
Premis : My grandfather has heart attack
Conclusion : My grandfather has hypertension
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
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 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.
[email protected]
Predicate Calculus
Every dog has a master.
Sadie is a dog.
Therefore, Sadie has a master.
The symbolized argument is not valid and yet we can see that the original
premises must surely imply the conclusion Sadie has a master.
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
($).
[email protected]
Predicate Calculus
Consider the sentence below:
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:
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:
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:
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.
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))
1. Negate the goal and convert result to clause form. Add the result to the clauses obtained in step 1.
Chapter 3 ENDED
Thank You
SEE YOU IN NEXT
CHAPTER