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

Chapter-04-Knowledge Representation and Reasoning

Chapter 4 of the document discusses Knowledge Representation and Reasoning in Artificial Intelligence, focusing on how machines can be made intelligent through knowledge. It covers various techniques for knowledge representation, including logical representation, semantic networks, rules-based representation, and frame representation. Additionally, it explains the role of knowledge-based agents and the importance of inference in decision-making.

Uploaded by

gemechisgadisa77
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter-04-Knowledge Representation and Reasoning

Chapter 4 of the document discusses Knowledge Representation and Reasoning in Artificial Intelligence, focusing on how machines can be made intelligent through knowledge. It covers various techniques for knowledge representation, including logical representation, semantic networks, rules-based representation, and frame representation. Additionally, it explains the role of knowledge-based agents and the importance of inference in decision-making.

Uploaded by

gemechisgadisa77
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 71

Jimma University

Jimma Institute of Technology


Faculty of Computing and Informatics
Program: Information Technology
Course: Artificial Intelligence

Chapter 4

Knowledge Representation and Reasoning

1
Topics we will cover
 Introduction to Knowledge Representation
 Reasoning
 Knowledge-based Systems
 Logical Agents
 Logic and Inference
 Propositional Logic
 Predicate (First-Order)Logic
 Inference in First-Order Logic

2
Introduction
 Humans are intelligent because they have
knowledge/information with them gathered through
experience.

Here both the computer or


machine are empty box!

AI
In AI we have to make To make a machine
machines intelligent so intelligent, we have to
How? give knowledge to the
that it can work like
human. machine or computer.
3
Cont…
 This intelligence is defined as the ability to use those
gathered knowledge. Reasoning is a concept closely
aligned with intelligence.
 Reasoning is the processing of knowledge or
information to take a decision.

4
Cont…
 Unlikely, machines will jump since they don’t have a
knowledge, intelligence and reasoning ability.
Because it is not intelligent!

5
Cont…
 To make a machine intelligent like human, we have to induce
the right knowledge in those machines so that it can process
it to take a right decision.

 Note: The knowledge representation given to the


machine should be correct. Else they would generate
wrong output.
6
Techniques of Knowledge
Representation
 Humans excel at comprehension, reasoning, and
knowledge interpretation. Moreover, humans have
knowledge of things, and based on that knowledge,
they perform various actions in the real world. But how
can we get machines to do work based on knowledge
they have or have acquired?
 Knowledge representation and reasoning (KRR), on the
other hand, govern how machines carry out these
tasks.
 KRR is the study of how to express an intelligent
agent's beliefs, intentions, and judgments in a suitable
manner for automated reasoning.
 Let us examine how machines accomplish these task of
knowledge Representation
7
Cont…
 Knowledge Representation and Reasoning (KR, KRR)
represent data from the real world. A computer can
comprehend and then use this knowledge to solve
complex real-world problems, such as
communicating with humans in natural language.
 There are four ways by which we can represent a
knowledge. These are:

8
1. Logical Representation
 Logical Representation is a language with some concrete
rules which deals with propositions and has no ambiguity
in representation.
 It is a way of drawing conclusion based up on various
condition.
 It consists of precisely defined syntax and semantics
which supports the sound inference. Each sentence can
be translated into logics using syntax and semantics.
 There are two types of Logical Representation:
 Propositional Logic
 Predicate Logic
 A proposition is a statement which is either true or false
and doesn't depend on any parameters. E.g: 2 + 3 = 5
9
Cont…
 Their truth value can be either true or false, but it needs
to be assigned any of the two values and not be
ambiguous.
 The branch of logic that deals with proposition
is propositional logic.
 A predicate is statement whose truth value depends on
the parameters specified in the statement.
 A quantified predicate is a proposition , that is, when
you assign values to a predicate with variables it can be
made a proposition.
 E.g: x +3 = 5 is predicate whose value depends on the
value of x.
 Now, this predicate becomes a proposition when ‘x’ is
assigned a value(like 2, 4, -2 or etc..).
10
2.Semantic Network Representation
 Semantic means simply meaning. And network is to
mean a graph.
 So, in general semantic network is a representation
technique in which knowledge is stored into the
system in the form of meaningful graph.
 For example, Consider the given knowledge stored in
a machine:
 Ram has a cycle. We can represent this using
 Ram is a boy. semantic network, as in next
slide.
 The cycle has a bell.
 Ram is 12 years old.
 The cycle has two paddles.
11
Cont…

 In this graph, nodes of the graph represent an object.


Arrows represent the relationship between this object.
 In general, semantic network representation shows
the connectivity of one object with another object.
12
3. Rules based representation
 In this type of knowledge representation, knowledge
is represented using if and then statements and the
machine takes decision based up on this rules. That
is;
 If <condition> then <conclusion>
If-Pattern, Premise
 Example: or Antecedent
If Temperature is below 10
then the weather is cold

Then-Pattern, Conclusion
Consequent

13
4.Frame representation
 It is a record like structure which consist of a
collection of attribute and its values to describe an
entity in the world.

14
Knowledge Based Agents
 A knowledge based agent is an agent that uses a
knowledge or knowledge base(KB), which is the
collection of sentences.
 Sentence here is a technical term, related but not
identical to the sentences of English.
 The sentence in this context is expressed in a language
called a knowledge representation language(KR) and
represents some assertion about the world.
 For efficient decision-making and reasoning, a knowledge
based agent need knowledge about the real world.
 These agents are capable of maintaining an internal
state of knowledge, reasoning over that knowledge,
updating their knowledge following observations, and
taking actions.
15
Cont…
 Knowledge-based agents are composed of two main
parts:
 Knowledge base (KB): set of sentences in a formal
language.
 Inference Engine (IE): reasons with knowledge to
produce new knowledge.
 Inference means to find conclusion based on facts,
information, and evidence. Or it’s, deriving new
sentences from old.
Architecture of
Knowledge
Based Agent

16
How the knowledge based agent
works?
 As shown in the architecture, by observing the
environment, the knowledge-based agent (KBA)
receives input from it.
 The input is taken by the agent's inference engine,
which also communicates with KB to make decisions
based on the knowledge stored in KB.
 KBA's learning component keeps the KB up to date by
learning new information.
 It’s through this step that the KBA makes
decision(output).
 Why do agents need a knowledge base then?
 For an agent to learn from experiences and take
action based on the knowledge, a knowledge base is
required.
17
Cont…
 The sentences in the KB must therefore
contain a range of information.
 The agent must be able to:
 Represent and update states of the environment,
 Represent its own actions,
 Incorporate new precepts into the KB,
 Update internal representations of the world,
 Deduce hidden properties of the environment and
 Deduce what the ‘right’ action is at any given time.
 In addition, the KB must contain the goal(s)
of the agent.
18
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.
 Logics are formal languages for representing information such that
conclusions can be drawn.
 Syntax means a proper structure to represent information(refers to
a rule to represent an info).
 x+2 ≥ y is a sentence; (syntactically correct)
 x2+y > {} is not a sentence (syntax error)
 Semantics define the "meaning" of sentences; i.e., define the truth
of each sentence with respect to each possible world.
 For example, the semantics for arithmetic specifies that the
sentence
 x+2 ≥ y is true if the number x+2 is not less than the number y
 x+2 ≥ y is true in a world where x = 7, y = 1 but false in a world where x =

19 0, y = 6
Cont…
 Propositions are divided into two categories:
 Atomic propositions: Simple assertions are referred to as
atomic propositions. It is made up of only one proposition
sign. These are the sentences that must be true or false in
order to pass.
 Example:
 2+2 is 4, it is an atomic proposition as it is a true fact
 "The Sun is cold" is also atomic proposition as it is a false
fact.
 Compound proposition: formed when simpler or atomic
statements are combined using logical connectives.
 Example:
 "It is raining today, and street is wet.“
 "Ankit is a doctor, and his clinic is in Mumbai.“
 9 is divisible by 3 and 4 is an odd number.
20
Propositional logic: Rules
 In propositional logic, 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 and
logical connectives. These connectives are also called
logical operators.
 The propositions and connectives are the basic elements of
the propositional logic.
 Logical Connectives
 Negation: sentence such as ¬ P is called negation of P.
 Conjunction: sentence which has ∧ connective such as, P ∧ Q is
called a conjunction.
 Example: Bona is intelligent and hardworking. It can be written as,
P= Bona is intelligent,
Q= Bona is hardworking. → P∧ Q.
21
Cont…
 Disjunction: sentence which has ∨ connective, such as P ∨
Q is called disjunction, where P and Q are the
propositions.
 Implication: sentence such as P → Q, also known as if-then
rules.
 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
 Biconditional: 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.

22
Truth tables for connectives

Table – Truth table for propositional logic operators

Construct a truth table for the formula .

23
Propositional logic: Semantics
 Rules for evaluating truth with respect to a model
m:

Construct a truth table for

24
Logical Equivalence
 Two sentences are logically equivalent if they are
true in the same models: α ≡ ß if α╞ β and β╞ α.

Table – Logical equivalences for propositional logic

25
Cont…

1.P ∨ (Q ∨ R) =(P ∨ Q) ∨
Associative Law:
R
2.P ∧ (Q ∧ R) =(P ∧ Q)
P ∨ (Q ∧ R)∧? (P ∨ Q) ∧ (P ∨ R)
R
Distributive Law:
P ∧ (Q ∨ R) ? (P ∧ Q) ∨ (P ∧ R)

26
Precedence of operators (logical
connectives)

27
Translation….
 Translation of English sentences to propositional logic:
 Identify atomic sentences that are propositions
 Use logical connectives to translate more complex
composite sentences that consist of many atomic
sentences
 Assume the following sentence:
 E.g.: It is not sunny this afternoon and it is colder
than yesterday.
 Atomic sentences:
 p = It is sunny this afternoon
 q = it is colder than yesterday
 Translation: ¬ pq
28
Cont…
 Assume the following sentences:
1. It is not sunny this afternoon and it is colder than yesterday.
¬pq
2. We will go swimming only if it is sunny. r
→ p
3. If we do not go swimming then we will take a canoe trip. ¬
r→s
4. If we take a canoe trip, then we will be home by sunset.
s→ t
Denote:
• p = It is sunny this afternoon
• q = it is colder than yesterday
• r = We will go swimming
• s= we will take a canoe trip
• t= We will be home by sunset
29
Entailment
 Entailment means that one thing follows from
another.
 One sentence follows from another.
 The symbol for entailment is ‘╞’. KB ╞ α
 Knowledge base KB entails sentence α if and only if
α is true in all worlds where KB is true.
 E.g., x+y=4 entails 4=x+y
 Also written as x+y=4 ╞ 4=x+y
 Entailment is a relationship between sentences that
is based on semantics.

30
Cont…
 Exercise: Check weather ( A v C ) ^ (B v ¬ C )
entails ( A v B )

31
Models
 When we need to be precise, we use the term
model in place of ''possible world.”
 Whereas possible worlds might be thought of as
(potentially) real environments that the agent might
or might not be in.
 We say m is a model of a sentence α if α is true in
m.
 Examples:
 {x=2,y=2} is a model of the sentence x+y=4,
 {x=1,y=3} is a model of the sentence x+y=4
 Formally, the possible models are just
M(α) is the set of all models of α.
all possible assignments of real
numbers to the variables x and y.
32
Cont…
 Inference by Model Checking
 Inference means to find a conclusion based on the
facts, information, and evidence.
 KB ╞ α iff M(KB)  M(α)
 This definition states that if (and only if) the models
of the KB are a subset of the models of α, then the
KB entails α.
 E.g. KB = Morocco won and Argentina won,

α = Argentina won

33
Cont…
 Exercise
 Given two sentences ‘a’ and ‘b’ as;
 a ⊨ b, what does this refers to?
 ‘a’ entails ‘b’
 M(a) ⊆ M(b)
 ‘b’ is satisfied in all models of ‘a’.
 ‘b’ may be satisfied in other models (as
well).

34
Validity and Satisfiability
 A sentence is valid if it is true in all models,
 e.g., A V  A, AA, is true in any world(for any
values of A)
 Validity is connected to inference via the Deduction
Theorem:
 KB ╞ α if and only if (KB  α) is valid
 A sentence is satisfiable if it is true in some model,
 e.g., A, A V B, is true in some world only(i.e A=T,
B=T/F)
 A sentence is unsatisfiable if it is true in no models
 e.g., A  A, can never be true;
 Satisfiability is connected to inference via the following:
 KB ╞ α if and only if (KB  α) is unsatisfiable
35
Self Test Exercise
 Is this true: ( P  Q ) ?
 It depends on the values of P and Q
 This is a satisfiable sentence – there are some models
for which it is true and others for which it is false.
 Is this true: ( P  ¬P ) ?
 No, it is never true
 This is unsatisfiable sentence (self-contradictory) –
there is no models for which it is true
 Is this true: ( ((P V Q) ¬Q)  P ) ?
 Yes, independent of the values of P and Q
 This is a valid sentence – it is true under all possible
models (a.k.a. a tautology)
36
Proof by Applying Inference Rules
 Instead of enumerating truth tables, we can do proof
by successively applying sound inference rules:
 So, generating the conclusions from evidence and
facts is termed as inference.
 Any logical equivalence relation can be used as an
inference rule.
 Inference rules are the templates for generating
valid arguments. They are applied to derive proofs in
artificial intelligence(such as logical equivalence).
 The proof is a sequence of the conclusion that leads
to the desired goal.
 What are the widely used inference rules?
37
Cont…

38
Types of Inference Rules
 1. Modus Ponens: states that if P and P → Q is true,
then we can infer that Q will be true. It can be
represented as:

 Example: let P be I’m sleepy, Q be I go to bed.


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
We can
 Hence, we can say that, if P→ Q is true andproof
P this using
is true
then Q will be true. the truth table as shown.

((P→Q)  P) => Q
39
Cont…
 2. Modus Tollens: state that if P→ Q is true and ¬ Q is
true, then ¬ P will also true. It can be represented
as:

 Example: let P be I’m sleepy, Q be I go to bed.


 "If I am sleepy then I go to bed" P→ Q
 "I do not go to the bed." ~Q
 Which infers that "I am not sleepy" ~P
 Hence, we can say that, if P→ Q is true and ~Q is true thenproof
~P will be true.
We can this using the
truth table as shown.

((P→Q)  ~Q) => ~P

40
Cont…
 3. Conjunction elimination (also called AND
elimination)
 It is a rule of inference which makes the inference
that, if the conjunction A and B is true, then A is
true, and B is also true.

 An example in English: let P be it's raining, Q be


it's pouring.
 It's raining and it's pouring.
 Therefore it's raining. ((P  Q)
// => P , ((P  Q) =>
also Q
Therefore it is
pouring.
 Hence, we can say that, if P∧Q is true, therefore Q is true.
41 And P is also true.
Cont…
 4. Addition rule (also called OR introduction)
 States that if P is true, therefore what ever the value
of Q, the logic P V Q is always true. It is represented
as follows:

 Example:
 Let p be “I will study discrete math.”
 Let q be “I will visit Las Vegas.”
 “I will study discrete math.”
 “Therefore, I will study discrete mathP or
→(pI will
V q)
visit
Las Vegas.”
42
Cont…
 5. Conjunction rule (also called AND introduction)
 States that if P is true, and Q is also true, therefore the
logic P ∧ Q is always true. It is represented as follows:

 Example:
 Let p be “I will study discrete math.”
 Let q be “I will study English literature.”
 “I will study discrete math.”
 “I will study English literature.”
 “Therefore, I will study discrete math and I will study
English literature.” ((p) ∧ (q)) →(p ∧ q)
43
Cont…
 All logical equivalences can be used as inference
rules.

 Inference rules are sound. i.e. when their premises


are true their conclusions are also true.
 Resolution rule: prove the following resolution rule
using truth table.
A∨B,¬A∨C (A v B)∧ (¬A v C)  (B v C)
B∨C

44
Resolution
 Resolution is a method of proof that involves
constructing proofs having some initial premises.
 It is employed when several statements are supplied
and we need to prove a conclusion from those claims.
 Uses Conjunctive Normal Form (CNF): sentence that is
represented using conjunction of disjunctions of
literals.
 A formula is in CNF if it is a conjunction of one or more
than one clause, where each clause is a disjunction of
literals. In other words, it is a product of
sums where ∧ symbol occurs between the clauses and
the ∨ symbol occurs in the clauses.
Example: (A B)(B C D) ,
45
Conjunctive Normal Form (CNF)
 Literal is a proposition(P) or its negation(¬ P).
 Clause is a set of literals connected by using logical
connective (disjunction in this case). I.e P v Q
 Examples of conjunctive normal form.
 (¬q ∨ p ∨ r) ∧ (¬p ∨ r) ∧ q
 (p ∨ r) ∧ (¬p ∨ r) ∧ (p ∨ ¬r)
 Examples of formulas that are not in CNF!
 (¬(q ∨ p) ∨ r) ∧ (q ∨ r), since ¬ is not resolved,
cause (¬p ∧ ¬q)
 ¬(q ∨ p), since an OR is nested within a NOT
 p∧( q∨( r∧s) ), since an AND is nested within an OR
 ( p∧ q) ∨ r, since an AND is nested within an OR
46
Rules while converting a sentence
to CNF:
 Replace α⇔β by (α⇒β) ∧ (β⇒α). When this is
complete, the sentence will have no occurrence of
⇔.
 Replace α⇒β by ¬α∨β. When this is complete, the
only Boolean operators will be ∨, ¬, and ∧.
 Replace ¬(α∨β) by ¬α∧¬β; and ¬(α∧β) by ¬α∨¬β;
and ¬¬α by α. Repeat as long as applicable. When
this is done, all negations will be next to an atomic
sentence.
 Replace (α ∧ β) ∨ γ by (α ∨ γ) ∧ (β ∨ γ), and α ∨ (β
∧ γ) by (α ∨ β) ∧ (α ∨ γ). Repeat as long as
applicable. When this is done, all conjunctions will
be at top level.
47
Conversion to CNF
 Convert into CNF: B1,1  (P1,2  P2,1)
1. Eliminate , replacing α  β with (α  β) (β  α).
(B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1)

2. Eliminate , replacing α  β with α  β.


(implication law)
(B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

3. Move  inwards using deMorgan's rules and


double negation:
(B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

4. Apply distributive law ( over ):


(B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1) (in CNF!)

48
Cont…
 Note that: a single literal can also be in a
CNF i.e p and ¬p are in CNF; but ¬ ¬ p is not
in a CNF! As from the rules of CNF!
 Convert the following sentences into
conjunctive normal form(CNF):
A. A<=>B
Ans: it’s CNF is:
B. (P ⇒ Q) ⇒ R
Ans:
C. A <=> (B => C)
Ans:
49
First-Order Logic:
 Why FOL?
 Syntax and Semantics of FOL
 Using FOL

50
Introduction
 Propositional Logic:
 We can only represents facts which are either True or
False. Example: 3 is an odd number.
 Represent a knowledge base (KB) using a formal
language.
 It is limited in its expressiveness in that it is unable to
represent facts about some or all objects in the universe.
 Example: Some humans are intelligent. All cars are
beautiful.
 First-Order Logic:
 An alternative (and more expressive) language for
representing KBs.
 It has the capability of expressing facts about some or all
objects in the universe using quantifiers.
51
First-Order Logic (FOL)
 It is also known as predicate logic.
 First-order logic (like natural language) assumes the
world contains,
 objects: represent things in the real world.
 E.g: people, houses, numbers, colors …
 relations: represent attributes of object or
relationships between objects.
 E.g: red, round, prime, brother of, bigger than, part
of, comes between, …
 functions: take object(s) and return an object result.
 E.g: Length(), TeammateOf(), best friend(), Sqrt()

52
Syntax of FOL: Basic elements
 Sentences in FOL represent these components of the world
using the following elements:
 constants: represent objects
 E.g: Haileselassie, 2, Blue, …
 predicates: represent relations
 E.g: Brother, >, …
 functions: represent functions
 E.g: Sqrt, LeftLegOf, …
 variables: by convention lower case letters
 E.g: x, y, a, b,...
 connectives: the same 5 connectives as are used
 i.e.: , , , , 
 equality: the two terms refer to the same object
 i.e. =
 quantifiers: existential and universal
53
Atomic Sentences
 Atomic sentence:
 The simplest type of sentence in FOL.
 An atomic sentence consists of either:
 Atomic sentence = predicate(term ,...,term ) where a term
1 N
is either:
 Term =function (term ,...,term ) or constant or variable
1 N

 E.g.1. TeammateOf(Kenenisa, HaileGebreselassie)


 The first example consists of a predicate, TeammateOf, with
two constant arguments, HaileGebreselassie and Kenenisa.
 E.g.2 Length(LeftLegOf(Kenenisa)) =
Length(RightLegOf(Kenenisa))
 The second example contains two constants (both
Kenenisa), combined using three functions, Length,
LeftLegOf and RightLegOf.
54
Complex Sentences
 Complex sentences are made from atomic
sentences using connectives:
 We can make more complex sentences by
combining atomic sentences using connectives
 S, S  S , S  S , S  S , S  S ,
1 2 1 2 1 2 1 2
 E.g.
 Teammate(Kenenisa,HaileGebreselassie) 
Teammate(HaileGebreselassie,Kenenisa)
 >(1,2)  ≤ (1,2)
 >(1,2)   >(1,2)

55
Interpretations
 Sentences are true with respect to a model and an
interpretation.
 Model contains objects (domain elements) and
relations among them.
 Interpretation specifies (real-world) referents for
 constant symbols → objects
 predicate symbols → relations
 function symbols →functional relations

 An atomic sentence predicate(term1,...,termN) is true


if the objects referred to by term1,...,termN are in the
relation referred to by predicate.

56
First-Order Logic Quantifiers
 First-Order Logic Quantifiers
 It is FOL quantifiers that give the language
its expressive power.
 There are two types of quantifier:
 universal quantifiers ()
 existential quantifiers ()

57
Universal Quantification
 The symbol for universal quantification is .
 To interpret the universal quantification symbol in a
FOL sentence we can read it as “for all …”.
 <variables> <sentence>
 E.g. x At(CS , x)  Intelligent(x)
 Can be interpreted as stating that “for all x,
At(CS, x) implies Intelligent(x)”.
 In other words, if everyone is at CS then they
are intelligent.
 Definition:
 x P is true in a model m iff P is true with x being
each possible object in the model.

58
A common mistake to avoid
 Typically,  is the main connective with .
 Common mistake: using  as the main connective
with :
 For Examples:
 x At(CS , x)  Intelligent(x)
 Means “Everyone is at CS and everyone is intelligent”
 x At(CS , x)  Intelligent(x)
 Means “Everyone at CS is intelligent”

59
Existential Quantification
 The symbol for existential quantification is .
 We can read this as “there exists …”.
 <variables> <sentence>
 E.g. x At (CS , x)  Intelligent(x)
 can be interpreted as stating that “there exists some x,
such that At(CS, x) and Intelligent(x) are both true.
 In other words, somebody at CS is intelligent.

 Definition:
o x P is true in a model m iff P is true with x being
some possible object in the model

60
Another common mistake to avoid
 Typically,  is the main connective with .
 Common mistake: using  as the main
connective with  :
 For Examples:
 x At(CS , x)  Intelligent(x)
 is true if there is anyone who is not at CS!
 x At (CS , x)  Intelligent(x)
 Means “Someone at CS is intelligent”

61
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
 x y Loves(x,y)
 “There is a person who loves everyone in the world”
 y x Loves(x,y)
 “Everyone in the world is loved by at least one person”

62
Equality in First-Order Logic
 The equality symbol in FOL does not mean that
same as assignment in most programming
languages.
 A sentence involving the ‘=’ symbol in FOL is true if
both of its arguments refer to the same object.
 term = term is true under a given interpretation
1 2
if and only if term1 and term2 refer to the same
object.
 E.g., x,y Brother(x,Abebe)  Brother(y,Abebe)  (x=y)
 x and y do not refer to the same object. In other words,
Abebe has two (distinct) brothers.
 Without the use of the equality symbol, the above sentence
would be true if x and y had the same value (i.e. Abebe has
one brother).
63
More Examples on FOL
 1. All birds fly.
 The predicate is "fly(x)", where x = bird.
 ∀x bird(x) →fly(x).
 2. Every man respects his parent.
 The predicate is "respect(x, y)," where x=man,
and y= parent.
 ∀x man(x) → respects (x, parent).
 3. Some boys play cricket.
 The predicate is "play(x, y)" where x= boys, and
y= game.
 ∃x boys(x) → play(x, cricket).
64
Cont…
 4. Not all students like both Mathematics and
Science.
 The predicate is "like(x, y)" where x= student, and
y= subject.
 ¬∀ (x) [ student(x) → like(x, Mathematics) ∧
like(x, Science)].
 5. Only one student failed in Mathematics.
 The predicate is "failed(x, y)" where x= student,
and y= subject.
 ∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y)
[¬(x==y) ∧ student(y) → ¬failed (x,
Mathematics)].
65
Inference in First-Order Logic
 Inference in First-Order Logic is used to deduce new
facts or sentences from existing sentences.
 1. The rule of Universal Instantiation (UI):
 Universal instantiation is also called as universal
elimination or UI is a valid inference rule. It can be
applied multiple times to add new sentences.
 The new KB is logically equivalent to the previous
KB.
 The UI rule state that we can infer any sentence P(c)
by substituting a ground term c (a constant within
domain x) from ∀ x P(x) for any object in the
universe of discourse.
 It can be represented as:
66
Universal Instantiation (UI)….
 Example:1.
 IF "Every person like ice-cream" that is;
 ∀x P(x) → like(x, ice-cream) so we can infer that
 "John likes ice-cream" ; P(c) → like(c, ice-cream)
 Example: 2.
 x (Fast(x)  Strong(x))  EthiopianRunner(x)
 For example, if the KB contains the symbols Kenenisa,
Derartu and Haile, then we can infer any of the following
statements using Universal Instantiation:
Fast(Kenenisa)  Strong (Kenenisa)  EthiopianRunner
(Kenenisa)
Fast(Derartu)  Strong (Derartu)  EthiopianRunner
(Derartu)
Fast(Haile)  Strong (Haile)  EthiopianRunner (Haile).
67
Existential Instantiation(EI)….
 2. The rule of Existential Instantiation(EI):
 Also called Existential Elimination, which is a valid
inference rule in first-order logic.
 It can be applied only once to replace the existential
sentence.
 The new KB is not logically equivalent to old KB, but
it will be satisfiable if old KB was satisfiable.
 This rule states that one can infer P(c) from the
formula given in the form of ∃x P(x) for a new
constant symbol c.
 The restriction with this rule is that c used in the rule
must be a new term for which P(c ) is true.
 It can be represented as:
68
Cont…
 We must create a new sentence for each existential
quantifier using a new object name that does not
already exist in the KB.
 Example: 1. x Runner(x)  TeammateOf(x,Kenenisa)
 This sentence(FOL) could be converted to:
 Runner(C )  TeammateOf(C ,Kenenisa)
1 1
 Example: 2. ∃x Crown(x) ∧ OnHead(x, John),
 So we can infer:
 Crown(K) ∧ OnHead( K, John), as K does not appear
in the kb.
 The above used K is a constant symbol, which is
called Skolem
constant.
69
Cont…
 The process of eliminating both universal and
existential quantifiers is known as propositionalising
the KB.
 Every FOL KB can be propositionalised so as to
preserve entailment.

 Reading assignment:
3. Universal Generalization
4. Existential introduction

70
71
?

You might also like