0% found this document useful (0 votes)
15 views

14 Propositional Logic I

The document discusses knowledge representation and reasoning in artificial intelligence. It describes how knowledge bases for AI agents can be represented using logic and sentences. It then provides details on propositional logic, including its syntax, semantics, and how it can be used to represent knowledge about the Wumpus world domain.

Uploaded by

Sami Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

14 Propositional Logic I

The document discusses knowledge representation and reasoning in artificial intelligence. It describes how knowledge bases for AI agents can be represented using logic and sentences. It then provides details on propositional logic, including its syntax, semantics, and how it can be used to represent knowledge about the Wumpus world domain.

Uploaded by

Sami Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Dr.

Shahnawaz Qureshi
Humans know things …
 the knowledge helps them to do various tasks.

 The knowledge has been achieved


◦ not by purely reflex mechanisms
◦ but by the processes of reasoning
 In AI, the example is knowladge-based agent which
contains set of sentences referred as knowledge-base.

3
For a generic knowledge-based agent:

 A percept is given to the agent.

 The agent adds the percept to its knowledge base.

 Perform best action according to the knowledge base.

 Tells the knowledge base that it has in fact taken that


action.

4
constructs a sentence asserting that the agent
perceived the given percept at time t
constructs a sentence that asks what action
should be done at time t
constructs a sentence that the chosen action
was executed at time t
5
6
7
The PEAS description for Wumpus World:
Performance measure:
 +1000 for climbing out of the cave with the gold,
 –1000 for falling into a pit or being eaten by the Wumpus,
 –1 for each action taken
 –10 for using up the arrow
Environment:
 A 4×4 grid of rooms. The agent starts in the square labelled
[1,1], facing to the right.
The game ends either when the agent dies or when the
agent climbs out of the cave.

8
The PEAS description for Wumpus World:
Actuators:
 The agent can move Forward, TurnLeft by 90◦, TurnRight by
90◦, grab, shoot
Sensors:
 The square adjacent directly (not diagonally) to the square
containing Wumpus, the agent will perceive a Stench.
 The squares adjacent to a pit, the agent will perceive a
Breeze.
 The square with gold, the agent will perceive a Glitter.
 An agent walks into a wall, it will perceive a Bump.
 When the Wumpus is killed, it emits a woeful Scream.

9
10
B

11
P

12
S
P

13
W
S OK
P

14
W
S OK
P

15
BGS OK
W
S OK OK
P

16
17
 The knowledge bases consist of sentences.

How to represent these sentances?

 Logic, a formal language, is the solution --- a way of


manipulating expressions in the language.

 Logic has
◦ Syntax
◦ Semantics

19
Syntax:
What expressions are legal --- what are allowed to write
down.
 The notion of syntax is clear enough with the example:
“𝑥 + 𝑦 = 4” is a well-formed sentence, whereas
“𝑥4𝑦+ =” is not.
Semantics:
What legal expression means --- meaning of sentences
 the sentence “𝑥 + 𝑦 = 4” is true in a world where 𝑥 is 2
and 𝑦 is 2, but false in a world where 𝑥 is 1 and 𝑦 is 1.
 Syntax is a form and semantics is the content.

20
Semantics:
 The semantics defines the truth of each sentence with
respect to each possible world.

 The term model can be used in place of “possible


world.”

 If a sentence 𝜶 is true in model 𝒎, we say that 𝒎


satisfies 𝜶 or sometimes 𝒎 is a model of 𝜶.

 The notation 𝑴(𝜶) --- the set of all models of 𝜶.

21
Entailment:
 means that one thing follows from another:

𝜶╞𝜷

 if and only if, in every model in which 𝜶 is true, 𝜷 is


also true. We can write

 The notation ⊆ means that: if 𝜶 ╞ 𝜷, then 𝜶 is a


stronger assertion than 𝜷

22
 We say 𝒎 is a model of sentence 𝜶 if 𝜶 is true in 𝒎

 𝑴(𝜶) is the set of all models of 𝜶

Then 𝑲𝑩 ╞ 𝜶 iff 𝑴(𝑲𝑩) ⊆ 𝑴(𝜶)

Example:
 The sentence 𝒙 = 𝟎 entails the sentence 𝒙𝒚 = 𝟎
◦ In any model where 𝒙 is zero, it is the case that 𝒙𝒚 is zero
(regardless of the value of 𝒚)

23
 Situation after detecting
nothing in [1,1], moving
right, breeze in [1,2]

 Consider possible models for


KB assuming only pits

 3 Boolean choices  8
possible models

24
3 Boolean choices  8 possible models
regardless of wumpus-world rules
25
KB = wumpus-world rules + observations

26
𝑲𝑩 = wumpus-world rules + observations
𝜶𝟏 = "[1,2] is safe", 𝑲𝑩 ╞ 𝜶𝟏 , proved by model checking
27
𝑲𝑩 = wumpus-world rules + observations
𝜶𝟐 = "[2,2] is safe", 𝑲𝑩 ╞ 𝜶𝟐
28
 If an inference algorithm 𝒊 can derive 𝜶 from 𝑲𝑩, we write

 which is pronounced “𝜶 is derived from 𝑲𝑩 by 𝒊” or


“𝒊 derives 𝜶 from 𝑲𝑩.”
Soundness:
 An inference algorithm that derives only entailed
sentences is called sound or truth preserving.
 Soundness is a highly desirable property.
Completeness:
 An inference algorithm is complete if it can derive any
sentence that is entailed.

29
 We'll look at two kinds of logic:

Propositional Logic
which is relatively simple.

First-order Logic
which is more complicated.

30
 The syntax of propositional logic defines the allowable
sentences.

What are the sentances?

 Sentance are well formed formulas


 True and False are sentances
 Propositional variables are sentences. P, Q, R, S etc.

32
 The atomic sentences consist of a single proposition
symbol.
 Each such symbol stands for a proposition that can be
True or False.
 The complex sentences are constructed from simpler
sentences, using parentheses and logical connectives.
 There are five connectives in common use:
¬ (not), ∧ (and), ∨ (or),
⇒ (implies), ⇔ (if and only if)

33
 ¬ (not) A sentence such as ¬W1,3 is called the
negation of W1,3.
◦ A literal is either an atomic sentence (a positive literal) or a
negated atomic sentence (a negative literal).
 ∧ (and) A sentence whose main connective is ∧, such
as W1,3 ∧ P3,1, is called a conjunction; its parts are the
conjuncts.
 ∨ (or) A sentence using ∨, such as (W1,3 ∧ P3,1) ∨ W2,2,
is a disjunction of the disjuncts (W1,3 ∧ P3,1) and W2,2.

34
 ⇒ (implies) A sentence such as (W1,3∧P3,1) ⇒ ¬W2,2 is
called an implication (or conditional). The premise or
antecedent is (W1,3 ∧P3,1).
 Implications are also known as rules or if–then
statements.
 The implication symbol is sometimes written as ⊃ or →
or ⇒.
 ⇔ (if and only if) The sentence W1,3 ⇔ ¬W2,2 is a bi-
conditional. Sometime it is written as ≡.

35
36
37
Precedence Example:

38
 The semantics defines the rules for determining the
truth value of a sentence with respect to a particular
model.
 In propositional logic, a model simply fixes the truth
value—true or false—for every proposition symbol
For example:
 If the sentences in the knowledge base make use of
the proposition symbols P1,2, P2,2, and P3,1, then one
possible model is:

39
 The semantics for propositional logic must specify how
to compute the truth value of any sentence, given a
model.
For Atomic sentences:
 True is true in every model and False is false in every
model.
 The truth value of every other proposition symbol must
be specified directly in the model.
◦ For example, in the model 𝒎𝟏 given earlier, P1,2 is false.

40
For complex sentences
 We have five rules, which hold for any sub-sentences 𝑷
and 𝑸 in any model 𝒎

41
 The propositional logic does not require any relation
of causation or relevance between P and Q.
◦ For example, the sentence “5 is odd implies Tokyo is the
capital of Japan” is a true sentence of propositional logic,
even though it is not a well-formed English sentence.

 In case of implication, any implication is true


whenever its antecedent is false.
◦ For example, “5 is even implies Sam is smart” is true,
regardless of whether Sam is smart or not.

42
43
 With propositional logic, we can construct a knowledge
base for the Wumpus world.

For Example:

44
 There is no pit in [1,1]:

 A square is breezy if and only if there is a pit in a


neighbouring square. This has to be stated for each
square; for now, we include just the relevant squares:

45
46
 Artificial Intelligence, A Modern Approach
Stuart J. Russell and Peter Norvig
◦ Chapter 7.

47
48

You might also like