Chapter 4-Knowledge and Reasoning
Chapter 4-Knowledge and Reasoning
The central component of a knowledge-based agent is its knowledge base, or KB. A knowledge base is
a set of sentences expressed in a language called a knowledge representation language and
represents some assertion about the world. Sometimes we dignify a sentence with the name axiom,
when the sentence is taken as given without being derived from other sentences.
There must be a way to add new sentences to the knowledge base and a way to query what is known.
The standard names for these operations are TELL and ASK, respectively. Both operations may involve
inference—that is, deriving new sentences from old. Inference must obey the requirement that when
one ASKs a question of the knowledge base, the answer should follow from what has been told (or
TELLed) to the knowledge base previously.
Knowledge-based agent program takes a percept as input and returns an action. The agent maintains
a knowledge base, KB, which may initially contain some background knowledge. Each time the agent
program is called, it does three things.
First, it TELLs the knowledge base what it perceives.
Second, it ASKs the knowledge base what action it should perform.
Third, the agent program TELLs the knowledge base which action was chosen, and the agent
executes the action.
The details of the representation language are hidden inside three functions that implement the
interface between the sensors and actuators on one side and the core representation and reasoning
system on the other.
MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent perceived the given
percept at the given time.
MAKE-ACTION-QUERY constructs a sentence that asks what action should be done at the
current time.
MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen action was
executed.
Knowledge base sentences are expressed according to the syntax of the representation language,
which specifies all the sentences that are well formed.
A logic defines the semantics or meaning of sentences. The semantics defines the truth of each
sentence with respect to each possible world. When we need to be precise, we use the term
model in place of “possible world.” For example, the sentence x + y =4 is true when there are four
possible assignments of real numbers to the variables x and y. If a sentence α is true in model m,
we say that m satisfies α or sometimes m is a model of α. We use the notation M(α) to mean the
set of all models of α.
Logical reasoning involves the relation of logical entailment between sentences—the idea that a
sentence follows logically from another sentence. The formal definition of entailment is this: α ⊧ β
if and only if, in every model in which α is true, β is also true. Using the notation just introduced,
we can write α ⊧ β if and only if M(α) ⊆ M(β).
Example: the sentence x = 0 entails the sentence xy = 0.
4.2. Propositional Logic
Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions. A proposition is a declarative statement which is either true or false. It is a technique of
knowledge representation in logical and mathematical form.
Propositional logic 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 representing a proposition,
such as 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. Statements which are questions,
commands, or opinions are not propositions such as "Where is your brother?", "How are you?",
"What is your name?", are not propositions.
NEGATION ¬ (not).
∧ (and). A sentence whose main connective is ∧, is called a conjunction;
∨ (or). A sentence using ∨ is a disjunction;
⇒ (implies). A sentence with ⇒ is called an implication. Implications are also known as rules or
if–then statements.
⇔ (if and only if). The sentence with ⇔ is a bi-conditional.
Operator precedence of propositional logic is: ¬, ∧, ∨,⇒,⇔
The syntax of propositional logic defines the allowable sentences for the knowledge representation.
There are two types of Propositions:
Atomic Propositions consists of a single proposition symbol. These are the sentences which
must be either true or false.
o Example: 2+2 is 4, is an atomic proposition as it is a true fact.
Compound propositions are constructed by combining simpler or atomic propositions, using
parenthesis and logical connectives.
o Example: "It is raining today, and street is wet."
Example: Given three propositions P-true, Q-true and R-true, the truth value of P V Q ⇒ ¬R is False.
Two propositions are said to be logically equivalent if and only if the columns in the truth table are
identical to each other. Given two propositions A and B with both true, ¬A V B and A ⇒ B are logically
equivalent.
Properties of Operators:
o Commutativity:
o P∧ Q = Q ∧ P, or
o P ∨ Q = Q ∨ P.
o Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
o Identity element:
o P ∧ True = P,
o P ∨ True= True.
o Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
o DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
o Double-negation elimination:
o ¬ (¬P) = P.
Variables x, y, z, a, b,....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic sentences:
o 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.
o We can represent atomic sentences as Predicate (term1, term2... term n).
Example: Abebe and Tola are brothers could be written as Brothers(Abebe, Tola).
Boby is a dog could be written as dog (Boby).
Complex Sentences:
o Complex sentences are made by combining atomic sentences using connectives.
Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the statement within its
range is true for everything or every instance of a particular thing. The Universal quantifier is
represented by a symbol ∀.
If x is a variable, then ∀x is read as: For all x or For each x For every x.
Example: All man drink coffee.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as: There exists 'x.' or
For some 'x.' or For at least one 'x.'.
∃x boy(x) ∧ intelligent(x)
Examples:
All birds fly. ∀x bird(x) →fly(x).
Every man respects his parent. ∀x man(x) → respects (x, parent).
Some boys play cricket. ∃x boy(x) ∧ plays(x, cricket).
4.4. Inference in First-Order Logic
Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences.
Before understanding the FOL inference rule, let's understand some basic terminologies used in FOL.
Substitution:
Substitution is a fundamental operation performed on terms and formulas. It occurs in all inference
systems in first-order logic. The substitution is complex in the presence of quantifiers in FOL. If we
write F[a/x], so it refers to substitute a constant "a" in place of variable "x".
Equality:
First-Order logic does not only use predicate and terms for making atomic sentences but also uses
another way, which is equality in FOL. For this, we can use equality symbols which specify that the
two terms refer to the same object.
As in the above example, the object referred by the Brother (John) is similar to the object referred
by Smith. The equality symbol can also be used with negation to represent that two terms are not the
same objects.
It can be represented as
Example:
o IF "Every person like ice-cream"=> ∀x P(x) so we can infer that "John likes ice-cream" =>
P(c)
o "All kings who are greedy are Evil." So let our knowledge base contains this detail as in the
form of FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
So from this information, we can infer any of the following statements using Universal
Instantiation: King(John) ∧ Greedy (John) → Evil (John)
Existential Instantiation
Existential instantiation is also called as Existential Elimination, which is a valid inference rule
in first-order logic. It can be applied only once to replace the existential sentence. The new KB
is not logically equivalent to old KB, but it will be satisfiable if old KB was satisfiable.
This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a new
constant symbol c. The restriction with this rule is that c used in the rule must be a new term
for which P(c ) is true.
It can be represented as
Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John)
Existential introduction
An existential introduction is also known as an existential generalization, which is a valid
inference rule in first-order logic. This rule states that if there is some element c in the
universe of discourse which has a property P, then we can infer that there exists something in
the universe which has the property P.
It can be represented as
The first part, the knowledge base, represents facts about the world. The second part, the inference
engine, allows new knowledge to be inferred. Knowledge representation and reasoning (KR, KRR) is
the part of Artificial intelligence which concerned with AI agents thinking and how thinking
contributes to intelligent behavior of agents. Following are the kind of knowledge which needs to be
represented in AI systems:
o Object: All the facts about objects in our world domain. E.g., Guitars contains strings, trumpets
are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o Knowledge-Base: The central component of the knowledge-based agents is the knowledge
base. It is represented as KB. The Knowledge base is a group of the Sentences.