Download Propositional Logic Lecture 11: Syntax and Semantics of Propositional Logic - Prof. Bruce and more Study notes Computer Science in PDF only on Docsity!
Propositional Logic
Propositional Logic
Lecture #11Lecture
Announcements
Announcements
Programming assignment #1 is due before the
Programming assignment #1 is due before the
next class
next class
- – Java timer info:Java timer info:
http://http://java.sun.com/docs/books/tutorial/uiswing/misc/tijava.sun.com/docs/books/tutorial/uiswing/misc/ti
mer.htmlmer.html
- – Qt timerQt timer info:info: http://doc.trolltech.com/4.2/timers.htmlhttp://doc.trolltech.com/4.2/timers.html
- Any questions?Any questions?
We need to schedule a midterm date
We need to schedule a midterm date……
- – It will be scheduled on ThursdayIt will be scheduled on Thursday
- – If you have any conflicts, know them by then!If you have any conflicts, know them by then!
ACM Club, Wednesday 5:00 110 USC ACM Club, Wednesday 5:00 110 USC
- – ““So what is thisSo what is this unixunix thing, anyway?thing, anyway?””
Logic
Logic
A
A
logic
logic
is a formal system of reasoning. It
is a formal system of reasoning. It
must have:
must have:
1.1. SyntaxSyntax , which describes the sentences of, which describes the sentences of
the logical language
the logical language
2.2. SemanticsSemantics , which assign meanings to, which assign meanings to
sentencessentences
Models
Models , which are possible worlds the
, which are possible worlds the
semantics might describe.semantics might describe.
Propositional Logic
Propositional Logic
Propositional logic is a simple logic based
Propositional logic is a simple logic based
on
on
propositions
propositions
- – Propositions are indivisiblePropositions are indivisible
- Propositions are eitherPropositions are either true
true or
or false
false
Examples of propositions Examples of propositions
- Your textbook is greenYour textbook is green
- – The sky is fallingThe sky is falling
SyntaxSyntax
The proposition symbols PThe proposition symbols P
11
, P, P
22
etc areetc are
atomic sentencesatomic sentences
If S is a sentence,If S is a sentence, ¬¬S is a sentenceS is a sentence
(negation(negation))
If S
If S
11
and S
and S
22
are sentences, (S
are sentences, (S
11
∧
∧ S
S
22
)
) is a sentenceis a sentence
(conjunction(conjunction))
If SIf S 11
and Sand S
22
are sentences, (Sare sentences, (S
11
∨∨ SS
22
)) is a sentenceis a sentence
(
(disjunctiondisjunction))
If SIf S 11
and Sand S
22
are sentences, (Sare sentences, (S
11
⇒⇒ SS
22
)) is a sentenceis a sentence
(implication(implication))
If SIf S 11
and Sand S
22
are sentences, (Sare sentences, (S
11
⇔⇔ SS
22
) is a sentence)is a sentence
(biconditional(biconditional))
Syntax : Backus-Syntax : Backus-Naur FormNaur Form
SentenceSentence →→ AtomicSentenceAtomicSentence
SentenceSentence →→ ComplexSentenceComplexSentence
AtomicSentenceAtomicSentence →→ T |T | ⊥⊥ || SymbolSymbol
ComplexSentenceComplexSentence →→ ¬¬ SentenceSentence
→ → (( SentenceSentence ^^ SentenceSentence ))
→ → (( SentenceSentence vv SentenceSentence ))
→ → (( SentenceSentence ⇒⇒ SentenceSentence ))
→ → (( SentenceSentence ⇔⇔ SentenceSentence ))
Semantics
Semantics
SS
11
& S& S
22
have the same valuehave the same value
(true or false)
(true or false)
(S(S
11
⇔⇔ SS
22
S
S
1
1
is false or S
is false or S
2
2
is true
is true (S
(S
11
S
S
22
At least one of SAt least one of S
11
or Sor S
22
(S(S is trueis true 11
v Sv S
22
SS
11
is true and Sis true and S
22
(S(S is trueis true 11
^ S^ S
22
S is false
S is false ¬
S
S
S is true
S is true S
S
This sentenceThis sentence…… … is true when ( …is true when (iffiff))
Semantics : Truth Tables
Semantics : Truth Tables
The semantics of any operator can be The semantics of any operator can be
expressed as a truth-expressed as a truth-tabletable
T
T
TT T T
TT ⊥⊥ ⊥⊥
TT TT TT
S
S
11
S
S
22
S
S
2
2
S
S
1
1
⊥⊥ ⊥⊥ TT
T
T
TT ⊥⊥ ⊥⊥
TT TT TT
SS
11
⇔⇔SS
22
S
S
22
S
S
11
Truth Tables (II)
Truth Tables (II)
How many (binary) operators are there?
How many (binary) operators are there?
- – And how do you know?And how do you know?
ExpressExpress ¬¬ as a binary operatoras a binary operator
TT
⊥⊥ TT TT
TT ⊥⊥ ⊥⊥
T
T
T
T
¬¬SS
11
SS
22
SS
11
2
4
= 16 (pigeon-hole principle)
Models
Models
Models
Models
are a mapping of propositions onto
are a mapping of propositions onto
{T,
{T,
Axioms
Axioms
are a set of (simple & complex)
are a set of (simple & complex)
sentences that are asserted to be truesentences that are asserted to be true
- – Without proofWithout proof
A set of axiomsA set of axioms entailsentails a sentencea sentence iffiff thethe
sentence is true for every model in which thesentence is true for every model in which the
axioms are true
axioms are true
Question
Question
Do the axioms {A
Do the axioms {A
B, B} entail {A}?
B, B} entail {A}?
- Written as {–Written as {AA⇒⇒B, B}B, B} ├├ {A}{A}
- How do you know if this is true?How do you know if this is true?
Truth Tables!
TT ⊥⊥ ⊥⊥ TT
⊥⊥ TT TT ⊥⊥
TT TT TT TT
AA
(A
(A
B)^B
AA BB B)^B
No, {A} is not
entailed
EntailmentEntailment
The goal is to infer the truth value of a The goal is to infer the truth value of a
predicate from a set of axioms {A, B
predicate from a set of axioms {A, B……}}
- – If {A, BIf {A, B……}} ├├ P, then we know P is trueP, then we know P is true
P, then we know P is false
P, then we know P is false
- – Otherwise, the value of P is unknownOtherwise, the value of P is unknown
The problem is that using truth tables to The problem is that using truth tables to
determine entailment is exponentially
determine entailment is exponentially
expensive.expensive.
Example of proof by negation
Example of proof by negation
ProveProve reductioreductio adad absurdamabsurdam ::
- – {({(pp⇒⇒qq), (), (pp⇒¬⇒¬qq)})}├├ ¬¬pp
Proof:Proof:
q
q), (), (pp ⇒¬
q
q), p}), p}
(q ^
(q ^ ¬
q)
CombinationCombination q) q,
q, ¬
q
q
((pp⇒¬⇒¬q), pq), p Modus PonensModus Ponens ¬¬qq
q
q Modus Ponens
Modus Ponens (
(pp ⇒
q
q), p), p
PrecedentPrecedent RuleRule AnticedentAnticedent
The
The WumpusWumpus WorldWorld
The
The WumpusWumpus WorldWorld
Performance measurePerformance measure
- – gold: +1000, death:gold: +1000, death: --1000 1000
- – --1 per step,1 per step, --10 for using the arrow10 for using the arrow
EnvironmentEnvironment
- Squares adjacent toSquares adjacent to wumpuswumpus: smelly: smelly
- – Squares adjacent to pit: breezySquares adjacent to pit: breezy
- – GlitterGlitter iffiff gold is in the same squaregold is in the same square
- – Shooting killsShooting kills wumpuswumpus if you are facing itif you are facing it
- – Shooting uses up the only arrowShooting uses up the only arrow
- – Grabbing picks up gold if in same squareGrabbing picks up gold if in same square
- – Square [1,1] is emptySquare [1,1] is empty
Sensors:
Sensors: Stench, Breeze, Glitter, BumpStench, Breeze, Glitter, Bump
Actuators:Actuators: Left turn, Right turn, Forward, Grab,Left turn, Right turn, Forward, Grab,
Release,ShootRelease,Shoot
The
The WumpusWumpus WorldWorld
EnvironmentEnvironment
Fully Observable? No, only local perception Fully Observable? No, only local perception
Deterministic? Yes, outcome exactly specified
Deterministic? Yes, outcome exactly specified
Static? Yes, Wumpus Static? Yes,Wumpus and pits do not moveand pits do not move
Discrete? Yes Discrete? Yes
Single- Single-agent? Yesagent? Yes
The question is:
can we use logic to solve this problem?
Wumpus LogicWumpusLogic
LetLet PP
x,yx,y
be the proposition that square (be the proposition that square (x,yx,y))
has a pit.
has a pit.
Let
Let WW
x,yx,y
be the proposition that the
be the proposition that the
wumpuswumpus is in square (is in square (x,yx,y))
Then we have the following axioms:Then we have the following axioms:
¬¬WW
1,11,
,, ¬¬PP
1,11,
BB
x,yx,y
⇔⇔ (P(P
x,y+1x,y+
v Pv P
x,yx,y--1 1
v Pv P
x+1,yx+1,y
v Pv P
x-x-1,y1,y
S
S
x,yx,y
(W
(W
x,y+1x,y+
v W
v W
x,yx,y--1 1
v W
v W
x+1,yx+1,y
v W
v W
xx--1,y1,y
WW
1,11,
v Wv W
1,21,
vv …… v Wv W
4,34,
v Wv W
4,44,
Wumpus
Wumpus (II)(II)
If sensors in square [1,1] detect neither If sensors in square [1,1] detect neither
breeze nor smell, what do we know?breeze nor smell, what do we know?
¬ ¬PP
1,21,
((¬¬PP SimplificationSimplification
1,21,
^^ ¬¬ PP
2,12,
((¬¬PP
1,21,
^^ ¬¬ PP
2,12,
DeMorgans ))
DeMorgans ¬¬(P(P
1,21,
v Pv P
2,12,
P
P
2,12,
Simplification
Simplification (
P
P
1,21,
^
^
P
P
2,12,
(P
(P
1,21,
v P
v P
2,12,
Modus
Modus
TollensTollens
B
B
1,11,
BB
1,11,
⇔⇔ (P(P
1,21,
v Pv P
2,12,
Anticedent
Anticedent Rule
Rule Precedent
Precedent