SlideShare une entreprise Scribd logo
1  sur  126
Unit 2
Knowledge representation
• It is the part of Artificial intelligence which concerned with AI
agents thinking
• And how thinking contributes to intelligent behavior of agents.
• It is 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.
• It is responsible for representing information about the real
world
• A computer use this information and can understand and can
utilize this knowledge to solve the complex real world problems
• Example diagnosis a medical condition or communicating with
humans in natural language.
What to Represent
• 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).
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.
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.
3. Meta-knowledge
• Knowledge about the other types of knowledge is called Meta-
knowledge.
4. Heuristic knowledge
• 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.
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.
Approaches to knowledge representation
1. Simple relational knowledge:
• It is the simplest way of storing facts which uses the relational
method, and each fact about a set of the object is set out
systematically in columns.
• This approach of knowledge representation is famous in database
systems where the relationship between different entities is
represented.
• This approach has little opportunity for inference.
Player Weight Age
Player1 65 23
Player2 58 18
Player3 75 24
2. Inheritable knowledge
• In the inheritable knowledge approach, all data must be stored into a
hierarchy of classes.
• All classes should be arranged in a generalized form or a hierarchal
manner.
• In this approach, we apply inheritance property.
• Elements inherit values from other members of a class.
• This approach contains inheritable knowledge which shows a
relation between instance and class, and it is called instance
relation.
• Every individual frame can represent the collection of attributes and
its value.
• In this approach, objects and values are represented in Boxed
nodes.
• We use Arrows which point from objects to their values.
3. Inferential knowledge:
• Inferential knowledge approach represents knowledge in the
form of formal logics.
• This approach can be used to derive more facts.
• It guaranteed correctness.
• Example: Let's suppose there are two statements:
• Marcus is a man
• All men are mortal
Then it can represent as;
man(Marcus)
∀x = man (x) ----------> mortal (x)s
4. Procedural knowledge:
• Procedural knowledge approach uses small programs and
codes which describes how to do specific things, and how to
proceed.
• In this approach, one important rule is used which is If-Then
rule.
• In this knowledge, we can use various coding languages such
as LISP language and Prolog language.
• We can easily represent heuristic or domain-specific knowledge
using this approach.
• But it is not necessary that we can represent all cases in this
approach.
Requirements for knowledge Representation
system:
A good knowledge representation system must possess the following
properties.
1. Representational Accuracy:
KR system should have the ability to represent all kind of required
knowledge.
2. Inferential Adequacy:
KR system should have ability to manipulate the representational
structures to produce new knowledge corresponding to existing
structure.
3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most
productive directions by storing appropriate guides.
4. Acquisitional efficiency- The ability to acquire the new knowledge
easily using automatic methods.
Knowledge representation techniques
There are mainly four ways of knowledge representation which
are given as follows:
1.Logical Representation
2.Semantic Network Representation
3.Frame Representation
4.Production Rules
1. Logical Representation
• Logical representation is a language with some concrete rules
which deals with propositions and has no ambiguity in
representation.
• Logical representation means drawing a conclusion based on
various conditions.
• This representation lays down some important communication
rules.
• It consists of precisely defined syntax and semantics which
supports the sound inference.
• Each sentence can be translated into logics using syntax and
semantics.
Syntax:
• Syntaxes are the rules which decide how we can construct legal
sentences in the logic.
• It determines which symbol we can use in knowledge
representation.
• How to write those symbols.
Semantics:
• Semantics are the rules by which we can interpret the sentence
in the logic.
• Semantic also involves assigning a meaning to each sentence.
Logical representation can be categorised into mainly two logics:
1.Propositional Logics
2.Predicate logics
Propositional logic in Artificial intelligence
• 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.
Following are some 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.
• 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.
• 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:
1.Atomic Propositions
2.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.
Example
1. 2+2 is 4, it is an atomic proposition as it is a true fact.
2."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.
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, which are given as follows:
1.Negation: A sentence such as ¬ P is called negation of P. A
literal can be either Positive literal or negative literal.
2.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.
3. 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.
4. 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
5. 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
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.
• Following are the truth table for all logical connectives:
Truth table with three propositions
Precedence of connectives
Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
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.
• Let's take two propositions A and B, so for logical equivalence,
we can write it as A⇔B. In below truth table we can see that
column for ¬A∨ B and A→B, are identical hence A is Equivalent
to B
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.
• 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.
First Order Predicate Logic
FOPL was developed by logicians to extend the expressiveness of PL. The symbols
and rules of combination permitted in FOPL are defined as follows:
1. Connectives: There are five connectives symbols: ∨, ^ , ¬ , ⇒ and ⇔.
2. Quantifiers: Two quantifier symbols are ∀ & ∃ where ∃x means for some x and
∀x means for all x.
3. Variables: These are the terms which may have different values in a given
domain.
4. Constants: These are the fixed value terms that belongs to a given domain.
5. Function: It is used to identify a domain element. It maps n elements
to a single element. Symbols f, g, h and words such as age_of,
income_of reprent a function.
6. Predicates: They are the relation within the domain to show how an
element is related to another. Capital letters or capitalized words are
used to represent a predicate.
Properties of a statement
Satisfiable:
A statement is satisfiable if there is some interpretation for which it is true.
Contradiction:
A sentence is contradictory (unsatisfiable) if there is no interpretation for which it is
true.
Valid:
A sentence is valid if it is true for every interpretation.
Equivalence:
Two sentence are equivalent if they have same truth values under every
interpretation.
Logical Consequences:
A sentence is a logical consequence of another if it is satisfied by all interpretation
which satisfies the first.
Well-Formed Formula(WFF)
• Well-Formed Formula(WFF) is an expression consisting of
variables(capital letters), parentheses, and connective symbols.
• An expression is basically a combination of operands &
operators and here operands and operators are the connective
symbols.
Well-formed formula (WFF)
• Any expression that obeys the syntactic rules of propositional
logic is called a well-formed formula, or WFF.
• Fortunately, the syntax of propositional logic is easy to learn. It
has only three rules:
1.A Statement variable standing alone is a Well-Formed
Formula(WFF).
For example– Statements like P, ∼P, Q, ∼Q are themselves
Well Formed Formulas.
2.If ‘P’ is a WFF then ∼P is a formula as well.
3.If P & Q are WFFs, then (P∨Q), (P∧Q), (P⇒Q), (P⇔Q), etc. are
also WFFs.
Some Equivalence Laws
Negative Law: ~(~P) ≈ P
De Morgan’s Laws: ~ (P V Q) ≈ ~P & ~Q
~ (P & Q) ≈ ~P V ~Q
Distributivity: P & ( Q V R) ≈ (P & Q) V (P & R)
P V ( Q & R) ≈ (P V Q) & (P V R)
Inference Rule
• Generating the conclusions from evidence and facts is termed
as Inference.
• Inference rules are applied to derive proofs in artificial
intelligence.
• The proof is a sequence of the conclusion that leads to the
desired goal.
• In inference rules, the implication among all the connectives
plays an important role.
Following are 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.
Types of Inference rules
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:
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.
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:
Example
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
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true
whenever P→Q is true, and Q→R is true. It can be represented
as the following notation:
Example:
Statement-1: If you have my home key then you can unlock my
home. P→Q
Statement-2: If you can unlock my home then you can take my
money. Q→R
Conclusion: If you have my home key then you can take my
money. P→R
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:
Example:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
5. Addition:
The Addition rule is one the common inference rule, and it states
that If P is true, then P∨Q will be true.
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)
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will
also be true. It can be represented as:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then
Q∨R will also be true. It can be represented as
Forward Chaining and backward chaining in
AI
The inference engine is the component of the intelligent system
in artificial intelligence, which applies logical rules to the
knowledge base to infer new information from known facts.
The first inference engine was part of the expert system.
Inference engine commonly proceeds in two modes, which are:
1.Forward chaining
2.Backward chaining
Horn Clause and Definite clause:
• Horn clause and definite clause are the forms of sentences,
which enables knowledge base to use a more restricted and
efficient inference algorithm.
• Logical inference algorithms use forward and backward
chaining approaches, which require KB in the form of the first-
order definite clause.
• Definite clause: A clause which is a disjunction of literals
with exactly one positive literal is known as a definite clause
or strict horn clause.
• Horn clause: A clause which is a disjunction of literals with at
most one positive literal is known as horn clause. Hence all
the definite clauses are horn clauses.
Example: (¬ p V ¬ q V k). It has only one positive literal k.
It is equivalent to p ∧ q → k.
Forward Chaining
• Forward chaining is also known as a forward deduction or
forward reasoning method when using an inference engine.
• Forward chaining is a form of reasoning which start with atomic
sentences in the knowledge base and applies inference rules
(Modus Ponens) in the forward direction to extract more data
until a goal is reached.
• The Forward-chaining algorithm starts from known facts,
triggers all rules whose premises are satisfied, and add their
conclusion to the known facts.
• This process repeats until the problem is solved.
Properties of Forward-Chaining
• It is a down-up approach, as it moves from bottom to top.
• It is a process of making a conclusion based on known facts or
data, by starting from the initial state and reaches the goal
state.
• Forward-chaining approach is also called as data-driven as we
reach to the goal using available data.
• Forward -chaining approach is commonly used in the expert
system, such as CLIPS, business, and production rule systems.
Example
• Tom is running (A)
• If a person is running, he will sweat (A->B)
• Therefore, Tom is sweating. (B)
Example
Facts
1.If D barks and D eats bone, then D is a dog.
2.If V is cold and V is sweet, then V is ice-cream.
3.If D is a dog, then D is black.
4.If V is ice-cream, then it is Vanilla.
Derive forward chaining using the given known facts to
prove Tomy is black.
• Tomy barks.
• Tomy eats bone.
Solution: Given Tomy barks.
From (1), it is clear:
If Tomy barks and Tomy eats bone, then Tomy is a dog.
From (3), it is clear:
If Tomy is a dog, then Tomy is black.
Hence, it is proved that Tomy is black.
Backward Chaining
• Backward-chaining is also known as a backward deduction or
backward reasoning method when using an inference engine.
• A backward chaining algorithm is a form of reasoning, which
starts with the goal and works backward, chaining through rules
to find known facts that support the goal.
Properties of backward chaining
• It is known as a top-down approach.
• Backward-chaining is based on modus ponens inference rule.
• In backward chaining, the goal is broken into sub-goal or sub-goals
to prove the facts true.
• It is called a goal-driven approach, as a list of goals decides which
rules are selected and used.
• Backward -chaining algorithm is used in game theory, automated
theorem proving tools, inference engines, proof assistants, and
various AI applications.
• The backward-chaining method mostly used a depth-first
search strategy for proof.
Example
• Tom is sweating (B).
• If a person is running, he will sweat (A->B).
• Tom is running (A).
Conjunctive Normal Form (CNF)
• In Boolean logic, a formula is in conjunctive normal form (CNF)
or clausal normal form if it is a conjunction of one or more clauses,
where a clause is a disjunction of literals.
• It is a product of sums or an AND of ORs.
• It is an ∧ of ∨s of (possibly negated, ¬) variables (called literals ).
(y ∨ ¬z) ∧ ( ¬y) ∧ (y ∨ z) is a CNF
(x ∨ ¬y ∨ z) is a CNF. So is (x ∧ ¬y ∧ z) .
(x ∨ ¬y ∧ z) is not a CNF
• To convert a formula into a CNF
– Open up the implications to get ORs.
Replace: P → Q with ¬P ∨ Q
Replace: P⇔Q with (¬P ∨ Q) ∧(P ∨ ¬Q)
– Get rid of double negations
Replace ¬¬P with P
– Convert F ∨ (G ∧ H) to (F ∨ G) ∧( F ∨ H)
Disjunctive Normal Form (DNF)
• This is a reverse approach of CNF. The process is similar to
CNF with the following difference:
• (A1 ? B1) V (A2 ? B2) V…V (An ? Bn).
• In DNF, it is OR of ANDS
Resolution
• It is one kind of proof technique that works this way -
(i) select two clauses that contain conflicting terms
(ii) combine those two clauses and
(iii) cancel out the conflicting terms.
Resolution Principle
Given two clauses C1 and C2 with no variables in common,
• if there is a literal L1 in C1 which is a complement of literal L2 in C2, both L1 and
L2 are deleted and a disjuncted C is formed from the remaining reduced clauses.
• The new clause C is called resolvent of C1 and C2. Resolution is the process of
generating these resolvents from a set of clauses.
For example we have following statements,
(1) If it is a pleasant day you will do strawberry picking
(2) If you are doing strawberry picking you are happy.
Goal-If it is a pleasant day then you are happy
Above statements can be written in propositional logic like this -
(1) pleasant → strawberry_picking
(2)strawberry_picking → happy
And again these statements can be written in CNF like this -
(1) (strawberry_picking ∨~pleasant) ∧
(2) (happy ∨~strawberry_picking)
By resolving these two clauses and cancelling out the conflicting
terms 'strawberry_picking' and '~strawberry_picking', we can
have one new clause,
~pleasant ∨ happy or pleasant → happy
i.e. If it is a pleasant day you are happy.
Process to apply the resolution
method
• Convert the given axiom into CNF, i.e., a conjunction of clauses.
Each clause should be dis-junction of literals.
• Apply negation on the goal given.
• Use literals which are required and prove it.
English sentences
(1) If it is sunny and warm day you will enjoy.
(2) If it is warm and pleasant day you will do strawberry picking
(3) If it is raining then no strawberry picking.
(4) If it is raining you will get wet.
(5) It is warm day
(6) It is raining
(7) It is sunny
Propositional Statements
(1) enjoy ← sunny ∧ warm
(2) strawberry_picking ← warm ∧ pleasant
(3) ~strawberry_picking ← raining
(4) wet ← raining
(5) warm
(6) raining
(7) sunny
CNF
(1) (enjoy ∨~sunny∨~warm) ∧
(2) (strawberry_picking ∨~warm∨~pleasant) ∧
(3) (~strawberry_picking ∨~raining) ∧
(4) (wet ∨~raining) ∧
(5) (warm) ∧
(6) (raining) ∧
(7) (sunny)
[Note: In our examples propositional logic has 7 statements. So, we will write these
statements in CNF as below (1) and (2) and (3) and (4) and (5) and (6) and (7)
Here and is replaced by ∧ to show them in conjunction of clauses (in CNF). Thus, it
will become (1) ∧ (2) ∧ (3) ∧ (4) ∧ (5) ∧ (6) ∧ (7) ]
• (Goal 1) You are not doing strawberry picking.
• (Goal 2) You will enjoy.
Goal 1 : You are not doing strawberry picking.
Prove : ~strawberry_picking
Assume : strawberry_picking (negate the goal and add it to
given clauses).
Goal 2 : You will enjoy.
Prove : enjoy
Assume : ~enjoy (negate the goal and add it to given clauses)
(Goal 3) :You will get wet.
Consider the following Knowledge Base:
1.The humidity is high or the sky is cloudy.
2.If the sky is cloudy, then it will rain.
3.If the humidity is high, then it is hot.
4.It is not hot.
• Goal: It will rain.
Rule-Based System Architecture
• The most common form of architecture used in expert and other types
of knowledge based systems is the production system or it is called
rule based systems.
• This type of system uses knowledge encoded in the form of production
rules i.e. if-then rules.
• The rule has a conditional part on the left hand side and a conclusion
or action part on the right hand side.
For example if: condition1 and condition2 and condition3
Then: Take action4
• The rule based architecture of an expert system consists of:-
1. the domain expert,
2. knowledge engineer,
3. inference engine,
4. working memory,
5. knowledge base,
6. external interfaces,
7. user interface,
8. explanation module,
9. database spreadsheets executable programs s
User Interface
• It is the mechanism by which the user and the expert system
communicate with each other i.e. the use interacts with the system
through a user interface.
• It acts as a bridge between user and expert system.
• This module accepts the user queries and submits those to the expert
system.
• The user normally consults the expert system for following reasons.
a) To get answer of his/her queries.
b) To get explanation about the solution for psychological satisfaction
• The user interface module is designed in such a way that at user level
it accepts the query in a language understandable by expert system.
• To make the expert system user friendly, the user interface interacts
with the user in natural language.
• The user interface provides as much facilities as possible such as
menus, graphical interfaces etc. to make the dialog user friendly and
more attractive.
Explanation Module
• The explanation module explains the reasoning of the system to a user.
• It provides the user with an explanation of the reasoning process when requested.
• The credibility of expert system will be established only when it is able to explain
“how and why” a particular conclusion is drawn.
• This explanation increases the belief of user in the expert system.
a) Explanation(How): To respond to a how query, the explanation module traces
the chain of rules fired during a consolation with the user.
b) Explanation (Why)? To respond to a why query, the explanation module must
be able to explain why certain information is needed by the inference engine to
complete a step in the reasoning process.
Working Memory
It is a global database of facts used by the rules.
knowledge engineer
• The primary people involved in building an expert system are
the knowledge engineer, the domain expert and the end user.
• Once the knowledge engineer has obtained a general overview of the
problem domain and gone through several problem solving sessions with
the domain expert, he/she is ready to begin actually designing the system,
selecting a way to represent the knowledge, determining the search strategy
(backward or forward) and designing the user interface.
• After making complete designs, the knowledge engineer builds a prototype.
• The prototype should be able to solve problems in a small area of the
domain.
• Once the prototype has been implemented, the knowledge engineer and
domain expert test and refine its knowledge by giving it problems to solve
and correcting its disadvantages.
Knowledge Base
• In rule based architecture of an expert system, the knowledge base is
the set of production rules.
Inference Engine
• The inference engine accepts user input queries and responses to questions
through the I/O interface.
• It uses the dynamic information together with the static knowledge stored in the
knowledge base.
• The knowledge in the knowledge base is used to derive conclusions about the
current case as presented by the user’s input.
• Inference engine is the module which finds an answer from the knowledge base.
• It applies the knowledge to find the solution of the problem.
TYPES OF RULE-BASED SYSTEMS
Like expert systems, rule-based systems can also be
categorized into:
• Forward Chaining: Also known as data-driven reasoning,
forward chaining is a data-driven technique that follows a
deductive approach to reach a conclusion.
• Backward Chaining: Often used in formulating plans,
backward chaining is an alternative to forward chaining. It is a
goal-driven technique that follows an inductive approach
or associative reasoning.
Algorithm For Forward Chaining:
Repeat
Collect the rules whose conditions match facts in Working Memory.
If more than one rule matches, use conflict resolution strategy to eliminate all but
one.
Do actions indicated by the rules (add facts to WM or delete facts from WM)
Until the problem is solved or no condition match.
Algorithm For Backard Chaining
A chain that is traversed from a hypothesis back to the facts that support the hypothesis is a backward
chain.
To prove goal G:
If G is in the initial facts, it is proven.
Otherwise, find a rule which can be used to conclude G, and try to prove
each of that rule’s conditions.
ADVANTAGES OF RULE-BASED SYSTEMS
• Rule-based programming is easy to understand.
• It can be built to represent expert judgment in simple or
complicated subjects.
• The cause-and-effect in Rule-Based Systems is transparent.
• It offers flexibility and an adequate mechanism to model several
basic mental processes into machines.
• Mechanizes the reasoning process.
DISADVANTAGES OF RULE-BASED SYSTEMS
Though exceptionally beneficial, rule-based systems have
certain drawbacks associated with them, such as:
• They require deep domain knowledge and manual work.
• Generating rules for a complex system is quite challenging and
time-consuming.
• It has less learning capacity, as it generates results based on
the rules.
Conflict resolution
• Suppose we have two rules, Rule 1 and Rule 2, with the
same IF part. Thus both of them can be set to fire when
the condition part is satisfied.
• These rules represent a conflict set.
• The inference engine must determine which rule to fire
from such a set.
• A method for choosing a rule to fired in a given cycle is
called conflict resolution.
Conflict resolution strategies
Conflict resolution strategies are used in production
systems in artificial intelligence, such as in rule-based expert
systems, to help in choosing which production rule to fire.
The need for such a strategy arises when the conditions of two or
more rules are satisfied by the currently known facts.
Categories of Conflict resolution strategies
Conflict resolution strategies fall into several main categories.
1.Specificity - If all of the conditions of two or more rules are
satisfied, choose the rule according to how specific its
conditions are. The most specific may be identified roughly as
the one having the greatest number of preconditions.
2.Recency - When two or more rules could be chosen, favor the
one that matches the most recently added facts, as these are
most likely to describe the current situation.
3.Not previously used - If a rule's conditions are satisfied, but
previously the same rule has been satisfied by the same facts,
ignore the rule. This helps to prevent the system from entering
infinite loops.
4.Order - Pick the first applicable rule in order of presentation.
5.Arbitrary choice - Pick a rule at random. This has the merit of
being simple to compute
Use of backtracking
• A backtracking algorithm is a problem-solving algorithm that
uses a brute force approach for finding the desired output.
• The Brute force approach tries out all the possible solutions and
chooses the desired/best solutions.
• The term backtracking suggests that if the current solution is not
suitable, then backtrack and try other solutions. Thus, recursion
is used in this approach.
• This approach is used to solve problems that have multiple
solutions.
• There are three main types of problems in backtracking. They are decision
problems, optimization problems, and enumeration problems.
• To understand if backtracking can be an effective solution, the constraints of
the problem must be clear and well-defined.
• Only then the concepts of dynamic programming can be implemented in the
form of algorithms to solve these problems effectively.
• Backtracking is an important tool for solving constraint
satisfaction problems, such as crosswords, verbal arithmetic,
Sudoku, and many other puzzles.
• It is often the most convenient technique for parsing, for the
knapsack problem and other combinatorial optimization
problems.
Backtracking Algorithm Applications
1.To find all Hamiltonian Paths present in a graph.
2.To solve the N Queen problem.
3.Maze solving problem.
4.The Knight's tour problem.
Semantic Nets
• AI agents have to store and organize information in their memory.
• One of the ways they do this is by using semantic networks.
• Semantic networks are a way of representing relationships between
objects and ideas.
• For example, a network might tell a computer the relationship between
different animals.
• A semantic network is a graphic notation for representing knowledge
in patterns of interconnected nodes.
• Semantic networks became popular in artificial intelligence and
natural language processing only because it represents knowledge or
supports reasoning.
• These act as another alternative for predicate logic in a form of
knowledge representation.
• The structural idea is that knowledge can be stored in the form of
graphs, with nodes representing objects in the world, and arcs
representing relationships between those objects.
Semantic Networks Are Majorly Used
For
• Representing data
• Revealing structure (relations, proximity, relative importance)
• Supporting conceptual edition
• Supporting navigation
• This representation consists of mainly two types of relations:
• a. IS-A relation (Inheritance)
• b. Kind-of-relation
Example: Following are some statements which we need to represent in the
form of nodes and links. Statements:
1. Jerry is a cat.
2. Jerry is a mammal
3. Jerry is owned by Priya.
4. Jerry is brown colored.
5. All Mammals are animal.
is-a
is-a
is –a
is-colored is-owned
White priya
Jerry
Cat
Animal
mammal
• In the above diagram, we have represented the different type of
knowledge in the form of nodes and edges.
• Each object is connected with another object by some relation
Advantages of Semantic network
1. Semantic networks are a natural representation of knowledge.
2. Semantic networks convey meaning in a transparent manner.
3. These networks are simple and easily understandable.
Inheritance in Semantic Net
• Inheritance allows us to specify properties of a superclass and then to define
a subclass, which inherits the properties of the superclass.
• Example: If we say that all mammals give birth to live babies and we also
say that all dogs are mammals and that Tommy is a dog then we can
conclude that Tommy gives birth to live mammals.
• In our example, mammals are the superclass of dogs and Tommy. Dogs are
the subclass of mammals and superclass of Tommy.
• Although inheritance is a useful way to express generalization about a class
of objects, in some cases we need to express exceptions to those
generalizations such as “Male animals do not give birth” or “Female dogs
below the age of 6 months do not give birth”.
• In such cases, we say that the default value has been overridden in the
subclass
Frames
• Frame based representation is a development of semantic nets and
allow us to express the idea of inheritance.
• A Frame System consists of a set of frames (or nodes), which are
connected together by relations. Each frame describes either an
instance or a class.
• Each frame has one or more slots, which are assigned slot values.
This is the way in which the frame system is built up.
• Rather than simply having links between frames, each relationship is
expressed by a value being placed in a slot.
Frame Name Slot Slot Value
Bob Is a Builder
Owns Tommy
eats Cheese
Tommy Is a Dog
chases Bella
Bella Is a Cat
chases mice
• When we say, “Tommy is a dog” we really mean, “Tommy is an
instance of the class dog” or “Tommy is a member of the class dogs”.
• The main advantage of using frame-based systems for expert systems
is that all information about a particular object is stored in one place

Contenu connexe

Similaire à Unit 2.pptx

Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
SherwinSangalang3
 
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
Carrie Wang
 

Similaire à Unit 2.pptx (20)

UNIT 2.pdf
UNIT 2.pdfUNIT 2.pdf
UNIT 2.pdf
 
theory.ppt
theory.ppttheory.ppt
theory.ppt
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
 
6 KBS_ES.ppt
6 KBS_ES.ppt6 KBS_ES.ppt
6 KBS_ES.ppt
 
AI Lesson 11
AI Lesson 11AI Lesson 11
AI Lesson 11
 
Lec 3 1 reasoning
Lec 3  1 reasoningLec 3  1 reasoning
Lec 3 1 reasoning
 
https://www.slideshare.net/amaresimachew/hot-topics-132093738
https://www.slideshare.net/amaresimachew/hot-topics-132093738https://www.slideshare.net/amaresimachew/hot-topics-132093738
https://www.slideshare.net/amaresimachew/hot-topics-132093738
 
Lesson 19
Lesson 19Lesson 19
Lesson 19
 
AI Lesson 19
AI Lesson 19AI Lesson 19
AI Lesson 19
 
Knowledge Representation in AI.pptx
Knowledge Representation in AI.pptxKnowledge Representation in AI.pptx
Knowledge Representation in AI.pptx
 
Module_4_2.pptx
Module_4_2.pptxModule_4_2.pptx
Module_4_2.pptx
 
KNOWLEDGE REPRESENTATION ISSUES.ppt
KNOWLEDGE REPRESENTATION ISSUES.pptKNOWLEDGE REPRESENTATION ISSUES.ppt
KNOWLEDGE REPRESENTATION ISSUES.ppt
 
Hypothesis, theory and scientific laws.
Hypothesis, theory and scientific laws.Hypothesis, theory and scientific laws.
Hypothesis, theory and scientific laws.
 
Process theory
Process theoryProcess theory
Process theory
 
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
New Quantitative Methodology for Identification of Drug Abuse Based on Featur...
 
Bloom's Taxonomy
Bloom's Taxonomy Bloom's Taxonomy
Bloom's Taxonomy
 
CS Artificial Intelligence chapter 4.pptx
CS Artificial Intelligence chapter 4.pptxCS Artificial Intelligence chapter 4.pptx
CS Artificial Intelligence chapter 4.pptx
 
chapter2 Know.representation.pptx
chapter2 Know.representation.pptxchapter2 Know.representation.pptx
chapter2 Know.representation.pptx
 
AI3391 Artificial Intelligence Session 25 Horn clause.pptx
AI3391 Artificial Intelligence Session 25 Horn clause.pptxAI3391 Artificial Intelligence Session 25 Horn clause.pptx
AI3391 Artificial Intelligence Session 25 Horn clause.pptx
 
Qualitative Analysis- Dr Ryan Thomas Williams
Qualitative Analysis- Dr Ryan Thomas WilliamsQualitative Analysis- Dr Ryan Thomas Williams
Qualitative Analysis- Dr Ryan Thomas Williams
 

Dernier

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Unit 2.pptx

  • 2. Knowledge representation • It is the part of Artificial intelligence which concerned with AI agents thinking • And how thinking contributes to intelligent behavior of agents. • It is 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.
  • 3. • It is responsible for representing information about the real world • A computer use this information and can understand and can utilize this knowledge to solve the complex real world problems • Example diagnosis a medical condition or communicating with humans in natural language.
  • 4. What to Represent • 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).
  • 6. 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.
  • 7. 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.
  • 8. 3. Meta-knowledge • Knowledge about the other types of knowledge is called Meta- knowledge.
  • 9. 4. Heuristic knowledge • 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.
  • 10. 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.
  • 11. Approaches to knowledge representation 1. Simple relational knowledge: • It is the simplest way of storing facts which uses the relational method, and each fact about a set of the object is set out systematically in columns. • This approach of knowledge representation is famous in database systems where the relationship between different entities is represented. • This approach has little opportunity for inference.
  • 12. Player Weight Age Player1 65 23 Player2 58 18 Player3 75 24
  • 13. 2. Inheritable knowledge • In the inheritable knowledge approach, all data must be stored into a hierarchy of classes. • All classes should be arranged in a generalized form or a hierarchal manner. • In this approach, we apply inheritance property. • Elements inherit values from other members of a class. • This approach contains inheritable knowledge which shows a relation between instance and class, and it is called instance relation. • Every individual frame can represent the collection of attributes and its value. • In this approach, objects and values are represented in Boxed nodes. • We use Arrows which point from objects to their values.
  • 14.
  • 15. 3. Inferential knowledge: • Inferential knowledge approach represents knowledge in the form of formal logics. • This approach can be used to derive more facts. • It guaranteed correctness. • Example: Let's suppose there are two statements: • Marcus is a man • All men are mortal Then it can represent as; man(Marcus) ∀x = man (x) ----------> mortal (x)s
  • 16. 4. Procedural knowledge: • Procedural knowledge approach uses small programs and codes which describes how to do specific things, and how to proceed. • In this approach, one important rule is used which is If-Then rule. • In this knowledge, we can use various coding languages such as LISP language and Prolog language. • We can easily represent heuristic or domain-specific knowledge using this approach. • But it is not necessary that we can represent all cases in this approach.
  • 17. Requirements for knowledge Representation system: A good knowledge representation system must possess the following properties. 1. Representational Accuracy: KR system should have the ability to represent all kind of required knowledge. 2. Inferential Adequacy: KR system should have ability to manipulate the representational structures to produce new knowledge corresponding to existing structure. 3. Inferential Efficiency: The ability to direct the inferential knowledge mechanism into the most productive directions by storing appropriate guides. 4. Acquisitional efficiency- The ability to acquire the new knowledge easily using automatic methods.
  • 19. There are mainly four ways of knowledge representation which are given as follows: 1.Logical Representation 2.Semantic Network Representation 3.Frame Representation 4.Production Rules
  • 20. 1. Logical Representation • Logical representation is a language with some concrete rules which deals with propositions and has no ambiguity in representation. • Logical representation means drawing a conclusion based on various conditions. • This representation lays down some important communication rules. • It consists of precisely defined syntax and semantics which supports the sound inference. • Each sentence can be translated into logics using syntax and semantics.
  • 21. Syntax: • Syntaxes are the rules which decide how we can construct legal sentences in the logic. • It determines which symbol we can use in knowledge representation. • How to write those symbols. Semantics: • Semantics are the rules by which we can interpret the sentence in the logic. • Semantic also involves assigning a meaning to each sentence.
  • 22. Logical representation can be categorised into mainly two logics: 1.Propositional Logics 2.Predicate logics
  • 23. Propositional logic in Artificial intelligence • 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.
  • 24. Following are some 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. • 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. • 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.
  • 25. Syntax of propositional logic • The syntax of propositional logic defines the allowable sentences for the knowledge representation. • There are two types of Propositions: 1.Atomic Propositions 2.Compound propositions
  • 26. 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. Example 1. 2+2 is 4, it is an atomic proposition as it is a true fact. 2."The Sun is cold" is also a proposition as it is a false fact.
  • 27. Compound proposition • Compound propositions are constructed by combining simpler or atomic propositions, using parenthesis and logical connectives. Example a) "It is raining today, and street is wet." b) "Ankit is a doctor, and his clinic is in Mumbai."
  • 28. 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: 1.Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or negative literal. 2.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.
  • 29. 3. 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. 4. 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 5. 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
  • 30.
  • 31. 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. • Following are the truth table for all logical connectives:
  • 32.
  • 33.
  • 34. Truth table with three propositions
  • 35. Precedence of connectives Precedence Operators First Precedence Parenthesis Second Precedence Negation Third Precedence Conjunction(AND) Fourth Precedence Disjunction(OR) Fifth Precedence Implication Six Precedence Biconditional
  • 36. 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. • Let's take two propositions A and B, so for logical equivalence, we can write it as A⇔B. In below truth table we can see that column for ¬A∨ B and A→B, are identical hence A is Equivalent to B
  • 37.
  • 38. 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.
  • 39. • 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.
  • 40. First Order Predicate Logic FOPL was developed by logicians to extend the expressiveness of PL. The symbols and rules of combination permitted in FOPL are defined as follows: 1. Connectives: There are five connectives symbols: ∨, ^ , ¬ , ⇒ and ⇔. 2. Quantifiers: Two quantifier symbols are ∀ & ∃ where ∃x means for some x and ∀x means for all x. 3. Variables: These are the terms which may have different values in a given domain. 4. Constants: These are the fixed value terms that belongs to a given domain.
  • 41. 5. Function: It is used to identify a domain element. It maps n elements to a single element. Symbols f, g, h and words such as age_of, income_of reprent a function. 6. Predicates: They are the relation within the domain to show how an element is related to another. Capital letters or capitalized words are used to represent a predicate.
  • 42. Properties of a statement Satisfiable: A statement is satisfiable if there is some interpretation for which it is true. Contradiction: A sentence is contradictory (unsatisfiable) if there is no interpretation for which it is true. Valid: A sentence is valid if it is true for every interpretation. Equivalence: Two sentence are equivalent if they have same truth values under every interpretation. Logical Consequences: A sentence is a logical consequence of another if it is satisfied by all interpretation which satisfies the first.
  • 43. Well-Formed Formula(WFF) • Well-Formed Formula(WFF) is an expression consisting of variables(capital letters), parentheses, and connective symbols. • An expression is basically a combination of operands & operators and here operands and operators are the connective symbols.
  • 44. Well-formed formula (WFF) • Any expression that obeys the syntactic rules of propositional logic is called a well-formed formula, or WFF. • Fortunately, the syntax of propositional logic is easy to learn. It has only three rules: 1.A Statement variable standing alone is a Well-Formed Formula(WFF). For example– Statements like P, ∼P, Q, ∼Q are themselves Well Formed Formulas. 2.If ‘P’ is a WFF then ∼P is a formula as well. 3.If P & Q are WFFs, then (P∨Q), (P∧Q), (P⇒Q), (P⇔Q), etc. are also WFFs.
  • 45. Some Equivalence Laws Negative Law: ~(~P) ≈ P De Morgan’s Laws: ~ (P V Q) ≈ ~P & ~Q ~ (P & Q) ≈ ~P V ~Q Distributivity: P & ( Q V R) ≈ (P & Q) V (P & R) P V ( Q & R) ≈ (P V Q) & (P V R)
  • 46. Inference Rule • Generating the conclusions from evidence and facts is termed as Inference. • Inference rules are applied to derive proofs in artificial intelligence. • The proof is a sequence of the conclusion that leads to the desired goal. • In inference rules, the implication among all the connectives plays an important role.
  • 47. Following are 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.
  • 48. Types of Inference rules 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:
  • 49. 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.
  • 50. 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:
  • 51. Example 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
  • 52. 3. Hypothetical Syllogism: The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and Q→R is true. It can be represented as the following notation: Example: Statement-1: If you have my home key then you can unlock my home. P→Q Statement-2: If you can unlock my home then you can take my money. Q→R Conclusion: If you have my home key then you can take my money. P→R
  • 53. 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:
  • 54. Example: Statement-1: Today is Sunday or Monday. ==>P∨Q Statement-2: Today is not Sunday. ==> ¬P Conclusion: Today is Monday. ==> Q
  • 55. 5. Addition: The Addition rule is one the common inference rule, and it states that If P is true, then P∨Q will be true.
  • 56. 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)
  • 57. 6. Simplification: The simplification rule state that if P∧ Q is true, then Q or P will also be true. It can be represented as:
  • 58. 7. Resolution: The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be true. It can be represented as
  • 59. Forward Chaining and backward chaining in AI The inference engine is the component of the intelligent system in artificial intelligence, which applies logical rules to the knowledge base to infer new information from known facts. The first inference engine was part of the expert system. Inference engine commonly proceeds in two modes, which are: 1.Forward chaining 2.Backward chaining
  • 60. Horn Clause and Definite clause: • Horn clause and definite clause are the forms of sentences, which enables knowledge base to use a more restricted and efficient inference algorithm. • Logical inference algorithms use forward and backward chaining approaches, which require KB in the form of the first- order definite clause.
  • 61. • Definite clause: A clause which is a disjunction of literals with exactly one positive literal is known as a definite clause or strict horn clause. • Horn clause: A clause which is a disjunction of literals with at most one positive literal is known as horn clause. Hence all the definite clauses are horn clauses. Example: (¬ p V ¬ q V k). It has only one positive literal k. It is equivalent to p ∧ q → k.
  • 62. Forward Chaining • Forward chaining is also known as a forward deduction or forward reasoning method when using an inference engine. • Forward chaining is a form of reasoning which start with atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more data until a goal is reached. • The Forward-chaining algorithm starts from known facts, triggers all rules whose premises are satisfied, and add their conclusion to the known facts. • This process repeats until the problem is solved.
  • 63.
  • 64. Properties of Forward-Chaining • It is a down-up approach, as it moves from bottom to top. • It is a process of making a conclusion based on known facts or data, by starting from the initial state and reaches the goal state. • Forward-chaining approach is also called as data-driven as we reach to the goal using available data. • Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and production rule systems.
  • 65. Example • Tom is running (A) • If a person is running, he will sweat (A->B) • Therefore, Tom is sweating. (B)
  • 66. Example Facts 1.If D barks and D eats bone, then D is a dog. 2.If V is cold and V is sweet, then V is ice-cream. 3.If D is a dog, then D is black. 4.If V is ice-cream, then it is Vanilla. Derive forward chaining using the given known facts to prove Tomy is black. • Tomy barks. • Tomy eats bone.
  • 67. Solution: Given Tomy barks. From (1), it is clear: If Tomy barks and Tomy eats bone, then Tomy is a dog. From (3), it is clear: If Tomy is a dog, then Tomy is black. Hence, it is proved that Tomy is black.
  • 68. Backward Chaining • Backward-chaining is also known as a backward deduction or backward reasoning method when using an inference engine. • A backward chaining algorithm is a form of reasoning, which starts with the goal and works backward, chaining through rules to find known facts that support the goal.
  • 69.
  • 70. Properties of backward chaining • It is known as a top-down approach. • Backward-chaining is based on modus ponens inference rule. • In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true. • It is called a goal-driven approach, as a list of goals decides which rules are selected and used. • Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference engines, proof assistants, and various AI applications. • The backward-chaining method mostly used a depth-first search strategy for proof.
  • 71. Example • Tom is sweating (B). • If a person is running, he will sweat (A->B). • Tom is running (A).
  • 72. Conjunctive Normal Form (CNF) • In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of one or more clauses, where a clause is a disjunction of literals. • It is a product of sums or an AND of ORs. • It is an ∧ of ∨s of (possibly negated, ¬) variables (called literals ).
  • 73. (y ∨ ¬z) ∧ ( ¬y) ∧ (y ∨ z) is a CNF (x ∨ ¬y ∨ z) is a CNF. So is (x ∧ ¬y ∧ z) . (x ∨ ¬y ∧ z) is not a CNF
  • 74. • To convert a formula into a CNF – Open up the implications to get ORs. Replace: P → Q with ¬P ∨ Q Replace: P⇔Q with (¬P ∨ Q) ∧(P ∨ ¬Q) – Get rid of double negations Replace ¬¬P with P – Convert F ∨ (G ∧ H) to (F ∨ G) ∧( F ∨ H)
  • 75. Disjunctive Normal Form (DNF) • This is a reverse approach of CNF. The process is similar to CNF with the following difference: • (A1 ? B1) V (A2 ? B2) V…V (An ? Bn). • In DNF, it is OR of ANDS
  • 76. Resolution • It is one kind of proof technique that works this way - (i) select two clauses that contain conflicting terms (ii) combine those two clauses and (iii) cancel out the conflicting terms.
  • 77. Resolution Principle Given two clauses C1 and C2 with no variables in common, • if there is a literal L1 in C1 which is a complement of literal L2 in C2, both L1 and L2 are deleted and a disjuncted C is formed from the remaining reduced clauses. • The new clause C is called resolvent of C1 and C2. Resolution is the process of generating these resolvents from a set of clauses.
  • 78. For example we have following statements, (1) If it is a pleasant day you will do strawberry picking (2) If you are doing strawberry picking you are happy. Goal-If it is a pleasant day then you are happy
  • 79. Above statements can be written in propositional logic like this - (1) pleasant → strawberry_picking (2)strawberry_picking → happy
  • 80. And again these statements can be written in CNF like this - (1) (strawberry_picking ∨~pleasant) ∧ (2) (happy ∨~strawberry_picking)
  • 81. By resolving these two clauses and cancelling out the conflicting terms 'strawberry_picking' and '~strawberry_picking', we can have one new clause, ~pleasant ∨ happy or pleasant → happy i.e. If it is a pleasant day you are happy.
  • 82. Process to apply the resolution method • Convert the given axiom into CNF, i.e., a conjunction of clauses. Each clause should be dis-junction of literals. • Apply negation on the goal given. • Use literals which are required and prove it.
  • 83. English sentences (1) If it is sunny and warm day you will enjoy. (2) If it is warm and pleasant day you will do strawberry picking (3) If it is raining then no strawberry picking. (4) If it is raining you will get wet. (5) It is warm day (6) It is raining (7) It is sunny
  • 84. Propositional Statements (1) enjoy ← sunny ∧ warm (2) strawberry_picking ← warm ∧ pleasant (3) ~strawberry_picking ← raining (4) wet ← raining (5) warm (6) raining (7) sunny
  • 85. CNF (1) (enjoy ∨~sunny∨~warm) ∧ (2) (strawberry_picking ∨~warm∨~pleasant) ∧ (3) (~strawberry_picking ∨~raining) ∧ (4) (wet ∨~raining) ∧ (5) (warm) ∧ (6) (raining) ∧ (7) (sunny) [Note: In our examples propositional logic has 7 statements. So, we will write these statements in CNF as below (1) and (2) and (3) and (4) and (5) and (6) and (7) Here and is replaced by ∧ to show them in conjunction of clauses (in CNF). Thus, it will become (1) ∧ (2) ∧ (3) ∧ (4) ∧ (5) ∧ (6) ∧ (7) ]
  • 86. • (Goal 1) You are not doing strawberry picking. • (Goal 2) You will enjoy.
  • 87. Goal 1 : You are not doing strawberry picking. Prove : ~strawberry_picking Assume : strawberry_picking (negate the goal and add it to given clauses).
  • 88. Goal 2 : You will enjoy. Prove : enjoy Assume : ~enjoy (negate the goal and add it to given clauses)
  • 89. (Goal 3) :You will get wet.
  • 90. Consider the following Knowledge Base: 1.The humidity is high or the sky is cloudy. 2.If the sky is cloudy, then it will rain. 3.If the humidity is high, then it is hot. 4.It is not hot. • Goal: It will rain.
  • 91. Rule-Based System Architecture • The most common form of architecture used in expert and other types of knowledge based systems is the production system or it is called rule based systems. • This type of system uses knowledge encoded in the form of production rules i.e. if-then rules. • The rule has a conditional part on the left hand side and a conclusion or action part on the right hand side. For example if: condition1 and condition2 and condition3 Then: Take action4
  • 92. • The rule based architecture of an expert system consists of:- 1. the domain expert, 2. knowledge engineer, 3. inference engine, 4. working memory, 5. knowledge base, 6. external interfaces, 7. user interface, 8. explanation module, 9. database spreadsheets executable programs s
  • 93.
  • 94. User Interface • It is the mechanism by which the user and the expert system communicate with each other i.e. the use interacts with the system through a user interface. • It acts as a bridge between user and expert system. • This module accepts the user queries and submits those to the expert system. • The user normally consults the expert system for following reasons. a) To get answer of his/her queries. b) To get explanation about the solution for psychological satisfaction
  • 95. • The user interface module is designed in such a way that at user level it accepts the query in a language understandable by expert system. • To make the expert system user friendly, the user interface interacts with the user in natural language. • The user interface provides as much facilities as possible such as menus, graphical interfaces etc. to make the dialog user friendly and more attractive.
  • 96. Explanation Module • The explanation module explains the reasoning of the system to a user. • It provides the user with an explanation of the reasoning process when requested. • The credibility of expert system will be established only when it is able to explain “how and why” a particular conclusion is drawn. • This explanation increases the belief of user in the expert system.
  • 97. a) Explanation(How): To respond to a how query, the explanation module traces the chain of rules fired during a consolation with the user. b) Explanation (Why)? To respond to a why query, the explanation module must be able to explain why certain information is needed by the inference engine to complete a step in the reasoning process.
  • 98. Working Memory It is a global database of facts used by the rules.
  • 99. knowledge engineer • The primary people involved in building an expert system are the knowledge engineer, the domain expert and the end user. • Once the knowledge engineer has obtained a general overview of the problem domain and gone through several problem solving sessions with the domain expert, he/she is ready to begin actually designing the system, selecting a way to represent the knowledge, determining the search strategy (backward or forward) and designing the user interface. • After making complete designs, the knowledge engineer builds a prototype. • The prototype should be able to solve problems in a small area of the domain. • Once the prototype has been implemented, the knowledge engineer and domain expert test and refine its knowledge by giving it problems to solve and correcting its disadvantages.
  • 100. Knowledge Base • In rule based architecture of an expert system, the knowledge base is the set of production rules.
  • 101. Inference Engine • The inference engine accepts user input queries and responses to questions through the I/O interface. • It uses the dynamic information together with the static knowledge stored in the knowledge base. • The knowledge in the knowledge base is used to derive conclusions about the current case as presented by the user’s input. • Inference engine is the module which finds an answer from the knowledge base. • It applies the knowledge to find the solution of the problem.
  • 102. TYPES OF RULE-BASED SYSTEMS Like expert systems, rule-based systems can also be categorized into: • Forward Chaining: Also known as data-driven reasoning, forward chaining is a data-driven technique that follows a deductive approach to reach a conclusion. • Backward Chaining: Often used in formulating plans, backward chaining is an alternative to forward chaining. It is a goal-driven technique that follows an inductive approach or associative reasoning.
  • 103. Algorithm For Forward Chaining: Repeat Collect the rules whose conditions match facts in Working Memory. If more than one rule matches, use conflict resolution strategy to eliminate all but one. Do actions indicated by the rules (add facts to WM or delete facts from WM) Until the problem is solved or no condition match.
  • 104. Algorithm For Backard Chaining A chain that is traversed from a hypothesis back to the facts that support the hypothesis is a backward chain. To prove goal G: If G is in the initial facts, it is proven. Otherwise, find a rule which can be used to conclude G, and try to prove each of that rule’s conditions.
  • 105. ADVANTAGES OF RULE-BASED SYSTEMS • Rule-based programming is easy to understand. • It can be built to represent expert judgment in simple or complicated subjects. • The cause-and-effect in Rule-Based Systems is transparent. • It offers flexibility and an adequate mechanism to model several basic mental processes into machines. • Mechanizes the reasoning process.
  • 106. DISADVANTAGES OF RULE-BASED SYSTEMS Though exceptionally beneficial, rule-based systems have certain drawbacks associated with them, such as: • They require deep domain knowledge and manual work. • Generating rules for a complex system is quite challenging and time-consuming. • It has less learning capacity, as it generates results based on the rules.
  • 107. Conflict resolution • Suppose we have two rules, Rule 1 and Rule 2, with the same IF part. Thus both of them can be set to fire when the condition part is satisfied. • These rules represent a conflict set. • The inference engine must determine which rule to fire from such a set. • A method for choosing a rule to fired in a given cycle is called conflict resolution.
  • 108. Conflict resolution strategies Conflict resolution strategies are used in production systems in artificial intelligence, such as in rule-based expert systems, to help in choosing which production rule to fire. The need for such a strategy arises when the conditions of two or more rules are satisfied by the currently known facts.
  • 109. Categories of Conflict resolution strategies Conflict resolution strategies fall into several main categories. 1.Specificity - If all of the conditions of two or more rules are satisfied, choose the rule according to how specific its conditions are. The most specific may be identified roughly as the one having the greatest number of preconditions. 2.Recency - When two or more rules could be chosen, favor the one that matches the most recently added facts, as these are most likely to describe the current situation.
  • 110. 3.Not previously used - If a rule's conditions are satisfied, but previously the same rule has been satisfied by the same facts, ignore the rule. This helps to prevent the system from entering infinite loops. 4.Order - Pick the first applicable rule in order of presentation. 5.Arbitrary choice - Pick a rule at random. This has the merit of being simple to compute
  • 111. Use of backtracking • A backtracking algorithm is a problem-solving algorithm that uses a brute force approach for finding the desired output. • The Brute force approach tries out all the possible solutions and chooses the desired/best solutions. • The term backtracking suggests that if the current solution is not suitable, then backtrack and try other solutions. Thus, recursion is used in this approach. • This approach is used to solve problems that have multiple solutions.
  • 112. • There are three main types of problems in backtracking. They are decision problems, optimization problems, and enumeration problems. • To understand if backtracking can be an effective solution, the constraints of the problem must be clear and well-defined. • Only then the concepts of dynamic programming can be implemented in the form of algorithms to solve these problems effectively.
  • 113. • Backtracking is an important tool for solving constraint satisfaction problems, such as crosswords, verbal arithmetic, Sudoku, and many other puzzles. • It is often the most convenient technique for parsing, for the knapsack problem and other combinatorial optimization problems.
  • 114. Backtracking Algorithm Applications 1.To find all Hamiltonian Paths present in a graph. 2.To solve the N Queen problem. 3.Maze solving problem. 4.The Knight's tour problem.
  • 115. Semantic Nets • AI agents have to store and organize information in their memory. • One of the ways they do this is by using semantic networks. • Semantic networks are a way of representing relationships between objects and ideas. • For example, a network might tell a computer the relationship between different animals.
  • 116.
  • 117. • A semantic network is a graphic notation for representing knowledge in patterns of interconnected nodes. • Semantic networks became popular in artificial intelligence and natural language processing only because it represents knowledge or supports reasoning. • These act as another alternative for predicate logic in a form of knowledge representation. • The structural idea is that knowledge can be stored in the form of graphs, with nodes representing objects in the world, and arcs representing relationships between those objects.
  • 118. Semantic Networks Are Majorly Used For • Representing data • Revealing structure (relations, proximity, relative importance) • Supporting conceptual edition • Supporting navigation
  • 119. • This representation consists of mainly two types of relations: • a. IS-A relation (Inheritance) • b. Kind-of-relation Example: Following are some statements which we need to represent in the form of nodes and links. Statements: 1. Jerry is a cat. 2. Jerry is a mammal 3. Jerry is owned by Priya. 4. Jerry is brown colored. 5. All Mammals are animal.
  • 120. is-a is-a is –a is-colored is-owned White priya Jerry Cat Animal mammal
  • 121. • In the above diagram, we have represented the different type of knowledge in the form of nodes and edges. • Each object is connected with another object by some relation
  • 122. Advantages of Semantic network 1. Semantic networks are a natural representation of knowledge. 2. Semantic networks convey meaning in a transparent manner. 3. These networks are simple and easily understandable.
  • 123. Inheritance in Semantic Net • Inheritance allows us to specify properties of a superclass and then to define a subclass, which inherits the properties of the superclass. • Example: If we say that all mammals give birth to live babies and we also say that all dogs are mammals and that Tommy is a dog then we can conclude that Tommy gives birth to live mammals. • In our example, mammals are the superclass of dogs and Tommy. Dogs are the subclass of mammals and superclass of Tommy. • Although inheritance is a useful way to express generalization about a class of objects, in some cases we need to express exceptions to those generalizations such as “Male animals do not give birth” or “Female dogs below the age of 6 months do not give birth”. • In such cases, we say that the default value has been overridden in the subclass
  • 124. Frames • Frame based representation is a development of semantic nets and allow us to express the idea of inheritance. • A Frame System consists of a set of frames (or nodes), which are connected together by relations. Each frame describes either an instance or a class. • Each frame has one or more slots, which are assigned slot values. This is the way in which the frame system is built up. • Rather than simply having links between frames, each relationship is expressed by a value being placed in a slot.
  • 125. Frame Name Slot Slot Value Bob Is a Builder Owns Tommy eats Cheese Tommy Is a Dog chases Bella Bella Is a Cat chases mice
  • 126. • When we say, “Tommy is a dog” we really mean, “Tommy is an instance of the class dog” or “Tommy is a member of the class dogs”. • The main advantage of using frame-based systems for expert systems is that all information about a particular object is stored in one place