AI Module4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

1

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

Syntax of First-Order logic:

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.

o Following are the basic elements of FOL syntax:

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).

Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).


Chinky is a cat: => cat (Chinky).

Complex Sentences:

o Complex sentences are made by combining atomic sentences using connectives.

Quantifiers in First-order logic:

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.

The Universal quantifier is represented by a symbol.

If x is a variable, then ∀x is read as:

o For all x
o For each x
o For every x.

Example:

Example:

1. All birds fly.


In this question the predicate is "fly(bird)."
And 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.
10
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).

3. Not all students like both Mathematics and Science.


In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)]

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:

o There exists a 'x.'


o For some 'x.'
o For at least one 'x.'

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.

Predicate logic helps analyze the scope of the subject


over the predicate. There are three quantifiers :
4 Scope analysis is not done in propositional logic. Universal Quantifier (∀) depicts for all, Existential
Quantifier (∃) depicting there exists some and
Uniqueness Quantifier (∃!) depicting exactly one.

Propositions are combined with Logical


Operators or Logical Connectives like
5 Predicate Logic adds by introducing quantifiers to the
Negation(¬), Disjunction(∨), Conjunction(∧),
existing proposition.
Exclusive OR(⊕), Implication(⇒), Bi-Conditional
or Double Implication(⇔).

6 It is a more generalized representation. It is a more specialized representation.

7 It can deal with set of entities with the help of


It cannot deal with sets of entities.
quantifiers.

18
19
Reoresent it in bottom layer

20
21
22
23
Agents based on Propositional Logic

Wumpus world problem

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.

What is the Wumpus world problem in AI?

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:

• Falling into Pits


• Getting eaten by Wumpus

Additional components to help agent (sensors)

Sensors help the agent move forward successfully.

• Rooms adjacent to the Wumpus have some stench.


• If the agent is adjacent to a Pit, then he will perceive a breeze.
• A room with glitter has gold in it.
• Wumpus will scream*= when it is killed, which can be heard anywhere in the cave.
• The agent will feel a bump when they hit a wall.

Wumpus world cave problem

Moves agent can make (actuators)

The following are the moves an agent can make once they enter the cave:

25
• Forward
• Left
• Right
• Grab
• Shoot

Environment

The game has:

• A 4x4 grid (16 rooms).


• The agent starts with the room square [1, 1] and facing towards the right.
• Wumpus and gold can be anywhere except for the first square [1,1].
• Any room of the cave can be a Pit, except for the first square.

Performance measure

The performance of the agent is measured on the following basis:

• 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

Properties of the Wumpus World

• The game is comprised of a single agent.


• The agent can perceive the close environment that is the room adjacent to them.
• The outcomes of the Wumpus World Problem are already known.
• The order in the Wumpus World Problem is important.
• Only the agent can move, so the conditions stay constant throughout the game.

26
Figure 1

Wumpus world problem using propositional logic

From figure 1 a & b

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

You might also like