Sie sind auf Seite 1von 78

Sri Krishna Arts and Science

Computer Technology

19CTP14- Artificial Intelligence

Class: II M.Sc IT/CT

Classroom Code: 63srbvk

Course Coordinator
Dr. V. S. Anita Sofia
Prof. & Head
SKASC 1
Knowledge based Agent

References
1. https://www.youtube.com/watch?v=KVIshSocUzo
2. https://www.youtube.com/watch?v=40WIjcAsfTQ

SKASC 2
Agenda
• Knowledge based Agent

• Architecture of Knowledge based Agent

• Why use knowledge base

• Knowledge Representation
Knowledge based Agent
• 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.
Knowledge based Agent

• Knowledge-based agents are composed of two


main parts:
• Knowledge-base and
• Inference system.
Knowledge based Agent
• A knowledge-based agent must able to do the following:
• An agent should be able to represent states, actions, etc.
• An agent Should be able to incorporate new percepts
• An agent can update the internal representation of the world
• An agent can deduce the internal representation of the world
• An agent can deduce appropriate actions.
The architecture of knowledge-based
agent
Knowledge based Agent
• The knowledge-based agent (KBA) take input from the environment by
perceiving the environment.

• The input is taken by the inference engine of the agent and which also
communicate with KB to decide as per the knowledge store in KB.

• The learning element of KBA regularly updates the KB by learning new


knowledge.
Knowledge base
• Knowledge-base is a central component of a knowledge-based agent, it is
also known as KB.

• It is a collection of sentences (here 'sentence' is a technical term and it is


not identical to sentence in English).

• These sentences are expressed in a language which is called a


knowledge representation language.

• The Knowledge-base of KBA stores fact about the world.


Why use a knowledge base?

• Knowledge-base is required for updating


knowledge for an agent to learn with
experiences and take action as per the
knowledge.
Inference system
• Inference means deriving new sentences from old.

• Inference system allows us to add a new sentence to the knowledge base.

• A sentence is a proposition about the world.

• Inference system applies logical rules to the KB to deduce new information.

• Inference system generates new facts so that an agent can update the KB.

• An inference system works mainly in two rules which are given as:
• Forward chaining
• Backward chaining
Operations Performed by KBA
• Following are three operations which are performed by KBA in
order to show the intelligent behavior:

• TELL: This operation tells the knowledge base what it perceives from


the environment.

• ASK: This operation asks the knowledge base what action it should


perform.

• Perform: It performs the selected action


A generic knowledge-based agent
function KB-AGENT(percept):   • The knowledge-based agent takes percept
persistent: KB, a knowledge base    as input and returns an action as output.
          t, a counter, initially 0, indicati
ng time    • The agent maintains the knowledge base,
TELL(KB, MAKE-PERCEPT- KB, and it initially has some background
SENTENCE(percept, t))    knowledge of the real world.
Action = ASK(KB, MAKE-ACTION-
• It also has a counter to indicate the time for
QUERY(t))   
TELL(KB, MAKE-ACTION- the whole process, and this counter is
SENTENCE(action, t))   initialized with zero
 t = t + 1  
 return action   
A generic knowledge-based agent
• Each time when the function is called, it performs its three operations:
• Firstly it TELLs the KB what it perceives.
• Secondly, it asks KB what action it should take
• Third agent program TELLS the KB that which action was chosen.

• The MAKE-PERCEPT-SENTENCE generates a sentence as setting that the agent perceived the given
percept at the given time.

• The MAKE-ACTION-QUERY generates a sentence to ask which action should be done at the current
time.
• MAKE-ACTION-SENTENCE generates a sentence which asserts that the chosen action was executed.
Various levels of knowledge-based
agent
• A knowledge-based agent can be viewed at different levels which are given below:

1. Knowledge level

• Knowledge level is the first level of knowledge-based agent, and in this level, we
need to specify what the agent knows, and what the agent goals are.

• With these specifications, we can fix its behavior.

• For example, suppose an automated taxi agent needs to go from a station A to


station B, and he knows the way from A to B, so this comes at the knowledge level.
Various levels of knowledge-based
agent
2. Logical level:

• How the knowledge representation of knowledge is stored.

• Sentences are encoded into different logics.

• An encoding of knowledge into logical sentences occurs.

• At the logical level we can expect to the automated taxi agent to


reach to the destination B.
Various levels of knowledge-based
agent
3. Implementation level:

• This is the physical representation of logic and knowledge.

• At the implementation level agent perform actions as per logical


and knowledge level.

• At this level, an automated taxi agent actually implement his


knowledge and logic so that he can reach to the destination.
Approaches to designing a
knowledge-based agent
• There are mainly two approaches to build a knowledge-based agent:

• 1. Declarative approach: 
• create a knowledge-based agent by initializing with an empty knowledge base and telling the agent
all the sentences with which we want to start with. This approach is called Declarative approach.

• 2. Procedural approach: 
• In the procedural approach, we directly encode desired behavior as a program code. Which means
we just need to write a program that already encodes the desired behavior or agent.

• However, in the real world, a successful agent can be built by combining both declarative and
procedural approaches, and declarative knowledge can often be compiled into more efficient
procedural code.
What is knowledge representation?

• Humans are best at understanding, reasoning, and


interpreting knowledge.

• Human knows things, which is knowledge and as per their


knowledge they perform various actions in the real world. 

• But how machines do all these things comes under


knowledge representation and reasoning.
What is knowledge representation?
• Knowledge representation can be described as following:
• Knowledge representation and reasoning (KR, KRR) is the part of Artificial
intelligence which concerned with AI agents thinking and how thinking
contributes to intelligent behavior of agents.
• It is responsible for representing information about the real world so that a
computer can understand and can utilize this knowledge to solve the complex
real world problems such as diagnosis a medical condition or communicating
with humans in natural language.
What is knowledge representation?

• It is also a way which describes how we can represent


knowledge in artificial intelligence.

• Knowledge representation is not just storing data into some


database, but it also enables an intelligent machine to learn
from that knowledge and experiences so that it can behave
intelligently like a human.
What to Represent:
• Following are the kind of knowledge which needs to be represented in AI systems:

• Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.

• Events: Events are the actions which occur in our world.

• Performance: It describe behavior which involves knowledge about how to do things.

• Meta-knowledge: It is knowledge about what we know.

• Facts: Facts are the truths about the real world and what we represent.

• Knowledge-Base: The central component of the knowledge-based agents is the


knowledge base. It is represented as KB. The Knowledgebase is a group of the Sentences
(Here, sentences are used as a technical term and not identical with the English language).
Knowledge

• Knowledge is awareness or familiarity gained


by experiences of facts, data, and situations.
Types of knowledge
Types of knowledge

1. Declarative Knowledge:

• Declarative knowledge is to know about something.

• It includes concepts, facts, and objects.

• It is also called descriptive knowledge and expressed in


declarative sentences.

• It is simpler than procedural language.


Types of knowledge
2. Procedural Knowledge

• It is also known as imperative knowledge.

• Procedural knowledge is a type of knowledge which is responsible for


knowing how to do something.

• It can be directly applied to any task.

• It includes rules, strategies, procedures, agendas, etc.

• Procedural knowledge depends on the task on which it can be applied.


Types of knowledge
3. Meta-knowledge:

• Knowledge about the other types of knowledge is called Meta-knowledge.

4. Heuristic knowledge:

• Heuristic knowledge is representing knowledge of some experts in a filed or


subject.

• Heuristic knowledge is rules of thumb based on previous experiences,


awareness of approaches, and which are good to work but not guaranteed.
Types of knowledge

5. Structural knowledge:

• Structural knowledge is basic knowledge to problem-solving.

• It describes relationships between various concepts such as


kind of, part of, and grouping of something.

• It describes the relationship that exists between concepts or


objects.
The relation between knowledge and
intelligence
• Knowledge of real-worlds plays a vital role in
intelligence and same for creating artificial
intelligence.

• Knowledge plays an important role in demonstrating


intelligent behavior in AI agents.

• An agent is only able to accurately act on some input


when he has some knowledge or experience about
that input.

• There is one decision maker which act by sensing the


environment and using knowledge.

• But if the knowledge part will not present then, it


cannot display intelligent behavior.
AI knowledge cycle
• An Artificial intelligence system has the
following components for displaying
intelligent behavior:
• Perception
• Learning
• Knowledge Representation and
Reasoning
• Planning
• Execution
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.
Propositional Logic

• Example:

• a) It is Sunday.  

• b) The Sun rises from West (False proposition)  

• c) 3+3= 7(False proposition)  

• d) 5 is a prime number.   
Basic facts about propositional logic
• Propositional logic is also called Boolean logic as it works on 0 and 1.

• In propositional logic, we use symbolic variables to represent the logic, and


we can use any symbol for a representing a proposition, such A, B, C, P, Q,
R, etc.

• Propositions can be either true or false, but it cannot be both.

• Propositional logic consists of an object, relations or function, and logical


connectives.

• These connectives are also called logical operators.


Basic facts about propositional logic
• The propositions and connectives are the basic elements of the
propositional logic.

• Connectives can be said as a logical operator which connects two


sentences.

• A proposition formula which is always true is called tautology, and it is also


called a valid sentence.

• A proposition formula which is always false is called Contradiction.


Basic facts about propositional logic
• A proposition formula which has both true and false values is called

• 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.
Syntax of propositional logic
• The syntax of propositional logic defines the allowable sentences for the
knowledge representation.

• There are two types of Propositions:


• Atomic Propositions
• Compound 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.
Atomic Proposition

• Example:

• 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 simpler or atomic propositions, using
parenthesis and logical connectives.
Compound proposition

• Example:

• a) "It is raining today, and street is wet."  

• b) "Ankit is a doctor, and his clinic is in Mumbai."  
 
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


Logical Connectives
• Negation: 
• A sentence such as ¬ P is called negation of P. A literal can be either
Positive literal or negative literal.

• Conjunction: 
• A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
Logical Connectives
• Disjunction: 
• A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P
and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.

• Implication: 
• A sentence such as P → Q, is called an implication. Implications are also known as
if-then rules. It can be represented as
            If it is raining, then the street is wet.
        Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
Logical Connectives
• Biconditional: 
• A sentence such as P⇔ Q is a Biconditional
sentence, example If I am breathing, then I
am alive
            P= I am breathing, Q= I am alive, it can
be represented as P ⇔ Q.
Propositional Logic Connectives
Truth Table

• In propositional logic, we need to know the truth


values of propositions in all possible scenarios.

• We can combine all the possible combination with


logical connectives, and the representation of these
combinations in a tabular format is called Truth table.
Truth Table
Truth Table
Truth table with three propositions
Precedence of connectives
Precedence Operators

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Six Precedence Biconditional


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.
Logical equivalence
Properties of Operators
• Commutativity:
• P∧ Q= Q ∧ P, or
• P ∨ Q = Q ∨ P.

• Associativity:
• (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R)

• Identity element:
• P ∧ True = P,
• P ∨ True= True.
Properties of Operators
• Distributive:
• P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).

• DE Morgan's Law:
• ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
• ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).

• Double-negation elimination:
• ¬ (¬P) = P.
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.
Rules of Inference

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

• Inference rules:
• Inference rules are the templates for generating valid
arguments.
• Inference rules are applied to derive proofs in artificial
intelligence, and the proof is a sequence of the conclusion
that leads to the desired goal.
Rules of Inference
• some terminologies related to inference rules
• Implication: It is one of the logical connectives which can be represented as P
→ Q. It is a Boolean expression.
• Converse: The converse of implication, which means the right-hand side
proposition goes to the left-hand side and vice-versa. It can be written as Q →
P.
• Contrapositive: The negation of converse is termed as contrapositive, and it
can be represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be represented as
¬ P → ¬ Q.
Rules of Inference

• Hence from the above truth table, we can prove that P → Q is equivalent to
¬ Q → ¬ P, and Q→ P is equivalent to ¬ P → ¬ Q.
Types of Inference rules - Modus
Ponens
• 1. Modus Ponens:

• The Modus Ponens rule is one of the most important rules of


inference, and it states that if P and P → Q is true, then we
can infer that Q will be true.

• It can be represented as:


Types of Inference rules - Modus
Ponens
• Example:

• Statement-1: "If I am sleepy then I go to bed" ==> P→ Q


Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q
will be true.
Types of Inference rules - Modus
Ponens
Types of Inference rules - Modus
Tollens
• 2. Modus Tollens:

• The Modus Tollens rule state that if P→ Q is true and ¬ Q is


true, then ¬ P will also true.

• It can be represented as:


Types of Inference rules - Modus
Tollens

• Statement-1: "If I am sleepy then I go to bed"


==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not
sleepy" => ~P
Types of Inference rules - Modus
Tollens
Types of Inference rules - Hypothetical syllogism

• 3. Hypothetical Syllogism

• The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is
true, and Q→R is true.

• Example:

• Statement-1: If you have my home key then you can unlock my


home. P→Q
Statement-2: If you can unlock my home then you can take my
money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
Types of Inference rules - Hypothetical syllogism
Types of Inference rules - Disjunctive
Syllogism
• 4. Disjunctive Syllogism:

• The Disjunctive syllogism rule state that if P ∨Q is true, and ¬P


is true, then Q will be true.

• It can be represented as:


Types of Inference rules - Disjunctive
Syllogism
• Example:

• Statement-1: Today is Sunday or Monday.


==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
Types of Inference rules - Disjunctive
Syllogism
Types of Inference rules - Addition

• The Addition rule is one the common inference


rule, and it states that If P is true, then P∨Q will
be true.
Types of Inference rules - Addition

• Example:

• Statement: I have a vanilla ice-cream. ==> P


Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-
cream. ==> (P∨Q)
Types of Inference rules - Addition
Types of Inference rules -
Simplification

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


then Q or P will also be true.

• It can be represented as:


Types of Inference rules -
Simplification
Types of Inference rules - Resolution

• The Resolution rule state that if P∨Q and ¬


P∧R is true, then Q∨R will also be true. 

• It can be represented as
Types of Inference rules - Resolution

Das könnte Ihnen auch gefallen