Logic: Semantics and Bottom

advertisement
Propositional Definite Clause
Logic: Syntax, Semantics and
Bottom-up Proofs
Jim Little
UBC CS 322 – CSP
October 20, 2014
Slide 1
Lecture Overview
• Recap: Logic intro
• Propositional Definite Clause Logic:
Semantics
• PDCL: Bottom-up Proof
Slide 2
Logic: A general framework for
reasoning
General problem: Query answering
• tell the computer how the world works
• tell the computer some facts about the world
• ask a yes/no question about whether other facts must be true
Solving it with Logic
1.
2.
3.
4.
5.
Begin with a task domain.
Distinguish those things you want to talk about (the ontology)
Choose symbols in the computer to denote elements of your ontology
Tell the system knowledge about the domain
Ask the system whether new statements about the domain are true or
false
live_w4?
lit_l2?
Slide 3
Example: Electrical Circuit
/down
/ up
Slide 4
/down
/ up
Syntax: are these sentences that a
reasoning procedure can process?
Semantics: what do these statements say
about the world I need to represent?
Slide 5
To Define a Logic We Need
• Syntax: specifies the symbols used, and how they
can be combined to form legal sentences
• Knowledge base is a set of sentences in the language
• Semantics: specifies the meaning of symbols and
sentences
• Reasoning theory or proof procedure: a
specification of how an answer can be produced.
• Sound: only generates correct answers with respect to
the semantics
• Complete: Guaranteed to find an answer if it exists
Slide 6
Propositional Definite Clauses: Syntax
Definition (atom)
An atom is a symbol starting with a lower case letter
Examples: p1;
live_l1
Definition (body)
A body is an atom or is of the form b1 ∧ b2 where b1 and b2 are bodies.
Examples: p1 ∧ p2;
ok_w1 ∧ live_w0
Definition (definite clause)
Examples: p1 ← p2;
A definite clause is
live_w0 ← live_w1 ∧ up_s2
- an atom or
- a rule of the form h ← b where h is an
atom (“head”) and b is a body. (Read this as “h if b”.)
Definition (KB)
A knowledge base (KB) is a set of definite
clauses
Slide 7
Propositional Definite Clauses:
Semantics
Definition (interpretation)
An interpretation I assigns a truth value to each atom.
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 is false in I.
• A knowledge base KB is true in I if and only if
every clause in KB is true in I.
Definition (model)
A model of a knowledge base KB is an interpretation in
which KB is true.
Similar to CSPs: a model
Slide 8of a set of clauses is
an interpretation that makes all of the clauses true
To Obtain This We Need One More Definition
Definition (logical consequence)
If KB is a set of clauses and G is a conjunction of atoms,
G is a logical consequence of KB, written KB ⊧ G, if
G is true in every model of KB.
• we also say that G logically follows from KB, or that KB
entails G.
• In other words, KB ⊧ G if there is no interpretation in which
KB is true and G is false.
• when KB is TRUE, then G must be TRUE
• We want a reasoning procedure that can find all and only the
logical consequences of a knowledge base
Slide 9
User’s View of Semantics
• Choose a task domain: intended interpretation.
• For each proposition you want to represent, associate a
proposition symbol in the language.
• Tell the system clauses that are true in the intended
interpretation: axiomatize the domain.
• Ask questions about the intended interpretation.
• If KB |= g , then g must be true in the intended interpretation.
Slide 10
Computer’s View of Semantics
• The computer doesn’t have access to the intended
interpretation.
• All it knows is the knowledge base.
• The computer can determine if a formula is a logical
consequence of KB.
• If KB |= g then g must be true in the intended interpretation.
• Otherwise, there is a model of KB in which g is false. This
could be the intended interpretation.
The computer wouldn't know!
Slide 11
Computer’s View of Semantics
• Otherwise, there is a model of KB in which g is false.
This could be the intended interpretation.
The computer wouldn't know
I1
I2
p
q
r
s
true
true
true
true
true
true
true
false
 p  q.

KB   q.
 r  s.

Slide 12
To Define a Logic We Need
• Syntax: specifies the symbols used, and how they
can be combined to form legal sentences
• Knowledge base is a set of sentences in the language
• Semantics: specifies the meaning of symbols and
sentences
• Reasoning theory or proof procedure: a
specification of how an answer can be produced
(sound and complete)
•
Bottom-up Proof Procedure for Finding Logical Consequence
Slide 13
Proof Procedures
• A proof procedure is a mechanically derivable
demonstration that a formula logically follows from a
knowledge base.
• Given a proof procedure P, KB ⊦ P g means g can be
derived from knowledge base KB with the proof procedure.
• If I tell you I have a proof procedure for PDCL
• What do I need to show you in order for you to trust my
procedure?
That is sound and complete
Slide 14
Soundness and Completeness
Definition (soundness)
A proof procedure P is sound if KB ⊦P g implies KB ⊧ g.
sound: every atom derived by P follows logically from KB
(i.e. is true in every model)
• Soundness of proof procedure P: need to prove that
If g can be derived by the procedure (KB ⊦P g)
then g is true in all models of KB (KB ⊧ g)
Definition (completeness)
A proof procedure P is complete if KB ⊧ g implies KB ⊦P g.
complete: every atom that logically follows from KB is derived by P
• Completeness of proof procedure P: need to prove that
If g is true in all models of KB (KB ⊧ g)
15
then g is derived by theSlide
procedure
(KB ⊦P g)
Simple Proof Procedure
Simple proof procedure S
• Enumerate all interpretations
• For each interpretation I, check whether it is a model of KB
 i.e., check whether all clauses in KB are true in I
• KB ⊦S g if g holds in all such models
problem with this approach?
• If there are n propositions in the KB, must check all
the 2𝑛 interpretations!
Goal of proof theory
• find sound and complete proof procedures that allow us to
prove that a logical formula follows from a KB avoiding to
Slide 16
do the above
Lecture Overview
• Recap Lecture 7
• Logical Consequences and Proof Procedures
• Bottom-Up Proof Procedure
• Soundness
• Completeness
Slide 17
Bottom-up proof procedure
• One rule of derivation, a generalized form of modus
ponens:
• If “h ← b1  …  bm" is a clause in the knowledge base,
and
each bi has been derived,
then h can be derived.
• This rule also covers the case when m = 0.
Slide 18
Bottom-up proof procedure
C :={};
repeat
select clause “h ← b1 ∧ … ∧ bm” in KB such
that bi ∈ C for all i, and h ∉ C;
C := C ∪ { h }
until no more clauses can be selected.
KB ⊦ G if G ⊆ C at the end of this procedure
The C at the end of BU procedure is a fixed point:
• Further applications of our rule of derivation will not
change C!
Slide 19
Bottom-up proof procedure: example
C := {};
repeat
select clause h ← b1  …  bm in KB
such that bi  C for all i, and h  C;
C := C  {h}
until no more clauses can be selected.
a← b  c
a← e  f
b← f  k
c← e
d← k
e.
f← j  e
f← c
j← c
{}
{e}
{c,e}
{c,e,f}
{c,e,f,j}
{c,e,f,j,a}
Slide 20
Done.
Lecture Overview
• Recap of Lecture 6
• Planning as CSP
• Logic
• Intro
• Propositional Definite Clause Logic (PDCL)
• Sintax and Semantics
• Logical Consequences and Proof Procedures
• Bottom Up Proof Procedure
• Soundness and completeness
Slide 21
Soundness of bottom-up proof procedure BU
Definition (soundness)
A proof procedure P is sound if KB ⊦P g implies KB ⊧ g.
sound: every atom g that P derives follows logically from KB
C := {};
repeat
select clause h ← b1  …  bm in KB
such that bi  C for all i, and h  C;
C := C  {h}
until no more clauses can be selected.
What do we need to prove to show that BU is
sound ?
Slide 22
Soundness of bottom-up proof procedure BU
Definition (soundness)
A proof procedure P is sound if KB ⊦P g implies KB ⊧ g.
sound: every atom g that P derives follows logically from KB
C := {};
repeat
select clause h ← b1  …  bm in KB
such that bi  C for all i, and h  C;
C := C  {h}
until no more clauses can be selected.
What do we need to prove to show that BU is sound ?
If g  C at the end of BU procedure,
then g is true in all models of KB (KB ⊧ g)
Slide 23
Soundness of bottom-up proof procedure BU
What do we need to prove to show that BU is sound ?
If g  C at the end of BU procedure,
then g is true in all models of KB (KB ⊧ g)
By contradiction: Suppose there is a g such that
KB ⊦ BU g but not KB ⊧ g.
• Let h be the first atom added to C that is not true in every model
of KB.
• In particular, suppose I is a model of KB in which h isn’t true
• There must be a clause in KB of form
h  b1 ...  bn
where each bi is true in I.
• Because h is false in I, this clause is false in I.
Slide 24
• Therefore I is not a model of KB
=> Contradiction
Completeness of BU: general idea
•
Generic completeness of proof procedure:
If G is logically entailed by the KB (KB ⊧ G)
then G can be proved by the BU procedure (KB ⊦BU G)
Sketch of our proof:
1. Suppose KB ⊧ G. Then G is true in all models of KB.
2. Thus G is true in any particular model of KB
3. We will define a model (called minimal model) so that if G is
true in that model, G is proved by the bottom up algorithm.
4. Thus KB ⊦ G.
Slide 25
Completeness of BU: general idea
We define a specific model of our KB, in which
• every atom in C at the end of BU is true
• every other atom is false
This is called minimal model
All atoms = {a, b, c, d,e, f, g}
C = {e,d, c, f,}
Minimal Model =
a=F, b=F, c=T, d = T, e=T, f=T, g=F
KB
a ← e ∧ g.
b ← f ∧ g.
c ← e.
f←c
e.
d.
• Using this model, we’ll then show that, if KB ⊧ G,
then G must be in C, that is
If g is true in all models of KB (KB ⊧ g)
then g  C at the end of BU procedure (KB ⊦BU Slide
g) 26
Definition
The minimal model MM is the interpretation in which
- every element of BU’s fixed point C is true
- every other atom is false.
Claim: MM is a model of KB
Proof by contradiction: assume that MM is not a model of KB.
• Then there must exist some clause in KB which is false
in MM
 Like every clause in KB, it is of the form h ← b1  …  bm
(with m  0).
• h ← b1  …  bm can only be false in MM if each bi is
true in MM and h is false in MM.
 Since each bi is true in MM, each bi must be in C as well.
 BU would add h to C, so h would be true in MM
 Contradiction! Thus, MM is a model of KB
Slide 27
Completeness of bottom-up procedure
If g is true in all models of KB (KB ⊧ g)
then g  C at the end of BU procedure (KB ⊦BU g)
Direct proof based on minimal model:
•
•
•
•
Suppose KB ⊧ g. Then g is true in all models of KB.
Thus g is true in the minimal model.
Thus g  C at the end of BU procedure.
Thus KB ⊦BU g. Done. KB ⊧ g implies KB ⊦BU g
Slide 28
Summary for bottom-up proof procedure BU
• BU is sound:
it derives only atoms that logically follow from KB
• BU is complete:
it derives all atoms that logically follow from KB
• Together:
it derives exactly the atoms that logically follow from KB
• And, it is efficient!
• Linear in the number of clauses in KB
Each clause is used maximally once by BU
Slide 29
Learning Goals Up To Here
• PDCL syntax & semantics
- Verify whether a logical statement belongs to the
language of propositional definite clauses
- Verify whether an interpretation is a model of a PDCL
KB.
‾ Verify when a conjunction of atoms is a logical consequence
of a knowledge base
• Bottom-up proof procedure
• Define/read/write/trace/debug the Bottom Up (BU) proof
procedure
• Prove that the BU proof procedure is sound and complete
Slide 30
Lecture Overview
• Recap: Logic intro
• Propositional Definite Clause Logic:
Semantics
• PDCL: Bottom-up Proof
Slide 31
Next class
(still section 5.2)
• Soundness and Completeness of Bottom-up
Proof Procedure
• Using PDC Logic to model the electrical domain
• Reasoning in the electrical domain
Slide 32
Download