Artificial Intelligence
Prepared by:
Ataklti Nguse
Chapter Four:
knowledge-based Agents
01/08/2025 1
2
4.1. Knowledge-based agent
01/08/2025
•An intelligent agent needs knowledge about the real world for taking decisions
and reasoning to act efficiently.
• Knowledge-based agents are those agents who have the capability of
–maintaining an internal state of knowledge,
–reason over that knowledge,
–update their knowledge after observations and take actions.
•These agents can represent the world with some formal representation and act
intelligently.
3
Continued…
• A knowledge-based agent is an agent that consists of two parts:
• a knowledge base and an inference engine
• The central component of a knowledge-based agent is its knowledge base, or
KB.
• A knowledge base is a set of sentences.
• Each sentence is expressed in a language called a knowledge representation
language and represents some assertion about the world.
• The inference engine is consists of algorithms that take the contents of the
knowledge base and infer (i.e. deduce) new knowledge about the world.
01/08/2025
4
Knowledge Base (KB)
• Contains set of facts about the domain expressed in a
suitable representation language
–Each individual representation are called sentences
–Sentences are expressed in a (formal) knowledge representation
(KR) language
• A KBA is designed such that there is a way to:-
–TELL it (i.e. to add new sentences to the KB) and ASK it (i.e. to
query the KBA)
–TELLs the knowledge base what it perceives.
–When one ASKs a question, the answer should follow from what
has been TELLed to the KB previously.
–ASKs the knowledge base what action to perform.
–Inference mechanism determines what follows from what has been
TELLed to the KB
01/08/2025
5
Figure 1 – The structure of a knowledge-
based agent
01/08/2025
6
Cont…
• The agent receives precepts from the environment they will be converted
into sentences and added to the KB
• Inference engine generates new knowledge it is also added to the KB
• When the agent needs to make an action, we must ask the KB what the
optimal action will be at that time
• There must be some way of telling the KB a new piece of information;
• and there must be some way of asking the KB some question about the
environment
01/08/2025
7
Schematic perspective KBR
• If KB is true in the real world, then any sentence  derived from KB by a sound
inference procedure is also true in the real world.
• chuchu is sick with the corona virus chuchu is sick
⊨
01/08/2025
8
Entailment and derivation
01/08/2025
9
Continued…
• Knowledge can also be represented by the symbols of logic, which is
the study of the rules of exact reasoning.
• Logic is also of primary importance in expert systems in which the
inference engine reasons from facts to conclusions.
• A descriptive term for logic programming and expert systems is
automated reasoning systems.
01/08/2025
10
4.2. Logic as KR
•A Logic is a formal language in which knowledge can be represented
such that conclusions can be drawn.
–It is a declarative language to assert sentences and deduce from
sentences.
•Components of a formal logic
•Syntax: what expressions/structures are allowed in the language.
Describes how to make sentences
E.g. red(mycar) is ok, but mycar(grey or green) is not.
–Semantics: express what sentences mean, in terms of a mapping to
real world.
•Semantics relate sentences to reality.
•E.g. red(mycar) means that my car is red.
–Proof Theory: how we can draw new conclusions from existing
statements in the logic.
–It is a means of carrying our reasoning using a set of rules.
–Reasoning: is the process of constructing new sentences from existing facts
in the KB.
01/08/2025
11
Continued…
• Logic accepted rules for making precise statements.
• Logic essential for computer science: programming,
artificial intelligence, logic circuits...
• Logic
– Represents knowledge precisely
– Helps to extract information (inference)
01/08/2025
12
Logical Arguments
• An argument is a sequence of statements.
• The last statement is called the conclusion, all the previous
statements are premises (or assumptions/ hypotheses).
• A valid argument is an argument where the conclusion is true if the
premises are true.
01/08/2025
13
Continued…
• In mathematics there are different kinds of logics. Some of these
according to order of their generality are:-
• Logical representation can be categorized into mainly two
logics:
– Propositional logic
– First order logic
01/08/2025
14
4.2.1.Propositional (Boolean) logic (PL)
• 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 but not
both at any time.
• It is a technique of knowledge representation in logical and mathematical
form.
• Proposition can be conditional or unconditional
Examples
– It is Sunday.
– The Sun rises from West (False proposition)
– Socrates is mortal
– If the winter is severe, then students will not succeed.
– All are the same iff their color is black
• In propositional logic, symbols represent the whole proposition.
Examples:
– M = Socrates is mortal
– W = winter is sever
– S = students will not succeed
01/08/2025
15
Continued…
• 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.
• Propositional logic consists of an object, relations or function, and logical
connectives.
• These connectives are also called logical operators which connects two sentences.
• The propositions and connectives are the basic elements of the propositional logic.
• 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 Rohini", "How are you", "What is your name", are not propositions.
01/08/2025
16
Syntax of propositional logic:
• The syntax of propositional logic defines the allowable sentences for
the knowledge representation.
• There are two types of Propositions:
• Atomic Proposition: Atomic propositions are the simple
propositions.
• It consists of a single proposition symbol. These are the sentences
which must be either true or false.
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
•Compound proposition: Compound propositions are constructed by
combining .
•Example
a)It is raining today, and street is wet."
b) “Jemal is a doctor, and his clinic is in harar."
01/08/2025
17
Logical Connectives:
• Logical connectives are used to connect two simpler
propositions or representing a sentence logically.
• We can create compound propositions with the help of logical
connectives.
• There are mainly five connectives, which are given as follows:
01/08/2025
18
Propositional Logic Connectives:
01/08/2025
19
Precedence of connectives:
• Just like arithmetic operators, there is a precedence order for
propositional connectors or logical operators.
01/08/2025
Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Six Precedence Bi conditional
20
Propositional logic (PL): Syntax
• A proposition is simply a statement that is either true or false.
• The syntax of PL defines the allowable sentences
• The proposition symbols S1, S2 etc are sentences
• If S is a sentence, S is a sentence (negation)
• If S1 and S2 are sentences, S1  S2 is a sentence (conjunction)
• If S1 and S2 are sentences, S1  S2 is a sentence (disjunction)
• If S1 and S2 are sentences, S1  S2 is a sentence (implication)
• If S1 and S2 are sentences, S1  S2 is a sentence (biconditional)
01/08/2025
21
sentences in PL
Examples: Convert from English sentence to PL
Let A = Lectures are active, R = Text is readable, and P = Kebede will
pass the exam, then represent the following:
• the lectures are not active:
• the lectures are active and the text is readable:
• either the lectures are active or the text is readable:
• if the lectures are active, then the text is not readable:
• the lectures are active if and only if the text is readable:
• if the lectures are active, then if the text is not readable, Kebede will
not pass the exam:
A
A  R
A V R
A   R
A  R
A  (R  P )
22
Proofing theorem using Propositional logic (PL)
Exercise: convert P sentences to PL:
•“It is humid.”:
•“If it is humid, then it is hot” :
•“If it is hot and humid, then it is raining”:
01/08/2025
23
Semantics
•Specify the interpretation of the proposition symbols &
constants, and the meanings of the logical connectives
–Truth Tables: define the semantics of sentences. The following table
shows truth table for the five logical connectives.
Note: P and Q can be any sentence, including complex
sentences.
P Q P PQ PQ PQ PQ
True True False True True True True
True False False False True False False
False True True False True True False
False False True False False True True
01/08/2025
24
Semantics (Complex Sentences)
R S R RS R
S
(RS)(R
S)
True True False True True True
True False False False False True
False True True False True True
False False True False True True
• Complex sentences such as (RS)(RS) are
defined by a process of decomposition.
– First determine the meaning of (RS) and of (RS).
– Then combine them using the definition of the  function
•Can you write the truth table for:
–(P  Q)  (R  P)
01/08/2025
25
Logical equivalence:
• Logical equivalence is one of the features of
propositional logic.
• Two propositions are said to be logically equivalent if
and only if the columns in the truth table are identical
to each other.
01/08/2025
26
Logical equivalence
•Two sentences are logical equivalent iff they are true in
same models. α Ξ β if and only if α |= β and β |= α
01/08/2025
27
Continued…
–Is (P  Q)  R same as P  (Q  R) ?
–Is (P  Q)  R same as P  (Q  R) ?
–Is (P  Q)  R same as P  (Q  R) ?
01/08/2025
28
Equivalent Expressions
• Consider the following three statements
• Helen is not married but Biniam is not single
• ¬ h ∧ ¬ b
• Biniam is not single and Helen is not married
• ¬ b ∧ ¬ h
• Neither Biniam is single nor Helen is married
• ¬ (b h)
∨
• These three statements are equivalent
• ¬ h ∧ ¬ b ≡ ¬ b ∧ ¬ h ≡ ¬ (b h)
∨
01/08/2025
29
4.2.2. Inference Rule for PL
 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.
 To prove validity of a sentence, there are a set of already
identified patterns called inference rules.
 Inference is the process of finding what sentences are entailed
01/08/2025
30
Inference Rules
RULE PREMISE CONCLUSION
Modus Ponens A, A  B B
Modus Tolens B, A  B A
And Elimination A  B A
And Introduction A, B A  B
Or Introduction A A1  A2 …  An
Double Negation Elimination  A A
Unit Resolution A  B, B A
Resolution A  B, B 
C
A  C
Hypothetical Syllogism PQ, QR PR
• In the case of modus ponens, if A is true and A  B is true, then
conclude B is true.
01/08/2025
31
Continued
01/08/2025
32
Soundness vs Completeness
• Soundness: If KB Q then KB Q
⊢ ⊨
–If Q is derived from a set of sentences KB using a given set of rules of
inference, then Q is entailed by KB.
 A rule is sound if its conclusion is true whenever the premise is true
–Hence, inference produces only real entailments, or any sentence that follows
deductively from the premises is valid.
• Completeness: If KB Q then KB Q
⊨ ⊢
–If Q is entailed by a set of sentences KB, then Q can be derived from KB
using the rules of inference.
• Soundness means that you cannot prove anything that's wrong.
• Completeness means that you can prove anything that's right.
01/08/2025
33
Continued…
01/08/2025
34
Terminology
•Valid sentence: A sentence is valid sentence or tautology if and only if
it is True under all possible interpretations in all possible worlds.
Example: “It’s raining or it’s not raining.” (R  R).
•Satisfiable: A sentence is satisfiable if and only if there is some
interpretations in some world for which the sentence is True.
Example: “It is raining or it is humid”. R v Q, R
•Unsatisfiable: A sentence is unsatisfiable (inconsistent sentence or
self- contradiction) if and only if it is not satisfiable, i.e. a sentence that
is False under all interpretations. The world is never like what it
describes.
Example: “It’s raining and it's not raining.” R  R
01/08/2025
35
Formal Proofs
•A proof is a sequence of sentences, where each sentence is
either a premise or a sentence derived from earlier sentences in
the proof by one of the rules of inference.
•The last sentence is the theorem (also called goal or query) that
we want to prove.
Example: The “weather problem”. Proof whether it is
raining or not.
1. Q Premise “It is humid”
2. Q  P Premise “If it is humid, it is hot”
3. (PQ)  R Premise “If it’s hot & humid, it’s raining”
4. P Modus Ponens(1,2) “It is hot”
5. PQ And Introduction(1,4) “It is hot and humid”
6. R Modus Ponens(3,5) “It is raining”
01/08/2025
36
Example 2
 Construct formal proof of validity for the following problem:
 If the investigation continues, then new evidence is brought to
light.
 If new evidence is brought to light, then several leading citizens
are implicated.
 If several leading citizens are implicated, then the newspapers
stop publicizing the case.
 If continuation of the investigation implies that the newspapers
stop publicizing the case, then the bringing to light of new
evidence implies that the investigation continues.
 The investigation does not continue. Therefore, new evidence is
not brought to light.
 Represent using PL and proof the conclusion that “new evidence is not
brought to light”.
01/08/2025
37
Solution
Let
C: The investigation continues.
B: New evidence is brought to light.
I: Several leading citizens are implicated.
S: The newspapers stop publicizing the case.
1. C  B
2. B  I
3. I  S
4. (C  S)  (B  C)
5. C
6. C  I 1,2 (Hypothetical Syllogism)
7. C  S 6,3 (Hypothetical Syllogism)
8. B C 7,4 (Modus Ponens)
9. B 8,5 (Modus Tollens)
38
Continued…
 During a murder investigation, you have gathered the following clues:
1. if the knife is in the store room, then we saw it when we cleared the
store room;
2. the murder was committed at the basement or inside the apartment;
3. if the murder was committed at the basement, then the knife is in the
yellow dust bin;
4. we did not see a knife when we cleared the store room;
5. if the murder was committed outside the building, then we are unable
to find the knife;
6. if the murder was committed inside the apartment, then the knife is in
the store room.
The question is: where is the knife?"
01/08/2025
39
Continued…
• First, we assigned symbols to the above clues:
• s : the knife is in the store room;
• c : we saw the knife when we clear the store room;
• b : the murder was committed at the basement;
• a : murder was committed inside the apartment;
• y : the knife is in the yellow dust bin;
• o : the murder was committed outside the building;
• u : we are unable to find the knife;
01/08/2025
40
01/08/2025
More examples
41
Example 3
 Deme is either intelligent or a good actor.
 If Deme is intelligent, then he can count from 1 to 10.
 Deme can only count from 1 to 2.
 Therefore Deme is a good actor.
 Represent using PL and proof the conclusion that Deme is
a good actor or not.
Let:
I: Deme is intelligent
A: Deme is a good actor.
C: Deme can count from 1 to 10.
01/08/2025
42
What rule is used for the
conclusion?
1. If world population continues to grow, then cities will
become hopelessly crowed; If cities become
hopelessly overcrowded, then pollution will become
intolerable. Therefore, if world population continues
to grow then pollution will become intolerable.
2. Either Yohanes or Thomas was in Ethiopia;
Yohanes was not in Ethiopia. Therefore, Thomas
was in Ethiopia.
01/08/2025
43
Continued
3.If twelve million children die yearly form starvation,
then something is wrong with food distribution;
Twelve million children die yearly form starvation.
Therefore, something is wrong with food distribution.
4.If Japan cares about endangered species, then it has
stopped killing whales; Japan has not stopped
killing whales. Therefore, Japan does not care about
endangered species.
01/08/2025
44
Which rule of inference is used in each
argument below?
• Alice is a Math major. Therefore, Alice is either a Math major or a CSI
major.
• Jerry is a Math major and a CSI major. Therefore, Jerry is a Math
major.
• If it is rainy, then the pool will be closed. It is rainy. Therefore, the pool
is closed.
• If it snows today, the university will close. The university is not closed
today. Therefore, it did not snow today.
• If I go swimming, then I will stay in the sun too long. If I stay in the
sun too long, then I will sunburn. Therefore, if I go swimming, then I
will sunburn.
• l go swimming or eat an ice cream. I did not go swimming.
• Therefore, I eat an ice cream.
01/08/2025
45
Formal proof example
• Show that the hypotheses:
• It is not sunny this afternoon and it is colder than yesterday.
• We will go swimming only if it is sunny.
• If we do not go swimming, then we will take a canoe trip.
• If we take a canoe trip, then we will be home by sunset.
• lead to the conclusion:
• We will be home by the sunset.
• Main steps:
1Translate the statements into propositional logic.
2 Write a formal proof, a sequence of steps that state hypotheses
or apply inference rules to previous steps.
01/08/2025
46
Valid Arguments
• Example 1: From the this proposition
• P^(p->q)
• Show that q is a conclusion.
• Show that : ¬ q→ ¬ p ≡ p→ q
• Show that p q → r ≡ (p → r) (q → r)
∨ ∧
• (f ^ a ->r);
• f ;
• -a;
• Therefor:- -r;
01/08/2025
47
Forms of Logical expression
• There are different standard forms of expressing PL statement. Some
of these are:
1. Clausal normal form: it is a set of one or more literals connected with
the disjunction operator (disjunction of literals).
Example ~P  Q  ~R is a clausal form
2. Conjunctive normal forms (CNF): conjunction of disjunction of
literals or conjunction of clauses.
Example (A  B)  (C D)
3. Disjunctive normal form (DNF): disjunction of conjunction of literals.
Example (A  B) (C  D)
4. Horn form: conjunction of literals implies a literal.
Example (A  B  C D)=>E
01/08/2025
48
Cont.
• Normal forms can be obtained by applying
equivalence laws
[(A v B) => (C v D)] => P
~[~(A v B) v (C v D)] v P
[~~(A v B) ^ ~(C v D)] v P
[(A v B)^(~C ^ ~D)] v P
(A v B v P)^(~C^~D v P)
(A v B v P)^(~C v P)^(~D v P) a CNF
01/08/2025
49
Practical Example (The Wumpus world
• Goal: Agent wants to move to the square which holds Gold, grab it
and come back to the original square and release it there
• Initially agent could be at any of the square
01/08/2025
50
Wumpus World PEAS description
• Performance measure
– gold +1000, death -1000
– -1 per step, -10 for using the arrow
• Environment
– Squares adjacent to wumpus are smelly
– Squares adjacent to pit are breezy
– Glitter iff gold is in the same square
– Shooting kills wumpus if you are facing it
– Shooting uses up the only arrow
– Grabbing picks up gold if in same square
– Releasing drops the gold in same square
• Sensors: Stench, Breeze, Glitter, Bump, Scream
• Actuators: Left turn, Right turn, Forward, Grab(obtain), Release, Shoot
• YOUR MISSION Prove that the Wumpus is in (1,3) and
• there is a pit in (3,1), given the observations shown and these rules:
51
Continued…
In the square containing the wumpus and in the directly (not diagonally)
adjacent squares, the agent will perceive a Stench.
– In the squares directly adjacent to a pit, the agent will perceive a Breeze.
– In the square where the gold is, the agent will perceive a Glitter.
– When an agent walks into a wall, it will perceive a Bump.
– When the wumpus is killed, it emits a woeful Scream that can be perceived
anywhere in the cave
01/08/2025
52
Limitations of Propositional logic:
• 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.
01/08/2025
• 53
4.3. First Order Logic (FOL)
• 01/08/2025
• 54
First Order Logic (FOL)
• First-order logic is another way of knowledge representation in
artificial intelligence sometime is called Predicate 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:
• 01/08/2025
• 55
Syntax of First-Order logic:
• As a natural language, first-order logic also has two main parts:
– Syntax
– Semantics
• 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.
• write statements in short-hand notation in FOL.
• 01/08/2025
• 56
Atomic sentences:
• 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: Abebe and Dereje are brothers: Brothers(Abebe, Dereje).
Chinky is a cat: cat (Chinky).
• Complex Sentences:
• Complex sentences are made by combining atomic sentences using
connectives.
• Abebe like both Mathematics and Science.
• 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.
• Consider the statement: "x is an integer."
• 01/08/2025
• 57
Quantifiers in First-order logic:
• 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:
– Universal Quantifier, (for all, everyone, everything)
– Existential quantifier, (for some, at least one).
• All men drink coffee.
– ∀x men(x) → drink (x, coffee).
• It will be read as: There are all x where x is a men who drink coffee.
• Some boys are intelligent.
– ∃x: boys(x) intelligent(x)
∧
• It will be read as: There are some x where x is a boy who is
intelligent.
• The main connective for universal quantifier ∀ is implication →.
• The main connective for existential quantifier ∃ is and ∧.
• 01/08/2025
• 58
Universal Quantification
• Universal Quantifiers: makes statements about every object
<variables> <sentence>
–Everyone at AAU is smart:
x At(x,AAU)  Smart(x)
–All cats are mammals:
x cat(x)  mammal(x)
• x sentence P is true iff P is true with x being each possible object in the given
universe
–The above statement is equivalent to the conjunction
At(Jone, AAU)  Smart(Jone) 
At(Jemal, AAU)  Smart(Jemal)  ….
Typically,  is the main connective with 
–Common mistake: the use of  as the main connective with :
• 01/08/2025
• 59
Existential Quantification
•Makes statements about some objects in the universe
<variables> <sentence>
–Someone at AAU is smart:
x At(x,AAU)  Smart(x)
–Spot has a sister who is a cat:
x sister(spot,x)  cat(x)
•x sentence P is true iff P is true with x being some possible objects
–The above statement is equivalent to the disjunction
At(Jone, AAU)  Smart(Jone) 
At(Alemu, AAU)  Smart(Alemu)  ….
•Common mistake to avoid
–Typically,  is the main connective with 
–Common mistake: using  as the main connective with :
• 01/08/2025
• 60
Nested Quantifiers
•x,y parent(x,y)  child(y,x)
–for all x and y, if x is the parent of y then y is the child of x.
•x y Loves(x,y)
–There is a person who loves everyone in the given world
•y x Loves(x,y)
–Everyone in the given universe is loved by at least one person
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
•Quantifier duality: each can be expressed using the other, using
negation ()
x Likes(x,icecream) x Likes(x,icecream)
–Everyone likes ice cream means that there is nobody who dislikes ice
cream
 Likes(x,cake)  Likes(x,cake)
• 01/08/2025
• 61
Continued…
• 01/08/2025
• 62
Examples
• FOL is a more powerful form of logic
–Almost any English sentence may be represented in first- order predicate
calculus
Example:
(1) John’s mother is married to John’s father
married(father(john), mother(john))
(2) Potato is good and Potato is a kind of food
good(Potato) Ù is(Potato, food)
good(Potato) Ù food(Potato)
(3) All food are edible
"X food( X) ® edible( X)
• FOL Contains predicates, quantifiers and variables
• E.g. Philosopher(a) -> Scholar(a)
• 63
Sentences
Represent the following using variables & quantifiers:
• Everything in the garden is lovely 
•Everyone likes ice cream 
•Peter has some friends 
•John plays the piano or the violin
•Some people like snakes --
•Jones did not write thesis –
•Nobody wrote thesis –
x in(x, garden)  lovely(x)
x likes(x, icecream)
y friends(Peter,y)
plays(john, piano) v plays(john, violin)
x(person(x) Λ likes(x, snakes))
write( Jones, thesis)
x write(x, thesis)
• 01/08/2025
• 64
Some Examples of FOL using quantifier:
1. All birds fly.
2. Every man respects his parent.
3. Some boys play cricket.
4. Not all students like both Mathematics and Science.
• 01/08/2025
• 65
Semantics
•There is a precise meaning to expressions in predicate logic.
•Like in propositional logic, it is all about determining whether
something is true or false.
•x P(x) means that P(x) must be true for every object x in the domain of
interest.
•x P(x) means that P(x) must be true for at least one object x in the
domain of interest.
– So if we have a domain of interest consisting of just two people,
john and merry, and we know that tall(merry) and tall(john) are
true, we can say that x tall(x) is true.
• 01/08/2025
• 66
Inference in First-Order Logic
• Inference in First-Order Logic is used to deduce new facts or sentences from
existing sentences.
• FOL inference rules for quantifier:
• As propositional logic we also have inference rules in first-order logic, so
following are some basic inference rules in FOL:
– Universal Generalization
– Universal Instantiation
– Existential Instantiation
– Existential introduction
• 01/08/2025
• 67
Sound Inference Rules
•Rules for PL apply to FOL as well.
–For example, Modus Ponens, And-Introduction, And-Elimination, etc.
•New (sound) inference rules for use with quantifiers:
–By substituting particular individuals for the variable. E.g. substitute
(x/sam, y/cake). Then likes(x,y) = likes(sam,cake)
• Universal Generalization:
• Universal generalization is a valid inference rule which states that if
premise P(c) is true for any arbitrary element c in the universe of
discourse, then we can have a conclusion as x P(x).
∀
• Example: Let's represent, P(c): "A byte contains 8 bits", so
for x P(x)
∀ "All bytes contain 8 bits.", it will also be true.
• 01/08/2025
• 68
Continued…
•Universal Elimination: If "x P(x) is true, then P(c) is
true, where c is a constant in the domain of x.
Example: "x eats(x, IceCream).
Using the substitution (x/Helen) we can infer eats(Helen,
Icecream).
–The variable symbol can be replaced by any constant symbol
or function symbol.
• 01/08/2025
• 69
Continued…
• Existential Introduction: If P(c) is true, then $x P(x)
is inferred.
Example: eats(John, IceCream) we can infer $x eats(x,
icecream).
• Existential Elimination: From $x P(x) infer P(c).
Example: $x eats(Sol, x) infer eats(Sol, Pizza)
• 01/08/2025
• 70
Proof and inference
•We can define inference rules allowing us to say that if certain things
are true, certain other things are sure to be true,
E.g. All men are mortal
Aristotle is a man
using logical inferences we can deduce that:
Aristotle is mortal
x man(x) mortal(x) man(Aristotle)
so we can conclude that mortal(Aristotle)
–This involves matching man(x) against man(Aristotle) and binding
the variable x to Aristotle.
Example 1: What can we conclude from the following?
x tall(x)  strong(x)
tall(john)
" x strong(x)  loves(merry, x)
Example 2: Every metal is dissolved by sulphuric acid
copper is a metal
can we conclude: Copper is dissolved by sulphuric acid
• 01/08/2025
• 71
Proofs
•Sound inference: find α such that KB |= α
•Proof process is a search, operators are inference rules
–It requires the operation of a series of inference rule to come
up with some conclusion
Example:
Bob is a buffalo. Pat is a pig. Buffaloes faster than pigs
Conclude: Bob faster Pat
1. Buffalo(Bob)
2. Pig(Pat)
3. x,y Buffalo(x) ^ Pig(y) → Faster(x,y)
4. Buffalo(Bob) ^ Pig(Pat) And Introduction (1, 2)
5. Buffalo(Bob) ^ Pig(Pat) → Faster(Bob, Pat)
Universal Elimination (3, {x/Bob,y/Pat})
6. Faster(Bob,Pat) Modus Ponens (6, 7)
• 01/08/2025
• 72
Resolution Proof
Practice exercise
• Jack owns a dog. Every dog owner is an animal lover.
No animal lover kills an animal. Either Jack or
Curiosity killed the cat, who is named Tuna. Did
Curiosity kill the cat?
• FOL representation:
A. (x) Dog(x)  Owns(Jack,x)
B. (x) ((y) Dog(y)  Owns(x, y))  AnimalLover(x)
C. (x) AnimalLover(x)  ((y) Animal(y)  Kills(x,y))
D. Kills(Jack,Tuna)  Kills(Curiosity,Tuna)
E. Cat(Tuna)
F. (x) Cat(x)  Animal(x)
G. Kills(Curiosity, Tuna)
• 01/08/2025
• 73
Unification
• Unification is an algorithm for determining the substitutions needed to make
two expressions match
• A substitution α unfies atomic sentences p and q if pα = qα
p q α
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,Jane)
Knows(y, Abe)
Knows(y,Mother(y))
Knows(John,x) Knows(x,Abe)
Idea: Unify rule:
• Premises with known facts apply unifier to conclusion
Example. if we know q and Knows(John,x) → Likes(John,x)
then we conclude Likes(John,Jane)
Likes(John,Abe)
Likes(John,Mother(John))
{x/Jane}
{y/John, x/Abe}
{y/John, x/Mother(John)}
Fail
• 01/08/2025

chapter AI 4 Kowledge Based Agent.pptx

  • 1.
    Artificial Intelligence Prepared by: AtakltiNguse Chapter Four: knowledge-based Agents 01/08/2025 1
  • 2.
    2 4.1. Knowledge-based agent 01/08/2025 •Anintelligent agent needs knowledge about the real world for taking decisions and reasoning to act efficiently. • Knowledge-based agents are those agents who have the capability of –maintaining an internal state of knowledge, –reason over that knowledge, –update their knowledge after observations and take actions. •These agents can represent the world with some formal representation and act intelligently.
  • 3.
    3 Continued… • A knowledge-basedagent is an agent that consists of two parts: • a knowledge base and an inference engine • The central component of a knowledge-based agent is its knowledge base, or KB. • A knowledge base is a set of sentences. • Each sentence is expressed in a language called a knowledge representation language and represents some assertion about the world. • The inference engine is consists of algorithms that take the contents of the knowledge base and infer (i.e. deduce) new knowledge about the world. 01/08/2025
  • 4.
    4 Knowledge Base (KB) •Contains set of facts about the domain expressed in a suitable representation language –Each individual representation are called sentences –Sentences are expressed in a (formal) knowledge representation (KR) language • A KBA is designed such that there is a way to:- –TELL it (i.e. to add new sentences to the KB) and ASK it (i.e. to query the KBA) –TELLs the knowledge base what it perceives. –When one ASKs a question, the answer should follow from what has been TELLed to the KB previously. –ASKs the knowledge base what action to perform. –Inference mechanism determines what follows from what has been TELLed to the KB 01/08/2025
  • 5.
    5 Figure 1 –The structure of a knowledge- based agent 01/08/2025
  • 6.
    6 Cont… • The agentreceives precepts from the environment they will be converted into sentences and added to the KB • Inference engine generates new knowledge it is also added to the KB • When the agent needs to make an action, we must ask the KB what the optimal action will be at that time • There must be some way of telling the KB a new piece of information; • and there must be some way of asking the KB some question about the environment 01/08/2025
  • 7.
    7 Schematic perspective KBR •If KB is true in the real world, then any sentence  derived from KB by a sound inference procedure is also true in the real world. • chuchu is sick with the corona virus chuchu is sick ⊨ 01/08/2025
  • 8.
  • 9.
    9 Continued… • Knowledge canalso be represented by the symbols of logic, which is the study of the rules of exact reasoning. • Logic is also of primary importance in expert systems in which the inference engine reasons from facts to conclusions. • A descriptive term for logic programming and expert systems is automated reasoning systems. 01/08/2025
  • 10.
    10 4.2. Logic asKR •A Logic is a formal language in which knowledge can be represented such that conclusions can be drawn. –It is a declarative language to assert sentences and deduce from sentences. •Components of a formal logic •Syntax: what expressions/structures are allowed in the language. Describes how to make sentences E.g. red(mycar) is ok, but mycar(grey or green) is not. –Semantics: express what sentences mean, in terms of a mapping to real world. •Semantics relate sentences to reality. •E.g. red(mycar) means that my car is red. –Proof Theory: how we can draw new conclusions from existing statements in the logic. –It is a means of carrying our reasoning using a set of rules. –Reasoning: is the process of constructing new sentences from existing facts in the KB. 01/08/2025
  • 11.
    11 Continued… • Logic acceptedrules for making precise statements. • Logic essential for computer science: programming, artificial intelligence, logic circuits... • Logic – Represents knowledge precisely – Helps to extract information (inference) 01/08/2025
  • 12.
    12 Logical Arguments • Anargument is a sequence of statements. • The last statement is called the conclusion, all the previous statements are premises (or assumptions/ hypotheses). • A valid argument is an argument where the conclusion is true if the premises are true. 01/08/2025
  • 13.
    13 Continued… • In mathematicsthere are different kinds of logics. Some of these according to order of their generality are:- • Logical representation can be categorized into mainly two logics: – Propositional logic – First order logic 01/08/2025
  • 14.
    14 4.2.1.Propositional (Boolean) logic(PL) • 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 but not both at any time. • It is a technique of knowledge representation in logical and mathematical form. • Proposition can be conditional or unconditional Examples – It is Sunday. – The Sun rises from West (False proposition) – Socrates is mortal – If the winter is severe, then students will not succeed. – All are the same iff their color is black • In propositional logic, symbols represent the whole proposition. Examples: – M = Socrates is mortal – W = winter is sever – S = students will not succeed 01/08/2025
  • 15.
    15 Continued… • In propositionallogic, 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. • Propositional logic consists of an object, relations or function, and logical connectives. • These connectives are also called logical operators which connects two sentences. • The propositions and connectives are the basic elements of the propositional logic. • 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 Rohini", "How are you", "What is your name", are not propositions. 01/08/2025
  • 16.
    16 Syntax of propositionallogic: • The syntax of propositional logic defines the allowable sentences for the knowledge representation. • There are two types of Propositions: • Atomic Proposition: Atomic propositions are the simple propositions. • It consists of a single proposition symbol. These are the sentences which must be either true or false. a) 2+2 is 4, it is an atomic proposition as it is a true fact. b) "The Sun is cold" is also a proposition as it is a false fact. •Compound proposition: Compound propositions are constructed by combining . •Example a)It is raining today, and street is wet." b) “Jemal is a doctor, and his clinic is in harar." 01/08/2025
  • 17.
    17 Logical Connectives: • Logicalconnectives are used to connect two simpler propositions or representing a sentence logically. • We can create compound propositions with the help of logical connectives. • There are mainly five connectives, which are given as follows: 01/08/2025
  • 18.
  • 19.
    19 Precedence of connectives: •Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators. 01/08/2025 Precedence Operators First Precedence Parenthesis Second Precedence Negation Third Precedence Conjunction(AND) Fourth Precedence Disjunction(OR) Fifth Precedence Implication Six Precedence Bi conditional
  • 20.
    20 Propositional logic (PL):Syntax • A proposition is simply a statement that is either true or false. • The syntax of PL defines the allowable sentences • The proposition symbols S1, S2 etc are sentences • If S is a sentence, S is a sentence (negation) • If S1 and S2 are sentences, S1  S2 is a sentence (conjunction) • If S1 and S2 are sentences, S1  S2 is a sentence (disjunction) • If S1 and S2 are sentences, S1  S2 is a sentence (implication) • If S1 and S2 are sentences, S1  S2 is a sentence (biconditional) 01/08/2025
  • 21.
    21 sentences in PL Examples:Convert from English sentence to PL Let A = Lectures are active, R = Text is readable, and P = Kebede will pass the exam, then represent the following: • the lectures are not active: • the lectures are active and the text is readable: • either the lectures are active or the text is readable: • if the lectures are active, then the text is not readable: • the lectures are active if and only if the text is readable: • if the lectures are active, then if the text is not readable, Kebede will not pass the exam: A A  R A V R A   R A  R A  (R  P )
  • 22.
    22 Proofing theorem usingPropositional logic (PL) Exercise: convert P sentences to PL: •“It is humid.”: •“If it is humid, then it is hot” : •“If it is hot and humid, then it is raining”: 01/08/2025
  • 23.
    23 Semantics •Specify the interpretationof the proposition symbols & constants, and the meanings of the logical connectives –Truth Tables: define the semantics of sentences. The following table shows truth table for the five logical connectives. Note: P and Q can be any sentence, including complex sentences. P Q P PQ PQ PQ PQ True True False True True True True True False False False True False False False True True False True True False False False True False False True True 01/08/2025
  • 24.
    24 Semantics (Complex Sentences) RS R RS R S (RS)(R S) True True False True True True True False False False False True False True True False True True False False True False True True • Complex sentences such as (RS)(RS) are defined by a process of decomposition. – First determine the meaning of (RS) and of (RS). – Then combine them using the definition of the  function •Can you write the truth table for: –(P  Q)  (R  P) 01/08/2025
  • 25.
    25 Logical equivalence: • Logicalequivalence is one of the features of propositional logic. • Two propositions are said to be logically equivalent if and only if the columns in the truth table are identical to each other. 01/08/2025
  • 26.
    26 Logical equivalence •Two sentencesare logical equivalent iff they are true in same models. α Ξ β if and only if α |= β and β |= α 01/08/2025
  • 27.
    27 Continued… –Is (P Q)  R same as P  (Q  R) ? –Is (P  Q)  R same as P  (Q  R) ? –Is (P  Q)  R same as P  (Q  R) ? 01/08/2025
  • 28.
    28 Equivalent Expressions • Considerthe following three statements • Helen is not married but Biniam is not single • ¬ h ∧ ¬ b • Biniam is not single and Helen is not married • ¬ b ∧ ¬ h • Neither Biniam is single nor Helen is married • ¬ (b h) ∨ • These three statements are equivalent • ¬ h ∧ ¬ b ≡ ¬ b ∧ ¬ h ≡ ¬ (b h) ∨ 01/08/2025
  • 29.
    29 4.2.2. Inference Rulefor PL  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.  To prove validity of a sentence, there are a set of already identified patterns called inference rules.  Inference is the process of finding what sentences are entailed 01/08/2025
  • 30.
    30 Inference Rules RULE PREMISECONCLUSION Modus Ponens A, A  B B Modus Tolens B, A  B A And Elimination A  B A And Introduction A, B A  B Or Introduction A A1  A2 …  An Double Negation Elimination  A A Unit Resolution A  B, B A Resolution A  B, B  C A  C Hypothetical Syllogism PQ, QR PR • In the case of modus ponens, if A is true and A  B is true, then conclude B is true. 01/08/2025
  • 31.
  • 32.
    32 Soundness vs Completeness •Soundness: If KB Q then KB Q ⊢ ⊨ –If Q is derived from a set of sentences KB using a given set of rules of inference, then Q is entailed by KB.  A rule is sound if its conclusion is true whenever the premise is true –Hence, inference produces only real entailments, or any sentence that follows deductively from the premises is valid. • Completeness: If KB Q then KB Q ⊨ ⊢ –If Q is entailed by a set of sentences KB, then Q can be derived from KB using the rules of inference. • Soundness means that you cannot prove anything that's wrong. • Completeness means that you can prove anything that's right. 01/08/2025
  • 33.
  • 34.
    34 Terminology •Valid sentence: Asentence is valid sentence or tautology if and only if it is True under all possible interpretations in all possible worlds. Example: “It’s raining or it’s not raining.” (R  R). •Satisfiable: A sentence is satisfiable if and only if there is some interpretations in some world for which the sentence is True. Example: “It is raining or it is humid”. R v Q, R •Unsatisfiable: A sentence is unsatisfiable (inconsistent sentence or self- contradiction) if and only if it is not satisfiable, i.e. a sentence that is False under all interpretations. The world is never like what it describes. Example: “It’s raining and it's not raining.” R  R 01/08/2025
  • 35.
    35 Formal Proofs •A proofis a sequence of sentences, where each sentence is either a premise or a sentence derived from earlier sentences in the proof by one of the rules of inference. •The last sentence is the theorem (also called goal or query) that we want to prove. Example: The “weather problem”. Proof whether it is raining or not. 1. Q Premise “It is humid” 2. Q  P Premise “If it is humid, it is hot” 3. (PQ)  R Premise “If it’s hot & humid, it’s raining” 4. P Modus Ponens(1,2) “It is hot” 5. PQ And Introduction(1,4) “It is hot and humid” 6. R Modus Ponens(3,5) “It is raining” 01/08/2025
  • 36.
    36 Example 2  Constructformal proof of validity for the following problem:  If the investigation continues, then new evidence is brought to light.  If new evidence is brought to light, then several leading citizens are implicated.  If several leading citizens are implicated, then the newspapers stop publicizing the case.  If continuation of the investigation implies that the newspapers stop publicizing the case, then the bringing to light of new evidence implies that the investigation continues.  The investigation does not continue. Therefore, new evidence is not brought to light.  Represent using PL and proof the conclusion that “new evidence is not brought to light”. 01/08/2025
  • 37.
    37 Solution Let C: The investigationcontinues. B: New evidence is brought to light. I: Several leading citizens are implicated. S: The newspapers stop publicizing the case. 1. C  B 2. B  I 3. I  S 4. (C  S)  (B  C) 5. C 6. C  I 1,2 (Hypothetical Syllogism) 7. C  S 6,3 (Hypothetical Syllogism) 8. B C 7,4 (Modus Ponens) 9. B 8,5 (Modus Tollens)
  • 38.
    38 Continued…  During amurder investigation, you have gathered the following clues: 1. if the knife is in the store room, then we saw it when we cleared the store room; 2. the murder was committed at the basement or inside the apartment; 3. if the murder was committed at the basement, then the knife is in the yellow dust bin; 4. we did not see a knife when we cleared the store room; 5. if the murder was committed outside the building, then we are unable to find the knife; 6. if the murder was committed inside the apartment, then the knife is in the store room. The question is: where is the knife?" 01/08/2025
  • 39.
    39 Continued… • First, weassigned symbols to the above clues: • s : the knife is in the store room; • c : we saw the knife when we clear the store room; • b : the murder was committed at the basement; • a : murder was committed inside the apartment; • y : the knife is in the yellow dust bin; • o : the murder was committed outside the building; • u : we are unable to find the knife; 01/08/2025
  • 40.
  • 41.
    41 Example 3  Demeis either intelligent or a good actor.  If Deme is intelligent, then he can count from 1 to 10.  Deme can only count from 1 to 2.  Therefore Deme is a good actor.  Represent using PL and proof the conclusion that Deme is a good actor or not. Let: I: Deme is intelligent A: Deme is a good actor. C: Deme can count from 1 to 10. 01/08/2025
  • 42.
    42 What rule isused for the conclusion? 1. If world population continues to grow, then cities will become hopelessly crowed; If cities become hopelessly overcrowded, then pollution will become intolerable. Therefore, if world population continues to grow then pollution will become intolerable. 2. Either Yohanes or Thomas was in Ethiopia; Yohanes was not in Ethiopia. Therefore, Thomas was in Ethiopia. 01/08/2025
  • 43.
    43 Continued 3.If twelve millionchildren die yearly form starvation, then something is wrong with food distribution; Twelve million children die yearly form starvation. Therefore, something is wrong with food distribution. 4.If Japan cares about endangered species, then it has stopped killing whales; Japan has not stopped killing whales. Therefore, Japan does not care about endangered species. 01/08/2025
  • 44.
    44 Which rule ofinference is used in each argument below? • Alice is a Math major. Therefore, Alice is either a Math major or a CSI major. • Jerry is a Math major and a CSI major. Therefore, Jerry is a Math major. • If it is rainy, then the pool will be closed. It is rainy. Therefore, the pool is closed. • If it snows today, the university will close. The university is not closed today. Therefore, it did not snow today. • If I go swimming, then I will stay in the sun too long. If I stay in the sun too long, then I will sunburn. Therefore, if I go swimming, then I will sunburn. • l go swimming or eat an ice cream. I did not go swimming. • Therefore, I eat an ice cream. 01/08/2025
  • 45.
    45 Formal proof example •Show that the hypotheses: • It is not sunny this afternoon and it is colder than yesterday. • We will go swimming only if it is sunny. • If we do not go swimming, then we will take a canoe trip. • If we take a canoe trip, then we will be home by sunset. • lead to the conclusion: • We will be home by the sunset. • Main steps: 1Translate the statements into propositional logic. 2 Write a formal proof, a sequence of steps that state hypotheses or apply inference rules to previous steps. 01/08/2025
  • 46.
    46 Valid Arguments • Example1: From the this proposition • P^(p->q) • Show that q is a conclusion. • Show that : ¬ q→ ¬ p ≡ p→ q • Show that p q → r ≡ (p → r) (q → r) ∨ ∧ • (f ^ a ->r); • f ; • -a; • Therefor:- -r; 01/08/2025
  • 47.
    47 Forms of Logicalexpression • There are different standard forms of expressing PL statement. Some of these are: 1. Clausal normal form: it is a set of one or more literals connected with the disjunction operator (disjunction of literals). Example ~P  Q  ~R is a clausal form 2. Conjunctive normal forms (CNF): conjunction of disjunction of literals or conjunction of clauses. Example (A  B)  (C D) 3. Disjunctive normal form (DNF): disjunction of conjunction of literals. Example (A  B) (C  D) 4. Horn form: conjunction of literals implies a literal. Example (A  B  C D)=>E 01/08/2025
  • 48.
    48 Cont. • Normal formscan be obtained by applying equivalence laws [(A v B) => (C v D)] => P ~[~(A v B) v (C v D)] v P [~~(A v B) ^ ~(C v D)] v P [(A v B)^(~C ^ ~D)] v P (A v B v P)^(~C^~D v P) (A v B v P)^(~C v P)^(~D v P) a CNF 01/08/2025
  • 49.
    49 Practical Example (TheWumpus world • Goal: Agent wants to move to the square which holds Gold, grab it and come back to the original square and release it there • Initially agent could be at any of the square 01/08/2025
  • 50.
    50 Wumpus World PEASdescription • Performance measure – gold +1000, death -1000 – -1 per step, -10 for using the arrow • Environment – Squares adjacent to wumpus are smelly – Squares adjacent to pit are breezy – Glitter iff gold is in the same square – Shooting kills wumpus if you are facing it – Shooting uses up the only arrow – Grabbing picks up gold if in same square – Releasing drops the gold in same square • Sensors: Stench, Breeze, Glitter, Bump, Scream • Actuators: Left turn, Right turn, Forward, Grab(obtain), Release, Shoot • YOUR MISSION Prove that the Wumpus is in (1,3) and • there is a pit in (3,1), given the observations shown and these rules:
  • 51.
    51 Continued… In the squarecontaining the wumpus and in the directly (not diagonally) adjacent squares, the agent will perceive a Stench. – In the squares directly adjacent to a pit, the agent will perceive a Breeze. – In the square where the gold is, the agent will perceive a Glitter. – When an agent walks into a wall, it will perceive a Bump. – When the wumpus is killed, it emits a woeful Scream that can be perceived anywhere in the cave 01/08/2025
  • 52.
    52 Limitations of Propositionallogic: • 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. 01/08/2025
  • 53.
    • 53 4.3. FirstOrder Logic (FOL) • 01/08/2025
  • 54.
    • 54 First OrderLogic (FOL) • First-order logic is another way of knowledge representation in artificial intelligence sometime is called Predicate 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: • 01/08/2025
  • 55.
    • 55 Syntax ofFirst-Order logic: • As a natural language, first-order logic also has two main parts: – Syntax – Semantics • 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. • write statements in short-hand notation in FOL. • 01/08/2025
  • 56.
    • 56 Atomic sentences: •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: Abebe and Dereje are brothers: Brothers(Abebe, Dereje). Chinky is a cat: cat (Chinky). • Complex Sentences: • Complex sentences are made by combining atomic sentences using connectives. • Abebe like both Mathematics and Science. • 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. • Consider the statement: "x is an integer." • 01/08/2025
  • 57.
    • 57 Quantifiers inFirst-order logic: • 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: – Universal Quantifier, (for all, everyone, everything) – Existential quantifier, (for some, at least one). • All men drink coffee. – ∀x men(x) → drink (x, coffee). • It will be read as: There are all x where x is a men who drink coffee. • Some boys are intelligent. – ∃x: boys(x) intelligent(x) ∧ • It will be read as: There are some x where x is a boy who is intelligent. • The main connective for universal quantifier ∀ is implication →. • The main connective for existential quantifier ∃ is and ∧. • 01/08/2025
  • 58.
    • 58 Universal Quantification •Universal Quantifiers: makes statements about every object <variables> <sentence> –Everyone at AAU is smart: x At(x,AAU)  Smart(x) –All cats are mammals: x cat(x)  mammal(x) • x sentence P is true iff P is true with x being each possible object in the given universe –The above statement is equivalent to the conjunction At(Jone, AAU)  Smart(Jone)  At(Jemal, AAU)  Smart(Jemal)  …. Typically,  is the main connective with  –Common mistake: the use of  as the main connective with : • 01/08/2025
  • 59.
    • 59 Existential Quantification •Makesstatements about some objects in the universe <variables> <sentence> –Someone at AAU is smart: x At(x,AAU)  Smart(x) –Spot has a sister who is a cat: x sister(spot,x)  cat(x) •x sentence P is true iff P is true with x being some possible objects –The above statement is equivalent to the disjunction At(Jone, AAU)  Smart(Jone)  At(Alemu, AAU)  Smart(Alemu)  …. •Common mistake to avoid –Typically,  is the main connective with  –Common mistake: using  as the main connective with : • 01/08/2025
  • 60.
    • 60 Nested Quantifiers •x,yparent(x,y)  child(y,x) –for all x and y, if x is the parent of y then y is the child of x. •x y Loves(x,y) –There is a person who loves everyone in the given world •y x Loves(x,y) –Everyone in the given universe is loved by at least one person 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 •Quantifier duality: each can be expressed using the other, using negation () x Likes(x,icecream) x Likes(x,icecream) –Everyone likes ice cream means that there is nobody who dislikes ice cream  Likes(x,cake)  Likes(x,cake) • 01/08/2025
  • 61.
  • 62.
    • 62 Examples • FOLis a more powerful form of logic –Almost any English sentence may be represented in first- order predicate calculus Example: (1) John’s mother is married to John’s father married(father(john), mother(john)) (2) Potato is good and Potato is a kind of food good(Potato) Ù is(Potato, food) good(Potato) Ù food(Potato) (3) All food are edible "X food( X) ® edible( X) • FOL Contains predicates, quantifiers and variables • E.g. Philosopher(a) -> Scholar(a)
  • 63.
    • 63 Sentences Represent thefollowing using variables & quantifiers: • Everything in the garden is lovely  •Everyone likes ice cream  •Peter has some friends  •John plays the piano or the violin •Some people like snakes -- •Jones did not write thesis – •Nobody wrote thesis – x in(x, garden)  lovely(x) x likes(x, icecream) y friends(Peter,y) plays(john, piano) v plays(john, violin) x(person(x) Λ likes(x, snakes)) write( Jones, thesis) x write(x, thesis) • 01/08/2025
  • 64.
    • 64 Some Examplesof FOL using quantifier: 1. All birds fly. 2. Every man respects his parent. 3. Some boys play cricket. 4. Not all students like both Mathematics and Science. • 01/08/2025
  • 65.
    • 65 Semantics •There isa precise meaning to expressions in predicate logic. •Like in propositional logic, it is all about determining whether something is true or false. •x P(x) means that P(x) must be true for every object x in the domain of interest. •x P(x) means that P(x) must be true for at least one object x in the domain of interest. – So if we have a domain of interest consisting of just two people, john and merry, and we know that tall(merry) and tall(john) are true, we can say that x tall(x) is true. • 01/08/2025
  • 66.
    • 66 Inference inFirst-Order Logic • Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences. • FOL inference rules for quantifier: • As propositional logic we also have inference rules in first-order logic, so following are some basic inference rules in FOL: – Universal Generalization – Universal Instantiation – Existential Instantiation – Existential introduction • 01/08/2025
  • 67.
    • 67 Sound InferenceRules •Rules for PL apply to FOL as well. –For example, Modus Ponens, And-Introduction, And-Elimination, etc. •New (sound) inference rules for use with quantifiers: –By substituting particular individuals for the variable. E.g. substitute (x/sam, y/cake). Then likes(x,y) = likes(sam,cake) • Universal Generalization: • Universal generalization is a valid inference rule which states that if premise P(c) is true for any arbitrary element c in the universe of discourse, then we can have a conclusion as x P(x). ∀ • Example: Let's represent, P(c): "A byte contains 8 bits", so for x P(x) ∀ "All bytes contain 8 bits.", it will also be true. • 01/08/2025
  • 68.
    • 68 Continued… •Universal Elimination:If "x P(x) is true, then P(c) is true, where c is a constant in the domain of x. Example: "x eats(x, IceCream). Using the substitution (x/Helen) we can infer eats(Helen, Icecream). –The variable symbol can be replaced by any constant symbol or function symbol. • 01/08/2025
  • 69.
    • 69 Continued… • ExistentialIntroduction: If P(c) is true, then $x P(x) is inferred. Example: eats(John, IceCream) we can infer $x eats(x, icecream). • Existential Elimination: From $x P(x) infer P(c). Example: $x eats(Sol, x) infer eats(Sol, Pizza) • 01/08/2025
  • 70.
    • 70 Proof andinference •We can define inference rules allowing us to say that if certain things are true, certain other things are sure to be true, E.g. All men are mortal Aristotle is a man using logical inferences we can deduce that: Aristotle is mortal x man(x) mortal(x) man(Aristotle) so we can conclude that mortal(Aristotle) –This involves matching man(x) against man(Aristotle) and binding the variable x to Aristotle. Example 1: What can we conclude from the following? x tall(x)  strong(x) tall(john) " x strong(x)  loves(merry, x) Example 2: Every metal is dissolved by sulphuric acid copper is a metal can we conclude: Copper is dissolved by sulphuric acid • 01/08/2025
  • 71.
    • 71 Proofs •Sound inference:find α such that KB |= α •Proof process is a search, operators are inference rules –It requires the operation of a series of inference rule to come up with some conclusion Example: Bob is a buffalo. Pat is a pig. Buffaloes faster than pigs Conclude: Bob faster Pat 1. Buffalo(Bob) 2. Pig(Pat) 3. x,y Buffalo(x) ^ Pig(y) → Faster(x,y) 4. Buffalo(Bob) ^ Pig(Pat) And Introduction (1, 2) 5. Buffalo(Bob) ^ Pig(Pat) → Faster(Bob, Pat) Universal Elimination (3, {x/Bob,y/Pat}) 6. Faster(Bob,Pat) Modus Ponens (6, 7) • 01/08/2025
  • 72.
    • 72 Resolution Proof Practiceexercise • Jack owns a dog. Every dog owner is an animal lover. No animal lover kills an animal. Either Jack or Curiosity killed the cat, who is named Tuna. Did Curiosity kill the cat? • FOL representation: A. (x) Dog(x)  Owns(Jack,x) B. (x) ((y) Dog(y)  Owns(x, y))  AnimalLover(x) C. (x) AnimalLover(x)  ((y) Animal(y)  Kills(x,y)) D. Kills(Jack,Tuna)  Kills(Curiosity,Tuna) E. Cat(Tuna) F. (x) Cat(x)  Animal(x) G. Kills(Curiosity, Tuna) • 01/08/2025
  • 73.
    • 73 Unification • Unificationis an algorithm for determining the substitutions needed to make two expressions match • A substitution α unfies atomic sentences p and q if pα = qα p q α Knows(John,x) Knows(John,x) Knows(John,x) Knows(John,Jane) Knows(y, Abe) Knows(y,Mother(y)) Knows(John,x) Knows(x,Abe) Idea: Unify rule: • Premises with known facts apply unifier to conclusion Example. if we know q and Knows(John,x) → Likes(John,x) then we conclude Likes(John,Jane) Likes(John,Abe) Likes(John,Mother(John)) {x/Jane} {y/John, x/Abe} {y/John, x/Mother(John)} Fail • 01/08/2025