Artificial Intelligence (CSE) Unit-Ii: 2.1.1 Logical Agents
Artificial Intelligence (CSE) Unit-Ii: 2.1.1 Logical Agents
UNIT-II
2.1.1 Logical Agents:
Knowledge-based agents – agents that have an explicit representation of knowledge that can be
reasoned with.
These agents can manipulate this knowledge to infer new things at the “knowledge level”
Knowledge Bases:
A Wumpus World
A Wumpus World PEAS description
Performance measure:
gold +1000, death -1000
-1 per step, -10 for using the arrow
Principle Difficulty: Agent is initially ignorant of the configuration of the environment – going
to have to reason to figure out where the gold is without getting killed!
Wumpus goal:
The agent’s goal is to find the gold and bring it back to the start square as quickly as possible,
without getting killed
1000 points reward for climbing out of the cave with the gold
1 point deducted for every action taken
10000 points penalty for getting killed
Note that in each case for which the agent draws a conclusion from the available information,
that conclusion is guaranteed to be correct if the available information is correct. This is a
fundamental property of logical reasoning.
The Wumpus Agent First Step
Later
Let’s Play
Wumpus World Characterization:
Fully Observable: No – only local perception
Deterministic: Yes – outcomes exactly specified
Episodic: No – sequential at the level of actions
Static : Yes – Wumpus and Pits do not move
Discrete: Yes
Single-agent: Yes – Wumpus is essentially a natural feature
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. Propositions can be
either true or false, but it cannot be both. Propositional logic is also called Boolean logic as it
works on 0 and 1.
Examples:
Today is Tuesday.
The Sun rises from West (False proposition)
2+2= 5(False proposition)
2+3= 5
Examples of Connectives:
(P ∧ Q) Arsalan likes football and Arsalan likes baseball.
(P ∨ Q) Arsalan is a doctor or Arsalan is an engineer.
(P ⇒ Q) If it is raining, then the street is wet.
(P ⇔ Q) I am breathing if and only if I am alive
Precedence of Connectives:
To eliminate the ambiguity we define a precedence for each operator. The “not” operator (¬)
has the highest precedence, followed by ∧ (conjunction), ∨(disjunction),⇒(implication),⇔
(biconditional).
Example:¬A ∧ B the ¬ binds most tightly, giving us the equivalent of (¬A)∧B rather than ¬
(A∧B)
Syntax of FOL:
Constants KingJohn, 2,...
Predicates Brother, >,...
Functions Sqrt, ...
Variables x, y, a, b,...
Connectives , , , ,
Equality =
Quantifiers ,
Logics in general:
Ontological Commitment:
What exists in the world — TRUTH
PL : facts hold or do not hold.
FOL : objects with relations between them that hold or do not hold
Constant Symbols:
▪ Stand for objects
▪ e.g., KingJohn, 2,...
Predicate Symbols
▪ Stand for relations
▪ e.g., Brother(Richard, John), greater_than(3,2)...
Function Symbols
▪ Stand for functions
▪ e.g., Sqrt(3) ...
Relations:
Some relations are properties: they state
some fact about a single object:
Round(ball), Prime(7).
n-ary relations state facts about two or more objects:
Married(John,Mary), LargerThan(3,2).
Some relations are functions: their value is another object: Plus(2,3), Father(Dan).
Terms:
Term = logical expression that refers to an object.
There are 2 kinds of terms:
o constant symbols: Table, Computer
o function symbols: Sqrt(3), Plus(2,3) etc
Functions can be nested:
o Pat_Grandfather(x) = father(father(x))
Terms can contain variables.
No variables = ground term.
Atomic Sentence:
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.
Atomic sentence = predicate (term1,...,termn)
Atomic sentences state facts using terms and predicate symbols P(x,y) interpreted as “x is P of y”
Examples: LargerThan(2,3) is false.
Married(Father(Richard), Mother(John)) could be true or false
Complex Sentence:
Complex sentences are made from atomic sentences using connectives
S, S1 S2, S1 S2, S1 S2, S1 S2,
Variables:
Person(John) is true or false because we give it a single argument ‘John’
We can be much more flexible if we allow variables which can take on values in a
domain. e.g., all persons x, all integers i, etc.
o E.g., can state rules like Person(x) => HasHead(x)
o or Integer(i) => Integer(plus(i,1)
Example:
All man drink coffee.
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its
scope is true for at least one instance of something.It is denoted by the logical operator ∃, which
resembles as inverted E. When it is used with a predicate variable then it is called as an
existential quantifier.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
There exists a 'x.'
For some 'x.'
For at least one 'x.'
Example:
Some boys are intelligent.
∃x: boys(x) ∧ intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.
Note:
In Existential quantifier we always use AND or Conjunction symbol (∧).
The main connective for universal quantifier ∀ is implication →.
The main connective for existential quantifier ∃ is and ∧.
Properties of Quantifiers:
In universal quantifier, ∀x∀y is similar to ∀y∀x.
In Existential quantifier, ∃x∃y is similar to ∃y∃x.
∃x∀y is not similar to ∀y∃x
Some Examples of FOL using quantifier:
1. All birds fly.
In this question the predicate is "fly(bird)." Since there are all birds who fly so it will be
represented as follows. ∀x bird(x) →fly(x)
.
2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where x=man, and y= parent. Since there is
every man so will use ∀, and it will be represented as follows: ∀x man(x) → respects (x, parent).
Forward chaining: Forward chaining is the process where it matches the set of conditions and
infer results from these conditions. It is data driven approach using which it reaches (infers) to
the goal condition.
Example: Given A (is true)
B->C
A->B
C->D
Prove D is also true.
Solution: Starting from A, A is true then B is true (A->B)
B is true then C is true (B->C)
C is true then D is true Proved (C->D)
Backward chaining: Backward chaining is the process where it performs backward search from
goal to the conditions used to get the goal. It is goal driven approach using which it reaches to
the initial condition.
Example: Given A (is true)
B->C
A->B
C->D
Prove D is also true.
Solution: Starting from D,
Let D is true then C is true (C->D)
C is true then B is true (B->C)
B is true then A is true Proved (A->B)
2.1.5 Resolution in FOL:
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e.,
proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the year
1965.Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions. Resolution
is a single inference rule which can efficiently operate on the conjunctive normal form or clausal
form.
Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known as
a unit clause.
Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said
to be conjunctive normal form or CNF.
Steps in Resolution:
Conversion of facts into first-order logic.
Negate the statement which needs to prove (proof by contradiction)
Convert FOL statements into CNF
Draw resolution graph (unification).
To better understand all the above steps, we will take an example in which we will apply
resolution.
Example:
Facts:
All peoples who are graduating are happy
All happy people smile
Some one is graduating
Prove that “Is someone smiling?” using resolution
Eliminate Implication
α⇒β≡¬α∨β
α ⇔ β ≡ (α ⇒ β) ∧ (β ⇒ α )
Example:
Eliminate Implication: α⇒β≡¬α∨β
∀x(¬ Graduating(x) ∨ happy(x))
∀x(¬happy(x) ∨ smile(x))
∃x graduating(x)
¬∃x smile(x)
Standardize variable
∀x regular(x) ∀x regular(x)
∃x busy(x) ∃y busy(y)
∃x attentive(x) ∃z attentive(z)
Example:
∀x(¬ Graduating(x) ∨ happy(x))
∀y(¬happy(y) ∨ smile(y))
∃z graduating(z)
¬ ∃w smile(w)
Example:
∀x(¬ Graduating(x) ∨ happy(x))
∀y(¬happy(y) ∨ smile(y))
∃z graduating(z)
∀w ¬ smile(w)
Example:
∀x(¬ Graduating(x) ∨ happy(x))
∀y(¬happy(y) ∨ smile(y))
4. Resolution Graph
If fact F is to be proved then it start with ¬F
It contradicts all other rules in KB
The process stop when it returns Null clause
Example:
¬ Graduating(x) ∨ happy(x)
¬happy(y) ∨ smile(y)
graduating(A)
¬ smile(w)
Resolution Graph:
2.2.1 Semantic Network:
Semantic nets were originally proposed in the early 1960 by M. Ross Quillian to represent the
meaning of English words. Semantic networks are alternative of predicate logic for knowledge
representation. In Semantic networks, we can represent our knowledge in the form of graphical
networks. This network consists of nodes representing objects and arcs which describe the
relationship between those objects. Semantic networks can categorize the object in different
forms and can also link those objects. Semantic networks are easy to understand and can be
easily extended.
Representation:
Semantic network representation consists of mainly two types of relations:
1. IS-A relation (Inheritance)
2. Kind-of-relation
Example 1: Following are some statements which we need to represent in the form of nodes and
arcs.
Example 2:
Statements
Jerry is a cat.
Jerry is a mammal
Jerry is owned by Priya.
Jerry is white colored.
All Mammals are animal.
Hendrix partitioned semantic network now comprises two partitions SA and S1. Node G is an
instance of the special class of general statements about the world comprising link statement,
form, and one universal quantifier
The partitioning of a semantic network renders them more logically adequate, in that one can
distinguish between individuals and sets of individuals and indirectly more heuristically adequate
by way of controlling the search space by delineating semantic networks.
Hendrix's partitioned semantic networks-oriented formalism has been used in building natural
language front-ends for data bases and for programs to deduct information from databases.
2.2.2 Frames:
A frame is a record like structure which consists of a collection of attributes and its values to
describe an entity in the world. A frame is analogous to a record structure, corresponding to the
fields and values of a record are the slots and slot fillers of a frame
Frames are the AI data structure which divides knowledge into substructures by representing
stereotypes situations. It consists of a collection of slots and slot values. These slots may be of
any type and sizes. Slots have names and values which are called facets.
Facets: The various aspects of a slot is known as Facets. Facets are features of frames which
enable us to put constraints on the frames.
Example: IF-NEEDED facts are called when data of any particular slot is needed.
A frame may consist of any number of slots, and a slot may include any number of facets and
facets may have any number of values. A frame is also known as slot-filter knowledge
representation in artificial intelligence.
Frames are derived from semantic networks and later evolved into our modern-day classes and
objects. A single frame is not much useful. Frames system consist of a collection of frames
which are connected. In the frame, knowledge about an object or event can be stored together in
the knowledge base. The frame is a type of technology which is widely used in various
applications including Natural language processing and machine visions.
Predicates not included on either of these lists are assumed to be unaffected by the operation.
Frame axioms are specified implicitly in STRIPS which greatly reduces amount of information
stored.
Rules:
• R1 : pickup(x)
Precondition & Deletion List: hand empty, on(x,table), clear(x)
Add List: holding(x)
• R2 : putdown(x)
Precondition & Deletion List: holding(x)
Add List: hand empty, on(x,table), clear(x)
• R3 : stack(x,y)
Precondition & Deletion List: holding(x), clear(y)
Add List: on(x,y), clear(x), hand empty
• R4 : unstack(x,y)
Precondition & Deletion List: on(x,y), clear(x), hand empty
Add List: holding(x), clear(y)
The space of POPs is smaller than TOPs and hence involve less search because in TOP it
requires six corresponding linearization.
Casual Link A B and the ordering constraints are added () ( A<B Start
< A A< Finish)
Resolve Conflict : add B<C or C<A
Goal Test:
There are no open preconditions