0% found this document useful (0 votes)
24 views42 pages

Lec 4 (3 - Part2)

Uploaded by

h.khaled
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)
24 views42 pages

Lec 4 (3 - Part2)

Uploaded by

h.khaled
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/ 42

Introduction to Logic

Direct Deduction

Prof. Ammar Mohammed


Logical Entailment

A set of premises D logically entails a conclusion j (D |= j)


if and only if every interpretation that satisfies D also
satisfies j.
Truth Table Method

Premises Conclusion
m p q m p q
T T T T T T
T T F T T F
T F T T F T
T F F T F F
F T T F T T
F T F F T F
F F T F F T
F F F F F F

With n constants, there are 2n truth assignments.


Entailment in Wumpus World
Wumpus World
• In the square where the Wumpus is and those next to it there is stench.
• In the square next to a pit there is a breeze.
• In the square with the gold there is glitter.
• When hitting a wall, the agent receives a bump.
• When the Wumpus dies, its howl is heard everywhere.
• Perceptions are quintuples. [Stench, Breeze, Glitter] means that there is
stench, breeze, and glitter. There is no location sensor.
• Actions: forward, turn right (90o), turn left (90o), grab an object, shoot
(only one arrow), leave the cave (only from square (1,1)).
• The agent dies, if he falls into a pit or meets the live Wumpus.
• Goal: fetch the gold and leave the cave.
• initial state: agent in (1,1), 1 Wumpus, 1 pile of gold and 3 pits, randomly
distributed.
Wumpus World

Agent’s initial knowledge base


contains the rules of the
environment: it knows that it’s
at [1,1] and it’s safe at [1,1]

percept: [none, none, none,]


Wumpus World
Exploring the Wumpus World

percept: [none, Breeze, none]


Wumpus World

percept: [none, Breeze, none, none, none]


Wumpus World
Exploring the Wumpus World

Cautious Agent will go back and then to [2,1]


Wumpus World
Exploring the Wumpus World

percept: [Stench, none, none]


Wumpus World
Exploring the Wumpus World

percept: [none, none, none]


Wumpus World
Exploring the Wumpus World
Wumpus World
Exploring the Wumpus World

percept: [Stench, Breeze, Glitter]


Wumpus World
Exploring the Wumpus World

• What are the safe moves from [1,1]?


Move to [2,1] then
• What are the safe moves from [2,1]?
B in [2,1] ⇒ P in [2,2] or [3,1]
• Move to [1,2] then
Wumpus World
Exploring the Wumpus World

• S in [1,2] => W in [1,1]


Survived in [1,1] and no S in [2,1] => W in [1,3]
No B in [1,2] => P in [3,1]
• Move to [2,2], then to [2,3]
• G in [2,3]
• Grab G and Come home
Wumpus World
Logical Reasoning
qIn each case where the agent draws a conclusion from the available
information, that conclusion is guaranteed to be correct if the available
information is correct

qThe above is the fundamental of logical reasoning


Model
Model
• We use the term “model” to represent “possible world”
• We say m is a model of a sentence α if α is true in model m

Entailment means that one thing follows logically from another. 𝛼 |= β

𝛼 |= β iff in every model in which 𝛼 is true, β is also true

if 𝛼 is true, then β must be true (informally, the truth of β is contained in the


truth of 𝛼)

E.g. KB = Ahly won and Zamalek won, α = Ahly won


Entailment
Entailment M(a)
x
x x x x x x x x xx
• A model is a formally structured world x xx xx x xx
x xxx xxx xx
with respect to which truth can be xxx x x xx x x x
xxx x x x x x x M(KB)
xx
evaluated x xxx
x x x x
x x x
x

• Then KB |= 𝛼 if M(KB) Í M(𝛼 )


Entailment in Wumpus World

• Situation after detecting nothing in


[1,1], moving right, breeze in [2,1]

• Consider possible models for “?”


(KB) assuming only pits

• 3 Boolean choices => 8 possible


models
Wumpus World
Wumpus World
Wumpus World
Wumpus World

KB + Observation
Wumpus World
Wumpus World
𝛼 = “There is no pit in [1,2] ”
1

What are the possible models of 𝛼1 ?


Wumpus World

• KB = Wumpus world rules + observations


• 𝛼1 = “There is no pit in [1,2] ”, KB |= 𝛼1, proved by model checking

Enumerate all possible models to check that 𝛼1 is true in all models in


which KB is true
Wumpus World

𝛼2 = “There is no pit in [2,2]

What are models of 𝛼2 ?


Wumpus World

• KB = wumpus world rules + observations


• 𝛼2 = “There is no pit in [2,2]”, KB ¬|= 𝛼2 proved by model checking

The inference algorithm illustrated in the previous figures called model


checking, because it enumerates all possible models to check 𝛼 is true
in all models in which KB is true
Proofs

Proofs:
Symbolic manipulation of sentences
rather than enumeration of truth assignments.

Benefits:
Proofs are usually smaller than truth tables.
Proofs can often be found with less work.
Proof Systems

Popular Types of Proof Systems:


Direct Deduction (Hilbert Systems)
Natural Deduction (Fitch)
Indirect Deduction (Resolution)

Others:
Gentzen Systems
Sequent Calculi
and so forth
Programme

Direct Proofs
Axiom Schemata
Rules of Inference
Direct Proofs
Hilbert Proof System
Soundness and Completeness
Practical Matters
Hierarchical Proofs
Metatheorems
Direct Proofs
Linear Reasoning
Schemas / Schemata
A axiom schema is an expression satisfying the
grammatical rules of our language except for the
occurrence of metavariables (written here as Greek letters)
in place of various subparts of the expression.

For example, the following expression is a schema with


metavariables φ and ψ.

φ ⇒ (ψ ⇒ φ)
Instances
An instance of a schema is a sentence obtained by
consistently substituting sentences for the metavariables in
the rule.
Schema:
φ ⇒ (ψ ⇒ φ)
Instances:
p ⇒ (q ⇒ p)
¬p ⇒ (q ⇒ ¬p)
(p ⇒ q) ⇒ ((q ⇒ r) ⇒ (p ⇒ q))
Non-Instance:
p ⇒ (q ⇒ r)
Valid Axiom Schemata

A valid axiom schema is a sentence pattern denoting an


infinite set of sentences, all of which are valid.

Reflexivity: (j Þ j)
Negation Elimination: (¬¬j Þ j)
Negation Introduction: (j Þ ¬¬j)
Tautology: (j Ú ¬j)

32
Rules of Inference
A rule of inference is a pattern of reasoning consisting of
zero or more axiom schemas, called premises, and one or
more additional schemas, called conclusions.

Try it using truth table φ⇒ψ


φ
ψ

This rule is Implication Elimination or Modus Ponens.

A rule applies to a set of sentences if and only if there is an instance of the rule in
which all of the premises are in the set. In this case, the conclusions of the instance
are the results of the rule application.
Rules of Inference for ¬ and ⇒

Implication Elimination Implication Creation


φ⇒ψ
φ ψ
ψ φ⇒ψ

Implication Distribution
(φ ⇒ (ψ ⇒ χ))
(φ ⇒ ψ) ⇒ (φ ⇒ χ)
Rule Instances
An instance of a rule of inference is the rule obtained by
consistently substituting sentences for the metavariables in
the rule.

Rule of Inference:
φ⇒ψ
φ
ψ

Instances:
p⇒q ¬p ⇒ q (p ⇒ q) ⇒ (q ⇒ r)
p ¬p p⇒q
q q q⇒r
Rule Application
Premises: Rule of Inference:
p φ⇒ψ
(p Þ q) φ
(p Þ q) Þ (q Þ r) ψ

Rule Instance 1: Rule Instance 2:


p (p ⇒ q) ⇒ (q ⇒ r)
(p ⇒ q) (p ⇒ q)
q (q ⇒ r)

Conclusion 1: Conclusion 2:
q (q Þ r)
Top Level Sentences Only!!!
Premises:
(p Þ q)
(p Þ r)

Rule of Inference: Rule Instance:


φ⇒ψ (p ⇒ q)
φ p
ψ q
Conclusion:
X (q Þ r) X No, no, no!

Rules cannot be applied to parts of sentences!!!


Linear Proof
A direct proof of a conclusion from a set of premises is a
sequence of sentences terminating in the conclusion in
which each item is either

(1) a premise,

(2) an instance of an axiom schema, or

(3) the result of applying a rule of inference to earlier items


in sequence.
Example
Given p and (p Þ q) and ((p Þ q) Þ (q Þ r)), prove r.

1. p Premise
2. pÞq Premise
3. (p Þ q) Þ (q Þ r) Premise
4. q IE: 1, 2
5. qÞr IE: 2, 3
6 r IE: 4, 5
Example

Given (p Þ q) and (q Þ r), prove (p Þ r).

1. p Þ q Premise
2. q Þ r Premise
3 p Þ (q Þ r) IC: 2
4 (p Þ q) Þ (p Þ r) ID: 4
5 (p Þ r) IE: 4, 5
Example

Given p and ¬p, prove q.

1. p Premise
2. ¬p Premise
3. ¬q Þ ¬p IC: 2
4. p Þ q IR: 3
5. q IE: 4, 1
Example

Given ¬¬p, prove p.

1. ¬¬p Premise
2. ¬¬¬¬p Þ ¬¬p IC: 1
4. ¬p Þ ¬¬¬p IR: 2
5. ¬¬p Þ p IR: 3
6 p IE: 5, 1

You might also like