propositional logic: semantics and an examplekevinlb/teaching/cs322 - 2008-9... · 2018-09-26 ·...
TRANSCRIPT
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Logic: Semantics and an Example
CPSC 322 – Logic 2
Textbook §5.2
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 1
Recap: Syntax PDC: Semantics Using Logic to Model the World
Lecture Overview
1 Recap: Syntax
2 Propositional Definite Clause Logic: Semantics
3 Using Logic to Model the World
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 2
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Syntax
Definition (atom)
An atom is a symbol starting with a lower case letter
Definition (body)
A body is an atom or is of the form b1 ∧ b2 where b1 and b2 arebodies.
Definition (definite clause)
A definite clause is an atom or is a rule of the form h← b where his an atom and b is a body. (Read this as “h if b.”)
Definition (knowledge base)
A knowledge base is a set of definite clauses
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 3
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Syntax
Definition (atom)
An atom is a symbol starting with a lower case letter
Definition (body)
A body is an atom or is of the form b1 ∧ b2 where b1 and b2 arebodies.
Definition (definite clause)
A definite clause is an atom or is a rule of the form h← b where his an atom and b is a body. (Read this as “h if b.”)
Definition (knowledge base)
A knowledge base is a set of definite clauses
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 3
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Syntax
Definition (atom)
An atom is a symbol starting with a lower case letter
Definition (body)
A body is an atom or is of the form b1 ∧ b2 where b1 and b2 arebodies.
Definition (definite clause)
A definite clause is an atom or is a rule of the form h← b where his an atom and b is a body. (Read this as “h if b.”)
Definition (knowledge base)
A knowledge base is a set of definite clauses
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 3
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Syntax
Definition (atom)
An atom is a symbol starting with a lower case letter
Definition (body)
A body is an atom or is of the form b1 ∧ b2 where b1 and b2 arebodies.
Definition (definite clause)
A definite clause is an atom or is a rule of the form h← b where his an atom and b is a body. (Read this as “h if b.”)
Definition (knowledge base)
A knowledge base is a set of definite clauses
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 3
Recap: Syntax PDC: Semantics Using Logic to Model the World
Lecture Overview
1 Recap: Syntax
2 Propositional Definite Clause Logic: Semantics
3 Using Logic to Model the World
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 4
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Semantics
Semantics allows you to relate the symbols in the logic to thedomain you’re trying to model.
Definition (interpretation)
An interpretation I assigns a truth value to each atom.
We can use the interpretation to determine the truth value ofclauses and knowledge bases:
Definition (truth values of statements)
A body b1 ∧ b2 is true in I if and only if b1 is true in I and b2
is true in I.
A rule h← b is false in I if and only if b is true in I and h isfalse in I.
A knowledge base KB is true in I if and only if every clausein KB is true in I.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 5
Recap: Syntax PDC: Semantics Using Logic to Model the World
Propositional Definite Clauses: Semantics
Semantics allows you to relate the symbols in the logic to thedomain you’re trying to model.
Definition (interpretation)
An interpretation I assigns a truth value to each atom.
We can use the interpretation to determine the truth value ofclauses and knowledge bases:
Definition (truth values of statements)
A body b1 ∧ b2 is true in I if and only if b1 is true in I and b2
is true in I.
A rule h← b is false in I if and only if b is true in I and h isfalse in I.
A knowledge base KB is true in I if and only if every clausein KB is true in I.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 5
Recap: Syntax PDC: Semantics Using Logic to Model the World
Models and Logical Consequence
Definition (model)
A model of a set of clauses is an interpretation in which all theclauses are true.
Definition (logical consequence)
If KB is a set of clauses and g is a conjunction of atoms, g is alogical consequence of KB, written KB |= g, if g is true in everymodel of KB.
we also say that g logically follows from KB, or that KBentails g.
In other words, KB |= g if there is no interpretation in whichKB is true and g is false.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 6
Recap: Syntax PDC: Semantics Using Logic to Model the World
Models and Logical Consequence
Definition (model)
A model of a set of clauses is an interpretation in which all theclauses are true.
Definition (logical consequence)
If KB is a set of clauses and g is a conjunction of atoms, g is alogical consequence of KB, written KB |= g, if g is true in everymodel of KB.
we also say that g logically follows from KB, or that KBentails g.
In other words, KB |= g if there is no interpretation in whichKB is true and g is false.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 6
Recap: Syntax PDC: Semantics Using Logic to Model the World
Example: Models
KB =
p← q.q.r ← s.
p q r sI1 true true true true Which interpretations are models?I2 false false false false
not a model of KB
I3 true true false false
is a model of KB
I4 true true true false
is a model of KB
I5 true true false true
not a model of KB
Which of the following is true?
KB |= q, KB |= p, KB |= s, KB |= r
KB |= q, KB |= p, KB 6|= s, KB 6|= r
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 7
Recap: Syntax PDC: Semantics Using Logic to Model the World
Example: Models
KB =
p← q.q.r ← s.
p q r sI1 true true true true is a model of KBI2 false false false false not a model of KBI3 true true false false is a model of KBI4 true true true false is a model of KBI5 true true false true not a model of KB
Which of the following is true?
KB |= q, KB |= p, KB |= s, KB |= r
KB |= q, KB |= p, KB 6|= s, KB 6|= r
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 7
Recap: Syntax PDC: Semantics Using Logic to Model the World
Example: Models
KB =
p← q.q.r ← s.
p q r sI1 true true true true is a model of KBI2 false false false false not a model of KBI3 true true false false is a model of KBI4 true true true false is a model of KBI5 true true false true not a model of KB
Which of the following is true?
KB |= q, KB |= p, KB |= s, KB |= r
KB |= q, KB |= p, KB 6|= s, KB 6|= r
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 7
Recap: Syntax PDC: Semantics Using Logic to Model the World
Example: Models
KB =
p← q.q.r ← s.
p q r sI1 true true true true is a model of KBI2 false false false false not a model of KBI3 true true false false is a model of KBI4 true true true false is a model of KBI5 true true false true not a model of KB
Which of the following is true?
KB |= q, KB |= p, KB |= s, KB |= r
KB |= q, KB |= p, KB 6|= s, KB 6|= r
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 7
Recap: Syntax PDC: Semantics Using Logic to Model the World
Lecture Overview
1 Recap: Syntax
2 Propositional Definite Clause Logic: Semantics
3 Using Logic to Model the World
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 8
Recap: Syntax PDC: Semantics Using Logic to Model the World
User’s view of Semantics
1 Choose a task domain: intended interpretation.
2 Associate an atom with each proposition you want torepresent.
3 Tell the system clauses that are true in the intendedinterpretation: axiomatizing the domain.
4 Ask questions about the intended interpretation.
5 If KB |= g, then g must be true in the intendedinterpretation.
6 The user can interpret the answer using their intendedinterpretation of the symbols.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 9
Recap: Syntax PDC: Semantics Using Logic to Model the World
Computer’s view of semantics
The computer doesn’t have access to the intendedinterpretation.
All it knows is the knowledge base.
The computer can determine if a formula is a logicalconsequence of KB.
If KB |= g then g must be true in the intended interpretation.If KB 6|= g then there is a model of KB in which g is false.This could be the intended interpretation.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 10
Recap: Syntax PDC: Semantics Using Logic to Model the World
Electrical Environment
light
two-wayswitch
switch
off
on
poweroutlet
circuit�breaker
outside power
�
l1
l2
w1
w0
w2
w4
w3
w6
w5
p2
p1
cb2
cb1s1
s2s3
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 11
Recap: Syntax PDC: Semantics Using Logic to Model the World
Representing the Electrical Environment
light l1.
light l2.
down s1.
up s2.
up s3.
ok l1.
ok l2.
ok cb1.
ok cb2.
live outside.
live l1 ← live w0
live w0 ← live w1 ∧ up s2.
live w0 ← live w2 ∧ down s2.
live w1,← live w3 ∧ up s1.
live w2 ← live w3 ∧ down s1.
live l2 ← live w4.
live w4 ← live w3 ∧ up s3.
live p1 ← live w3.
live w3 ← live w5 ∧ ok cb1.
live p2 ← live w6.
live w6 ← live w5 ∧ ok cb2.
live w5 ← live outside.
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 12
Recap: Syntax PDC: Semantics Using Logic to Model the World
Role of semantics
In user’s mind:
l2 broken: light l2 isbroken
sw3 up: switch is up
power: there is power inthe building
unlit l2: light l2 isn’t lit
lit l1: light l1 is lit
In Computer:
l2 broken← sw3 up
∧power ∧ unlit l2.
sw3 up.
power ← lit l1.
unlit l2.
lit l1.
Conclusion: l2 broken
The computer doesn’t know the meaning of the symbols
The user can interpret the symbols using their meaning
Propositional Logic: Semantics and an Example CPSC 322 – Logic 2, Slide 13