AI Module4
AI Module4
AI Module4
2
3
4
5
6
7
o 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:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
o 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
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
a. Syntax
b. Semantics
o 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.
8
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).
Complex Sentences:
9
o A quantifier is a language element which generates quantification, and quantification specifies the quantity of
specimen in the universe of discourse.
o These are the symbols that permit to determine or identify the range and scope of the variable in the logical
expression. There are two types of quantifier:
a. Universal Quantifier, (for all, everyone, everything)
b. Existential quantifier, (for some, at least one).
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.
o For all x
o For each x
o For every x.
Example:
Example:
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:
11
Semantics:
Semantics refers to the techniques that we use to evaluate an expression of First Order Logic in AI. These
techniques use various known relations and facts of the respective environment to deduce the boolean
value of the given First Order Logic expression.
12
Inference in FOL
• Inference in FOL is used to deduce new facts or sentences from existing sentences.
• Inference rules are the templates for generating valid arguments.
• In inference rules, the implication among all the connectives plays an important role.
13
14
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:
15
16
Difference between Propositional Logic and Predicate Logic(First order logic) :
17
Propositional Logic First Order Logic
Propositional logic is the logic that deals with a Predicate logic is an expression consisting of variables
1 collection of declarative statements which have with a specified domain. It consists of objects, relations
a truth value, true or false. and functions between the objects.
2 It is the basic and most widely used logic. Also It is an extension of propositional logic covering
known as Boolean logic. predicates and quantification.
3 A proposition has a specific truth value, either A predicate’s truth value depends on the variables’
true or false. value.
18
19
Reoresent it in bottom layer
20
21
22
23
Agents based on Propositional Logic
The Wumpus world problem depicts the value of a knowledge-based agent and the interpretation of that
knowledge with the help of reasoning and planning.
The Wumpus world is a 4x4 cave with 16 rooms connected to each other through passageways. The knowledge-
based agent goes forward in this world.
In Wumpus World:
• The cave has a room with a Wumpus, and the game is over when the agent enters the room; however, the
Wumpus stays in one room.
24
• The agent is given a single arrow that can be used to kill the Wumpus.
• There are some “Pits” rooms in the cave, and if the agent falls in a Pit, they will be stuck there forever.
Goal
• The cave has one room with the possibility of a heap of gold. The agent’s goal is to find this gold.
How to “win” it
The agent has to find the gold and climb out of the cave without:
The following are the moves an agent can make once they enter the cave:
25
• Forward
• Left
• Right
• Grab
• Shoot
Environment
Performance measure
• 1000 reward points if the agent successfully comes out of the cave with gold
• -1000 points penalty if the agent falls in the Pit or is eaten by Wumpus
• -1 for each action
• -10 for using an arrow
26
Figure 1
27
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e., proofs by contradictions.
28
29
Conjunctive normal form (CNF) is an approach to Boolean logic that expresses formulas as conjunctions of
clauses with an AND or OR.
30
31
32
33