0% found this document useful (0 votes)
56 views59 pages

Lecture 4 - Knowledge Representation and Reasoning (I)

The lecture discusses the fundamentals of Artificial Intelligence (AI) and Machine Learning, focusing on Knowledge Representation and Reasoning (KRR). KRR is essential for AI agents to understand and utilize information about the real world to solve complex problems. The lecture also covers various approaches and techniques for knowledge representation, including propositional logic and inference rules.

Uploaded by

Lam Chun Wing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views59 pages

Lecture 4 - Knowledge Representation and Reasoning (I)

The lecture discusses the fundamentals of Artificial Intelligence (AI) and Machine Learning, focusing on Knowledge Representation and Reasoning (KRR). KRR is essential for AI agents to understand and utilize information about the real world to solve complex problems. The lecture also covers various approaches and techniques for knowledge representation, including propositional logic and inference rules.

Uploaded by

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

COMP3057 –

Introduction to AI and
Machine Learning
Lecture 3 – Knowledge Representation and Reasoning (I)
Dr. UMAIR, Zuneera
What is AI?
 The science and engineering of making
intelligent machines, specially intelligent
computer programs (John McCarthy)
 First work on AI was presented by Warren
McCulloch and Walter Pitts in 1943
 Its about algorithms enabled by
constraints exposed by representation
that model targeted thinking, perception
and action (Patrick Winston)
 We all know about the Turing test, right?
Knowledge Representation and
Reasoning
 Humans are best at understanding, reasoning, and
interpreting knowledge.
 But how machines do all these things comes
under knowledge representation and
reasoning
 Knowledge representation and reasoning (KR, KRR)
is the part of Artificial intelligence which concerned
with AI agents thinking and how thinking
contributes to intelligent behavior of agents.
Knowledge Representation and
Reasoning
 It is responsible for representing
information about the real world so that a
computer can understand and can utilize
this knowledge to solve the complex real
world problems
 such as diagnosis a medical condition or
communicating with humans in natural
language.
 Knowledge representation is not just
storing data into some database, but it
also enables an intelligent machine to
learn from that knowledge and
What to Represent:
 Following are the kind of knowledge which needs to be represented in
AI systems:
1. Object: All the facts about objects in our world domain. E.g., Guitars
contains strings, trumpets are brass instruments.
2. Events: Events are the actions which occur in our world.
3. Performance: It describe behavior which involves knowledge about
how to do things.
4. Meta-knowledge: It is knowledge about what we know.
5. Facts: Facts are the truths about the real world and what we
represent.
6. Knowledge-Base: The central component of the knowledge-based
agents is the knowledge base. It is represented as KB. The
Knowledgebase is a group of the Sentences (Here, sentences are
used as a technical term and not identical with the English language).
The relation between knowledge
and intelligence:
 Knowledge plays an important role in
demonstrating intelligent behavior in AI agents.
 An agent is only able to accurately act on some
input when he has some knowledge or experience
about that input.
AI knowledge cycle:
 An Artificial intelligence
system has the following
components for
displaying intelligent
behavior:
 Perception
 Learning
 Knowledge
Representation and
Reasoning
 Planning
 Execution
AI Knowledge Cycle

 AI system has Perception component by which it


retrieves information from its environment. It can be
visual, audio or another form of sensory input.
 The Learning component is responsible for learning
from data captured by Perception comportment.
 The main components are knowledge representation
and Reasoning. These two components are involved
in showing the intelligence in machine-like humans.
Approaches to knowledge representation:

 There are mainly four approaches to knowledge


representation, which are given below:
1. Simple relational knowledge
2. Inheritable knowledge
3. Inferential knowledge
4. Procedural knowledge
1. Simple relational knowledge
 It is the simplest way of storing facts which uses the
relational method, and each fact about a set of the
object is set out systematically in columns.
 This approach of knowledge representation is famous
in database systems where the relationship between
different entities is represented.
 The following is the simple relational knowledge
representation.

Player Weight Age


Player1 65 23
Player2 58 18
Player3 75 24
2. Inheritable knowledge:

 In the inheritable knowledge


approach, all data must be stored
into a hierarchy of classes.
 All classes should be arranged in a
generalized form or a hierarchal
manner.
 In this approach, we apply
inheritance property.
 Elements inherit values from other
members of a class.
3. Inferential knowledge:

 Inferential knowledge approach represents


knowledge in the form of formal logics.
 This approach can be used to derive more facts.
 Example: Let's suppose there are two
statements:
 Marcus is a man
 Allmen are mortal
Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s
4. Procedural knowledge:

 Procedural knowledge approach uses small


programs and codes which describes how to do
specific things, and how to proceed.
 In this approach, one important rule is used which
is If-Then rule.
Techniques of knowledge
representation
 There are mainly four ways of knowledge
representation which are given as follows:
 Logical Representation
 Semantic Network Representation
 Frame Representation
 Production Rules

In this lecture, we are going to represent


Inferential Knowledge using Logical
representation
Techniques of knowledge representation
Logical Representation
 Logical representation is a language with some
concrete rules which deals with propositions and has
no ambiguity in representation.
 Logical representation means drawing a conclusion
based on various conditions.
 This representation lays down some important
communication rules. ‘
 It consists of precisely defined syntax and semantics
which supports the sound inference.
 Each sentence can be translated into logics using
syntax and semantics.
Techniques of knowledge
representation
Logical Representation
 Syntax:
 Syntaxes are the rules which decide how we can
construct legal sentences in the logic.
 Itdetermines which symbol we can use in
knowledge representation.
 How to write those symbols.
 Semantics:
 Semantics are the rules by which we can interpret
the sentence in the logic.
 Semantic also involves assigning a meaning to
each sentence.
Logical Representation

 Logical representation can be categorised into


mainly two logics:
 Propositional Logics
 First Order Logics or Predicate logics
Logical Representation:
Propositional Logic
 Propositional logic (PL) is the simplest form of
logic where all the statements are made by
propositions.
 A proposition is a declarative statement which is
either true or false.
 It is a technique of knowledge representation in
logical and mathematical form.
 Examples
 It is Sunday.
 The Sun rises from West (False proposition)
 3+3= 7(False proposition)
Logical Representation:
Propositional Logic
 Propositional logic is also called Boolean logic as it
works on 0 and 1.
 In propositional logic, we use symbolic variables
to represent the logic, and we can use any symbol
for a representing a proposition, such A, B, C, P, Q,
R, etc.
 Propositions can be either true or false, but it
cannot be both.
 Propositional logic consists of an object, relations
or function, and logical connectives.
 These connectives are also called logical
Logical Representation:
Propositional Logic
 The propositions and connectives are the basic elements
of the propositional logic.
 Connectives can be said as a logical operator which
connects two sentences.
 A proposition formula which is always true is
called tautology, and it is also called a valid sentence.
 A proposition formula which is always false is
called Contradiction.
 Statements which are questions, commands, or opinions
are not propositions such as "Where is Daniel", "How
are you", "What is your name", are not propositions.
Prepositional Logic
Syntax of Prepositional Logic
 The syntax of propositional logic defines the allowable sentences for the
knowledge representation. There are two types of Propositions:
1. Atomic Propositions:
 Atomic propositions are the simple propositions. It consists of a single
proposition symbol. These are the sentences which must be either true
or false.
 2+2 is 4, it is an atomic proposition as it is a true fact.
 "The Sun is cold" is also a proposition as it is a false fact.
2. Compound propositions:
 Compound propositions are constructed by combining simpler or
atomic propositions, using parenthesis and logical connectives.
 It is raining today, and street is wet."
 ”Rebecca is a doctor, and her clinic is in Central."
Prepositional Logic
Logical Connectives:
 Logical connectives are used to connect two simpler
propositions or representing a sentence logically.

There are mainly five connectives, which are given as
follows: Meaning
Connective
s
Negation: A sentence such as ¬ P is called negation of P.
A literal can be either Positive literal or negative literal.

Conjunctio A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.


Example: Vivian is intelligent and hardworking. It can be written as,
n: P= Vivian is intelligent,
Q= Vivian is hardworking. → P∧ Q.

Disjunction A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and Q are the propositions.
Example: "Rebecca is a doctor or Engineer",
: Here P= Rebecca is Doctor. Q= Rebecca is Engineer, so we can write it as P ∨ Q.

Implication A sentence such as P → Q, is called an implication. Implications are also known as if-then rules. It can be
represented as
: If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q

Bicondition A sentence such as P⇔ Q is a Biconditional sentence, example If I am breathing, then I am alive


P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Prepositional Logic
Logical Connectives:

 Following is the summarized table for


Propositional Logic Connectives:
Prepositional Logic
Truth Table
 In propositional logic, we need to know the truth
values of propositions in all possible scenarios.
 We can combine all the possible combination with
logical connectives, and the representation of
these combinations in a tabular format is
called Truth table.
Prepositional Logic
Truth Table
Prepositional Logic
Logical equivalence:
 Two propositions are said to be logically
equivalent if and only if the columns in the truth
table are identical to each other.
 Let's take two propositions A and B, so for logical
equivalence, we can write it as A⇔B. In below
truth table we can see that column for ¬A∨ B and
A→B, are identical hence A is Equivalent to B
Prepositional Logic
Properties of Operators
 Commutativity:
 P∧ Q= Q ∧ P, or
P ∨ Q = Q ∨ P.
 Associativity:
 (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
 (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
 Identity element:
P ∧ True = P,
P ∨ True= True.
Prepositional Logic
Properties of Operators
 Distributive:
 P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
 DE Morgan's Law:
¬ (P ∧ Q) = (¬P) ∨ (¬Q)
¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
 Double-negation elimination:
¬ (¬P) = P.
Prepositional Logic
Limitations
 We cannot represent relations like ALL, some,
or none with propositional logic. Example:
 All the girls are intelligent.
 Some apples are sweet.
 Propositional logic has limited expressive
power.
 In propositional logic, we cannot describe
statements in terms of their properties or
logical relationships.
Rules of Inference in Artificial intelligence

 Inference:
 In artificial intelligence, we need intelligent
computers which can create new logic from old
logic or by evidence, so generating the
conclusions from evidence and facts is
termed as Inference.
Rules of Inference in Artificial intelligence

 Inference rules:
 Implication: It is one of the logical connectives which
can be represented as P → Q. It is a Boolean expression.
 Converse: The converse of implication, which means
the right-hand side proposition goes to the left-hand
side and vice-versa. It can be written as Q → P.
 Contrapositive: The negation of converse is termed as
contrapositive, and it can be represented as ¬ Q → ¬ P.
 Inverse: The negation of implication is called inverse.
It can be represented as ¬ P → ¬ Q.
Rules of Inference in Artificial intelligence

 From the above term some of the compound


statements are equivalent to each other, which
we can prove using truth table:
Types of Inference rules:

1. Modus Ponens
2. Modus Tollens
3. Hypothetical Syllogism
4. Disjunctive Syllogism
5. Addition
6. Simplification
7. Resolution
Inference Rules:
1. Model Ponens
 The Modus Ponens rule is one of the most important rules
of inference, and it states that if P and P → Q is true, then
we can infer that Q will be true. It can be represented as:
 Notation:
 Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then
Q will be true.
Inference Rules
2. Modus Tollens

 The Modus Tollens rule state that if P→ Q is true


and ¬ Q is true, then ¬ P will also true. It can
be represented as:
 Notation:
 Statement-1: "If I am sleepy then I go to bed"
==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not
sleepy" => ~P
Inference Rules
3. Hypothetical Syllogism:

 The Hypothetical Syllogism rule state that if P→R is true


whenever P→Q is true, and Q→R is true. It can be
represented as the following notation:
 Example:
 Statement-1: If you have my home key then you can unlock my
home. P→Q
Statement-2: If you can unlock my home then you can take my
money. Q→R
Conclusion: If you have my home key then you can take my
money. P→R
Inference Rules
4. Disjunctive Syllogism:
 The Disjunctive syllogism rule state that if P∨Q is
true, and ¬P is true, then Q will be true. It can be
represented as:
 Notation:
 Example:
 Statement-1: Today is Sunday or Monday.
==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
Inference Rules
5. Addition:

 The Addition rule is one the common inference


rule, and it states that If P is true, then P∨Q will be
true.
 Notation:
 Example:
 Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-
cream. ==> (P∨Q)
Rules of Inference
6. Simplification:

 The simplification rule state that if P∧ Q is true,


then Q or P will also be true. It can be
represented as:
 Notation:
Rules of Inference
7. Resolution:
 The Resolution rule state that if P∨Q and ¬ P∧R is
true, then Q∨R will also be true. It can be
represented as:
 Notation:
First Order Logic
 In propositional logic (PL), we can only represent the
facts, which are either true or false.
 PL is not sufficient to represent the complex
sentences or natural language statements
 Consider the following sentence, which we cannot
represent using PL logic.
 "Some humans are intelligent", or
 “John likes cricket.“
 To represent the above statements, PL is not
sufficient, so we require some more powerful logic,
such as first-order logic.
First order logic or Predicate Logic

 In First order logic or Prediacate logic, we break


the sentence in:
 Subject and predicate
 We take an English sentence and try to find the
subject and predicate
 Sweden is Beautiful
 Sweden: Subject
 Is Beautiful : Predicate
First-Order logic:

 First-order logic is another way of knowledge


representation in artificial intelligence. It is an
extension to propositional logic.
 FOL is sufficiently expressive to represent the
natural language statements in a concise way.
 First-order logic is also known as Predicate logic
or First-order predicate logic
 First-order logic is a powerful language that
develops information about the objects in a more
easy way and can also express the relationship
between those objects..
First-Order logic:
 First-order logic (like natural language) does not only
assume that the world contains facts like propositional
logic but also assumes the following things in the world:
 Objects: A, B, people, numbers, colors, wars, theories,
squares, pits,…
 Relations: It can be unary relation such as: red,
round, is adjacent, or n-any relation such as: the
sister of, brother of, has color, comes between
 Function: Father of, best friend, third inning of, end of,
......
 As a natural language, first-order logic also has two main
parts:
Syntax of First-Order logic:
 The syntax of FOL determines which collection of
symbols is a logical expression in first-order logic.
The basic syntactic elements of first-order logic
are symbols. We write statements in short-hand
notation in FOL.
 Following are the basic elements of FOL syntax:
Constant 1, 2, A, John, Hong Kong, cat,....
Variables x, y, z, a, b,....
Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....


Connectiv ∧, ∨, ¬, ⇒, ⇔
es
Equality ==
First-Order logic:
Atomic Sentences
 Atomic sentences are the most basic sentences of
first-order logic. These sentences are formed from
a predicate symbol followed by a parenthesis with
a sequence of terms.
 We can represent atomic sentences as Predicate
(term1, term2, ......, term n).
 Example: Andy and Raymond are brothers:
=>
Dinky is a cat: =>
First-Order logic:
Complex Sentences:

 Complex sentences are made by combining


atomic sentences using connectives.
 First-order logic statements can be divided
into two parts:
 Subject: Subject is the main part of the
statement.
 Predicate: A predicate can be defined as a
relation, which binds two atoms together in a
statement.
First Order Logic
Complex Sentences:

 Consider the statement: "x is an integer.", it consists


of two parts, the first part x is the subject of the statement
and second part "is an integer," is known as a predicate.

 FOL of this example will be:


 Integer(x)
Quantifiers in First-order logic:

 A quantifier is a language element which


generates quantification, and quantification
specifies the quantity of specimen in the universe
of discourse.
 These are the symbols that permit to determine or
identify the range and scope of the variable in the
logical expression. There are two types of
quantifier:
 UniversalQuantifier, (for all, everyone,
everything)
 Existential quantifier, (for some, at least
Universal Quantifier:

 Universal quantifier is a symbol of logical


representation, which specifies that the statement
within its range is true for everything or every instance
of a particular thing.
 The Universal quantifier is represented by a symbol ∀,
which resembles an inverted A.
 Note: In universal quantifier we use implication "→".
 If x is a variable, then ∀x is read as:
 For all x
 For each x
 For every x.
Universal Quantifier
 All man drink coffee.
 Let a variable x which refers to a man so all x can be represented in UOD as
below:

 ∀x man(x) → drink (x, coffee).


 Break it into two sentences:
 1. All man are x. (x is a subject, man is predicate)
 2. x drinks coffee (x and coffee are subject, drink is predicate)
 It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:
 Existential quantifiers are the type of quantifiers,
which express that the statement within its scope is
true for at least one instance of something.
 It is denoted by the logical operator ∃
 Note: In Existential quantifier we always use AND or
Conjunction symbol (∧)
 If x is a variable, then existential quantifier will be ∃x
or ∃(x). And it will be read as:
 There exists a 'x.'
 For some 'x.'
 For at least one 'x.'
Existential Quantifier:
 Some boys are intelligent.

 ∃x: boys(x) ∧ intelligent(x)


 Break it down in two sentences:
 X is a boy : boy(x)
 (atleast one) x is intelligent : intelligent(x)
 It will be read as: There are some x where x is a boy who is intelligent.
Exestential Quantifiers

 Points to remember:
 The main connective for universal quantifier ∀ is
implication →.
 The main connective for existential quantifier ∃ is
and ∧.
Properties of Quantifiers:

 In universal quantifier, ∀x∀y is similar to ∀y∀x.


 In Existential quantifier, ∃x∃y is similar to ∃y∃x.
 ∃x∀y is not similar to ∀y∃x.
Examples

 1. All birds fly.


In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be
represented as follows.
∀x bird(x) →fly(x).
Examples

 2. Every man respects his parent.


In this question, the predicate is "respect(x, y),"
where x=man, and y= parent.
Since there is every man so will use ∀, and it will
be represented as follows:
∀x man(x) → respects (x, parent).
Example

 3. Some boys play cricket.


In this question, the predicate is "play(x, y),"
where x= boys, and y= game. Since there are
some boys so we will use ∃, and it will be
represented as:
∃x boys(x) ∧ play(x, cricket).
Example
 4. Not all students like both Mathematics and Science.
In this question, the predicate is "like(x, y)," where x= student,
and y= subject.
Since there are not all students, so we will use ∀ with negation,
so following representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x,
Science)].

You might also like