Knowledge and Reasoning: UNIT-3
Knowledge and Reasoning: UNIT-3
• Attributes
• Relationship among the attributes
• Granularity
• Representation of objects as sets
• Selectin of correct structure
Important Attributed:
•Any attribute of objects so basic that they occur in almost every
problem domain?
•There are two attributed “instance” and “isa”(One entity type might
be a subtype of another), that are general significance.
•These attributes are important because they support property
inheritance.
Relationship among attributes:
•Any important relationship that exists among object attributed?
•The attributes we use to describe objects are themselves entities
that we represent.
• The relationship between the attributes of an object, independent of
specific knowledge they encode, may hold properties like:
– Inverse — This is about consistency check, while a value is added to one attribute. The
entities are related to each other in many different ways.
– Existence in an isa hierarchy — This is about generalization-specification, like, classes
of objects and specialized subsets of those classes, there are attributes and
specialization of attributes. For example, the attribute height is a specialization of general
attribute physical-size which is, in turn, a specialization of physical-attribute. These
generalization-specialization relationships are important for attributes because they
support inheritance.
– Technique for reasoning about values — This is about reasoning values of attributes
not given explicitly. Several kinds of information are used in reasoning, like, height: must
be in a unit of length, Age: of a person cannot be greater than the age of person’s
parents. The values are often specified when a knowledge base is created.
– Single valued attributes — This is about a specific attribute that is guaranteed to take a
unique value. For example, a baseball player can at time have only a single height and
be a member of only one team. KR systems take different approaches to provide support
for single valued attributes.
Choosing Granularity:
•At what level of detail should the knowledge be represented?
•Regardless of the KR formalism, it is necessary to know:
– At what level should the knowledge be represented and what are the primitives?
•Should there be a small number or should there be a large number of low-level
primitives or High-level facts.
•High-level facts may not be adequate for inference while Low-level primitives may
require a lot of storage.
Set of objects:
•How should sets of objects be represented?
•There are certain properties of objects that are true as member of a set but not as
individual;
•The reason to represent sets of objects is: if a property is true for all or most
elements of a set, then it is more efficient to associate it once with the set rather
than to associate it explicitly with every elements of the set.
Finding Right structure:
•Given a large amount of knowledge stored in a database, how can relevant
parts are accessed when they are needed?
•This is about access to right structure for describing a particular situation.
•This requires, selecting an initial structure and then revising the choice.
•While doing so, it is necessary to solve following problems:
– How to perform an initial selection of the most appropriate structure.
– How to fill in appropriate details from the current situations.
– How to find a better structure if the one chosen initially turns out not to be
appropriate.
– What to do if none of the available structures is appropriate.
– When to create and remember a new structure.
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 agents are composed of two main parts:
– Knowledge-base and
– Inference system.
• 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.
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:
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.
2. Logical level:
• At this level, we understand that how the knowledge representation of
knowledge is stored. At this level, sentences are encoded into different
logics. At the logical level, 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.
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.A knowledge-based agent can be
viewed at different levels which are given below:
Approaches to designing a knowledge-based agent
• There are mainly two approaches to build a knowledge-based agent:
– Declarative approach: We can 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.
– 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.
Logic Basics
• logic deals with study of principles of reasoning.
• Here, we study about how logic is built,or how the logical
representation help in the process of decisions.
• logic involves syntax, semantics and inference procedure.
• Syntax: there is variety of ways to represent syntax. it is not a concern
but it is the way an agent builds a base so that reasoning plays an
important parrt.
• Semantics: it deals with the meaning in sentential form, it can either
be true or false.
• Logical inferring: there is a notion of truth that is to be maintained.
even it needs to have the property of completeness.
Propositional logic-syntax,semantics and inferences
• Propositional logic (PL) is the most simple logic that is
concerned with the propositions and their relationship.
• It is a mathematical model that provides reasoning regarding the
logical value of an expression.
• A proposition is a declarative statement which is either true or
false but not both.
• Example:
– It is Sunday.
– The Sun rises from West (False proposition)
– 3+3= 7(False proposition)
– 5 is a prime number.
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 (simple)
– Compound propositions
• Atomic Proposition: It consists of a single propositional symbol. This
symbol esentially represents if the proposition can be true or false.
• 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.
• 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:
• Negation: A sentence such as ~or ¬ 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.
• 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
• 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.
• Following is the summarized table for Propositional Logic Connectives:
Semantics of propositional logic
• It tells about the rules to determine the truth of a sentence.
• The model comprising a number of propositions actually defines the truth
value.
• with 2 propositional symbols the model will be 2^2, with 3 it will be 2^3.
Inference of propositional logic
• Generating the conclusions from evidence and facts is termed as
Inference.
• When comes to inference, we need to enumerate the models.
• The number of propositions playing part in it directly hampers the efficiency.
• The values where KB is true, and thus, the value of x is true indicate
inferring.
• Given a sentence n, the approach for deciding entailment is based on
recursive enumeration. The approach is:
Some Concepts
• Tautology: It states that the sentence is true if it is true in all
models.It is also called validity.
• Contradiction: Here, the proposition is always false.
• Satisfiability: A sentence or a proposition is satisfiable if it is true
for some model.
• To understand the relation between validity and satisfiability:
– Assume that a sentence x is valid.
– To prove that x is valid, we need to prove that ~x is not valid.
– we can state that, x I= y iff sentence (x^~y) is unsatisfiable.
– Proving y from x by checking the unsatisfiability is Proof by refutation or
contradiction.
Reasoning patterns in propositional logic
• Here, we use and apply the basic rules in order to derive chains of
conclusions to get the outcome or the target.
• These basic rules are also called patterns of inference.
• Two most commonly used rules are modes ponens and and-elimination.
– Modus ponens is represented as follows:
ɑ -> β, ɑ l-> β
• the rule states that when any sentence is in the form of ɑ -> β, and ɑ is given, then we can infer
β.
– In and-elimination , the rule is represented as
ɑ1^ɑ2^ɑ3^ɑn l->ɑi
• It states that from conjunctions, it is possible to infer any conjunction.
• These rules are actually the ones that eliminate the need for generating the
models.
• When these rules are applied, they generate sound(correct) inferences.
Resolution
• Resolution discuss about completeness.
• Resolution is a single inference rule, which gives a complete
inference algorithm when coupled with complete search algorithms.
• Any search algorithms, that is complete and applies the resolution
rule can derive any conclusion that is entailed in KB.
• suppose if x proposition is true, it is not possible to have resolution
to generate XvY, but can determine whether it is true or not.
• This is referred to as refutation completeness.
• Resolution is not ly applied to disjunctions but to conjection forms
also called conjunctive normal form (CNF).
Resolution Algorithm
Predicate logic
• In propositional logic, we can only represent the facts, which are either true
or false. It is not sufficient to represent the complex sentences or natural
language statements.
• The propositional logic has very limited expressive power.
• So, we required some more powerful logic, such as Predicate logic.
• It is also known as First-order logic. (more expressive)
• First-order logic statements can be divided into two parts:
– Subject: Subject is the main part of the statement.
– Predicate: A predicate can be defined as a relation, which binds two
atoms together in a statement.
• Consider the statement: "x is an integer.", it consists of two parts, the first
part x is the subject of the statement and second part "is an integer," is
known as a predicate.
Syntax and Semantics
• First-order logic (like natural language) does not only assume that the world
contains facts like propositional logic but also assumes the following things in
the world:
– Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
– Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation
such as: the sister of, brother of, has color, comes between
– Function: Father of, best friend, third inning of, end of, ......
• As a natural language, first-order logic also has two main parts:
– Syntax
– Semantics
• The syntax of FOL determines which collection of symbols is a logical
expression in first-order logic. The basic syntactic elements of first-order logic
are symbols.
• We write statements in short-hand notation in FOL.
• For example,
• “The car is red”
– here ‘car’ is the subject and ‘is red’ is the predicate.
• While representing,
– R(x) ; where R is red and x is any object
• A sentence can be an atomic sentence or sentence connected to each other.
Atomic sentences:
• Atomic sentences are the most basic sentences of first-order logic. These
sentences are formed from a predicate symbol followed by a parenthesis with
a sequence of terms.
• We can represent atomic sentences as Predicate (term1, term2, ......, term n).
• Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences:
•Complex sentences are made by combining atomic sentences using
connectives.
Inference in First-Order Logic
• Inference in First-Order Logic is used to deduce new facts or
sentences from existing sentences.
• Example:
– Shyam is an engineer.
– All engineers are intelligent.
• Here, intelligent and engineer are the classes. whereas, instance
indicates the membership belonging to the class.
• Instance(Shyam, Engineer) indicates the class membership.
Comparison of predicate and propositional logic
Unification
• Unification is a process of making two different logical atomic
expressions identical by finding a substitution.
• Unification depends on the substitution process.
• The substitution variables are called Most General Unifier or MGU.
• The UNIFY algorithm is used for unification, which takes two atomic
sentences and returns a unifier for those sentences (If any exist).
• It returns fail if the expressions do not match with each other.
• Unification is a key component of all first-order inference algorithms.
• Unification takes two literals as input and makes them identical using
substitution.
– Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that,
Ψ1𝜎 = Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
• Example: Find the MGU for Unify{King(x), King(John)}
– Let Ψ1 = King(x), Ψ2 = King(John),
– Substitution θ = {John/x} is a unifier for these atoms and applying this
substitution, and both expressions will be identical.
• E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
– In this example, we need to make both above statements identical to each
other.
– For this, we will perform the substitution.
– P(x, y)......... (i)
– P(a, f(z))......... (ii)
– Substitute x with a, and y with f(z) in the first expression, and it will be
represented as a/x and f(z)/y.
– With both the substitutions, the first expression will be identical to the second
expression and the substitution set will be: [a/x, f(z)/y].
Conditions for Unification:
• Following are some basic conditions for unification:
– Predicate symbol must be same, atoms or expression with
different predicate symbol can never be unified.
– Number of Arguments in both expressions must be identical.
– Unification will fail if there are two similar variables present in
the same expression.
Unification Algorithm
• Algorithm: Unify(Ψ1, Ψ2)
Implementation of the Algorithm
• Step.1: Initialize the substitution set to be empty.
• Step.2: Recursively unify atomic sentences:
a.Check for Identical expression match.
b.If one expression is a variable vi, and the other is a term ti which
does not contain variable vi, then:
a.Substitute ti / vi in the existing substitutions
b.Add ti /vi to the substitution setlist.
c.If both the expressions are functions, then function name must
be similar, and the number of arguments must be the same in both
the expression.
1. Find the MGU of {p(f(a), g(Y)) and p(X, X)} 2. Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y),
f(Y))}
Sol:
Sol:
S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X,
Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))
X)
S0 => { p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}
SUBST θ= {f(a) / X}
SUBST θ={b/Z}
S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a),
f(a)) S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))}
SUBST θ= {f(a) / g(y)}, Unification failed. SUBST θ={f(Y) /X}
Unification is not possible for these S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))}
expressions. SUBST θ= {g(b) /Y}
• Representation of frames:
Tendulkar
Instance: Batsman
Runs: 15500
Team: India
Inferences
• It is a mechanism by which reasoning takes place.
• Basic types are
– Deduction
– Induction
– Abduction
Uncertain Knowledge and Reasoning-Methods
• Uncertainty
• Let action At = leave for airport t minutes before flight
• Will At get me there on time?
– Problems:
1) partial observability (road state, other drivers’ plans, etc.)
2) noisy sensors (traffic reports)
3) uncertainty in action outcomes (flat tire, etc.)
4) immense complexity of modelling and predicting traffic
– Hence a purely logical approach either
1) risks falsehood: “A25 will get me there on time”
or
2) A1440 leads to conclusions that are too weak for decision making:
How To Deal With Uncertainty
Implicit methods:
•Ignore uncertainty as much as possible
•Build procedures that are robust to uncertainty
•This is the approach in the planning methods studied so far
(e.g.monitoring and replanning)
Explicit methods:
•Build a model of the world that describes the uncertainty (about the
system’s state, dynamics, sensors, model)
•Reason about the effect of actions given in the model
Methods for Handling Uncertainty
• Default reasoning
– Nonmonotonic logic: Allow the retraction of default beliefs if they
prove to be false
• Rule-based methods
– Certainty factors (Mycin): propagate simple models of belief
through causal or diagnostic rules
• Evidential reasoning
– Dempster-Shafer theory: Bel(P) is a measure of the evidence for
P; Bel(P) is a measure of the evidence against P; together they
define a belief interval (lower and upper bounds on confidence)
• Fuzzy reasoning
– Fuzzy sets: How well does an object satisfy a vague property?
– Fuzzy logic: “How true” is a logical statement?
Decision making with uncertainty
• Rational behavior:
– For each possible action, identify the possible outcomes
– Compute the probability of each outcome
– Compute the utility of each outcome
– Compute the probability-weighted (expected) utility over
possible outcomes for each action
– Select the action with the highest expected utility (principle of
Maximum Expected Utility)
Probability
• A well-known and well-understood framework for dealing with
uncertainty
• Has a clear semantics
• Provides principled answers for:
– Combining evidence
– Predictive and diagnostic reasoning
– Incorporation of new evidence
• Can be learned from data
• Intuitive to human experts (arguably?)
Bayesian Probability and Belief Network
• We use probability to describe uncertainty due to:
– Laziness: failure to enumerate exceptions, qualifications etc.
– Ignorance: lack of relevant facts, initial conditions etc.
– True randomness? Quantum effects? ...
• Probability can be interpreted from two views 1. Subjective and 2.Objective
• Bayesian or subjective probabilities - relate propositions to one’s current state of
knowledge.
– E.g. P(A(25)| no reported accident) = 0.1
These are not assertions about the world / absolute truth
• Beliefs change with new evidence:
– E.g. P(A(25)| no reported accident, 5am) = 0.2
• Bayesian probability is viewed as an extension of logic that enables reasoning with
uncertain statements.
Conditional Probability
• The basic statements in the Bayesian framework talk about
conditional probabilities.
– P(A|B) is the belief in event A given that event B is known with
certainty.
P(A|B)=P(A and B)/P(B)
• If it is rewritten as,
P(A ∧ B) = P(A|B)P(B) = P(B|A)P(A)
– Note: we often write P(A, B) as a shorthand for P(A ∧ B)
• This called Product Rule.
Bayes Rule
• Bayes rule is another alternative formulation of the product rule:
• Data mining
• Fuzzy logic
• Dempster -shafer theory