Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 43

Chapter Four

Knowledge Based Agents

04/23/2024
Contents
1. Logical Agents
2. Propositional Logic
3. Inference in Propositional Logic
4. Predicate (First-order) Logic
5. Inference in first-order logic
6. Knowledge Representation
7. Knowledge based system

04/23/2024
Knowledge-based Agents
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.

04/23/2024
Cont…
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.
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.

04/23/2024
Cont…
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).

04/23/2024
Cont…
•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.

04/23/2024
The structure of a knowledge-based agent
The architecture of knowledge based agent.

04/23/2024
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

04/23/2024
Logic as KR
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.
A Logic is a formal language in which knowledge can be represented, such
that conclusions can be drawn.

04/23/2024
Cont…
Logic:- 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.

04/23/2024
Cont…
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.

04/23/2024
Cont…
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).

04/23/2024
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 istrue if the premises
are true.

04/23/2024
…Logical representation of knowledge
Logical representation can be categorized mainly into two logics:
1. Propositional logic
2. First order logic

04/23/2024
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
04/23/2024
Cont…
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.

04/23/2024
Propositional Logic / PL: Syntax
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."
04/23/2024
PL 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:

04/23/2024
Cont…
Connective Symbols Word Technical term Example

 AND Conjunction AB

 OR Disjunction AB

 Implies Implication AB

 If and only if Biconditional AB

 Not Negation A OR B

04/23/2024
PL: Precedence of Connectives
Just like arithmetic operators, there is a precedence order for propositional
connectors or logical operators.

Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction (AND)
Forth Precedence Disjunction (OR)
Fifth Precedence Implication
Six Precedence Bi conditional

04/23/2024
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).

04/23/2024
PL: 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:
1. the lectures are not active: A
2. the lectures are active and the text is readable: AR
3. either the lectures are active or the text is readable: AR
4. if the lectures are active, then the text is not readable: A  R
5. the lectures are active if and only if the text is readable: A R
6. if the lectures are active, then if the text is not readable, Kebede will not pass
the exam: A ( R   P )

04/23/2024
PL: Syntax 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”:

04/23/2024
PL: 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

04/23/2024
PL: Semantics (Complex Sentences)
 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.

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
Can you write the truth table for: (P  Q)  (R   P).
04/23/2024
PL: 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.

04/23/2024
PL: Logical Equivalence

04/23/2024
PL: Logical Equivalence
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) ?
Example

04/23/2024
PL: Logical Equivalence
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)

04/23/2024
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.

04/23/2024
Inference Rules
Rule Premise Conclusion
Modus Ponus 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A3…. An
Double Negation  A A
Elimination
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 Ponus, if A is True and AB is True, then conclude B is True.
04/23/2024
Inference Rules: Soundness and Completeness

Soundness: If KB ⊢Q then KB ⊨ Q

• If Q is derived from a set of sentences KB using a given set of rules


ofinference, 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
thatfollows deductively from the premises is valid.

04/23/2024
Inference Rules: Soundness and Completeness

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.

04/23/2024
Inference Rules: Soundness and Completeness

04/23/2024
Inference Rules: Validity
 Valid sentence: A sentence is valid sentence or tautology if and only ifit 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

04/23/2024
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. Example1: 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”

04/23/2024
Cont…
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”.
04/23/2024
Formal Proofs
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)
04/23/2024
Formal Proofs: Main steps
1. Translate the statements into propositional logic.
2. Write a formal proof, a sequence of steps that state hypotheses or apply
inference rules to previous steps.

04/23/2024
Formal Proofs: Exercise 1
 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 inthe
store room.
The question is: “where is the knife?"
04/23/2024
Cont…
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;

04/23/2024
Formal Proofs: Exercise 2
Let p stand for the proposition “I bought a lottery ticket” and q for “I won
the jackpot”.
Express the following as English sentences:
1. ¬p
2. p  q
3. p  q
4. p  q
5. ¬p  ¬q
6. ¬p  (p  q)

04/23/2024
Limitations of Propositional Logic

To be Continued…

04/23/2024

You might also like