Upload
ateiska
View
216
Download
0
Embed Size (px)
Citation preview
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 1/25
Announcements
Upcoming due dates Tuesday 9/22 11:59 pm HW 3 (edX) (thanks to campus IT meltdo
!"ida# 9$%5 5:&& pm '"oect 1
iscussion *ections eek 9$%%+%3, o-cial sign+up .o" section
*ign up in pe"son at section
I. o/e".ull, p"io"it# goes to those ho sign up and a"e "egiste"ed .o" tha
I. #ou don0t sho up in pe"son, #ou ma# get umped to anothe" sectio
'"oailit# *essions Weekl#, until e0"e done ith p"oailit#2
W 9+1& am, %99 o"#
W 4+ pm, 531 o"#
Wo"ksheets a"e posted on edX s#llaus
6# o-ce hou"s: !"ida# 9am 511 *oda7 6onda# 11am 31&
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 2/25
* 188: A"ticial Intelligence
'"opositional ogic
*emantics and In.e"ence
Inst"ucto": *tua"t ;ussell
Uni/e"sit# o. ali.o"nia, <e"kele#
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 3/25
=noledge
=noledge ase > set o. sentences in a .o"m
language ecla"ati/e app"oach to uilding an agent (
s#stem): Tell it hat it needs to kno (o" ha/e it Learn t
knoledge)
Then it can Ask itsel. hat to do?anse"s shou."om the =<
Agents can e /ieed at the knowledge lei@e@, hat the# know, "ega"dless o. ho
implemented
Knowledge base
Inference engine
Domain-specific facts
Generic code
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 4/25
ogic
Syntax : What sentences a"e alloedD
Semantics: What a"e the possible worldsD
Which sentences a"e true in hich o"ldsD (i@e@defnition o. t"uth)
α1
α2 α3
*#ntaEland *emanti
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 5/25
FEamples
'"opositional logic *#ntaE: ' ∨ (¬G ∧ ;)7 X1 ⇔ (;aining ⇒ *unn
'ossile o"ld: '>t"ue,G>t"ue,;>.alse,*>t"ue
*emantics: α ∧ β is t"ue in a o"ld iJ is α t"ue an(etc@)
!i"st+o"de" logic *#ntaE: ∀E ∃# '(E,#) ∧ ¬G(Koe,.(E)) ⇒ .(E)>.(#)
'ossile o"ld: Lects o1, o%, o37 ' holds .o" Mo1
holds .o" Mo3N7 . (o1)>o17 Koe>o37 etc@
*emantics: φ(σ) is t"ue in a o"ld i. σ>o and φ h
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 6/25
In.e"ence: entailment
Entailment : α O> β (Bα entails βC o" Bβ .ollo
αC) iJ in e/e"# o"ld he"e α is t"ue, β is als I@e@, the α+o"lds a"e a suset o. the β+o"lds Pm⊆ models(β)Q
In the eEample, α% O> α1
(*a# α% is ¬G ∧ ; ∧ * ∧ W α1 is ¬G )
α1
α2
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 7/25
In.e"ence: p"oo.s
A p"oo. is a demonstration o. entailment e
and β 6ethod 1: model-checking
!o" e/e"# possile o"ld, i. α is t"ue make su"e thatoo
L= .o" p"opositional logic (nitel# man# o"lds)7 n"st+o"de" logic
6ethod %: theorem-proving *ea"ch .o" a seuence o. p"oo. steps (applications
inerence rules) leading ."om α to β
F@g@, ."om ' ∧ (' ⇒ G), in.e" G # odus !onens
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 8/25
In.e"ence ("eminde")
6ethod 1: model-checking
!o" e/e"# possile o"ld, i. α is t"ue make su"e thatoo
6ethod %: theorem-proving *ea"ch .o" a seuence o. p"oo. steps (applications
inerence rules) leading ."om α to β Sound algo"ithm: e/e"#thing it claims to p"o/
entailed
"omplete algo"ithm: e/e"# that is entailed ca
p"o/ed
' iti l l i t Th
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 9/25
'"opositional logic s#ntaE: The g"udetails
Ri/en: a set o. p"oposition s#mols X1,X%,S
(e o.ten add T"ue and !alse .o" con/enience)
Xi is a sentence
I. α is a sentence then ¬α is a sentence
I. α and β a"e sentences then α ∧ β is a sent
I. α and β a"e sentences then α ∨ β is a sent
I. α and β a"e sentences then α ⇒ β is a sen
I. α and β a"e sentences then α ⇔ β is a sen
And p@s@ the"e a"e no othe" sentences2
' iti l l i ti
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 10/25
'"opositional logic semantics: un/a"nished t"uth
function '+T;UFD(α,model) returns t"ue o" .a
if α is a s#mol then return ookup(α, mode if Lp(α) > ¬ then return not('+T;UFD(A"g1(α),model))
if Lp(α) > ∧ then return and('+T;UFD
(A"g1(α),model),'+T;UFD
(A"g%(α),model))
etc@
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 11/25
FEample
; ⇒ ( ⇔ U) (i. it0s "aining, #ou sta# d"# i. and onl# i. #
um"ella) 6odel >t"ue, ;>.alse, U>t"ue S@
.alse ⇒ (t"ue ⇔ t"ue)
.alse ⇒ t"ue
t"ue
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 12/25
*imple theo"em p"o/ing: !o"a"d c
!o"a"d chaining applies 6odus 'onens to g
ne .acts: Ri/en X1 ∧ X% ∧ S Xn ⇒ and X1, X%, S, Xn
In.e"
!o"a"d chaining keeps appl#ing this "ule, a
ne .acts, until nothing mo"e can e added ;eui"es =< to contain onl# defnite clause
(onunction o. s#mols) ⇒ s#mol7 o"
A single s#mol (note that X is eui/alent to T"u
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 13/25
!o"a"d chaining algo"ithm
function '+!+FTAI*D(=<, ) returns t"ue o" .alse count V a tale, he"e countPcQ is the nume" o. s#mols in in.e""ed V a tale, he"e in.e""edPsQ is initiall# .alse .o" all s
agenda V a ueue o. s#mols, initiall# s#mols knon to e
while agenda is not empt# do p V 'op(agenda)
if p > then return t"ue
if in.e""edPpQ > .alse then in.e""edPpQVt"ue
for each clause c in =< he"e p is in c@p"emise dodec"ement countPcQ
if countPcQ > & then add c@conclusion to agreturn .alse
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 14/25
Q
P
M
L
A
!o"a"d chaining eEample: '"o/
' ⇒ G
∧ 6 ⇒ '
< ∧ ⇒ 6
A ∧ ' ⇒
A ∧ < ⇒
A
1
%%
%
%
&
&
A
.alse< .alse
.alse6 .alse
' .alse
G
.alse
CLAUSES
AGENDA
A B
INFERREDCOUNT
Lx
xxxx true
1
1
x
xxxx true
1
!
x
xxxx true
1
!
"x
xxxx true
!
#x
xxxx true
!
!
L $x x
xxxx true
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 15/25
'"ope"ties o. .o"a"d chainin
Theo"em: ! is sound and complete .o" deni
=<s *oundness: .ollos ."om soundness o. 6odus
(eas# to check)
ompleteness p"oo.:
1@ ! "eaches a Eed point he"e no ne atomic sentences %@ onside" the nal inferred tale as a model m, assigning
s#mols
3@ F/e"# clause in the o"iginal =< is t"ue in m
'"oo.: *uppose a clause a1∧@@@ ∧ak ⇒ is .alse in m
Then a1∧@@@ ∧ak is t"ue in m and is .alse in m
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 16/25
*imple model checking
function TT+FTAI*D(=<, ) returns t"ue o" .alse return TT+HF=+A(=<,,s#mols(=<) U s#mols(),)function TT+HF=+A(=<,,s#mols,model) returns t"ue o
if empt#D(s#mols) then if '+T;UFD(=<,model) then return '+T;UFD(,moelse return t"ue
else
' V "st(s#mols) "est V "est(s#mols) return and ( TT+HF=+A(=<,,"est,model Y ' >
TT+HF=+A(=<,,"est,model Y '
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 17/25
*imple model checking, cont
*ame "ecu"sion as
ackt"acking L(%n) time, linea" space
We can do much ette"2
#1%true #1%false
#2%true #2%
#n%true
1 1 1
1 1 &
1
KB'
α'
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 18/25
*atisailit# and entailmen
A sentence is satisfable i. it is t"ue in at le
o"ld (c. *'s2) *uppose e ha/e a h#pe"+e-cient *AT sol/
can e use it to test entailmentD *uppose α O> β
Then α ⇒ β is t"ue in all o"lds Hence ¬(α ⇒ β) is .alse in all o"lds
Hence α ∧ ¬β is .alse in all o"lds, i@e@, unsatisa
*o, add the negated conclusion to hat #ou
test .o" (un)satisailit#7 also knon as "edu
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 19/25
onuncti/e no"mal .o"m (
F/e"# sentence can e eEp"essed as a con#
clauses Fach clause is a dis#unction o. literals
Fach lite"al is a s#mol o" a negated s#mo
on/e"sion to ! # a seuence o. standa
t"ans.o"mations: ; ⇒ ( ⇔ U) (i. it0s "aining, #ou sta# d"# i. and onl#
um"ella)
; ⇒ (( ⇒ U) ∧ (U ⇒))
¬; / ((¬ / U) ∧ (¬U / ))
(eplace biconditional b) two implications
(eplace α ⇒ β b) ¬α * β
Distribute * o*er ∧
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 20/25
F-cient *AT sol/e"s
' (a/is+'utnam+ogemann+o/eland) is the co
mode"n sol/e"s Fssentiall# a ackt"acking sea"ch o/e" models
some eEt"as: Early termination: stop i.
all clauses a"e satised7 e@g@, (A ∨ <) ∧ (A ∨ ¬) is satisA>t"ue
an# clause is .alsied7 e@g@, (A ∨ <) ∧ (A ∨ ¬) is satisedA>.alse,<>.alse
!ure literals: i. all occu""ences o. a s#mol in as+unsatised clauses ha/e the same sign, then gi/e that /alue
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 21/25
' algo"ithm
function '(clauses,s#mols,model) returns t"ue o" .alsif e/e"# clause in clauses is t"ue in model then return t"
if some clause in clauses is .alse in model then return .a ',/alue V!I+'U;F+*6<L(s#mols,clauses,model) if ' is non+null then return '(clauses, s#molsZ',modelY'>/alue)
',/alue V!I+UIT+AU*F(clauses,model)
if ' is non+null then return '(clauses, s#molsZ',modelY'>/alue)
' V !i"st(s#mols)7 "est V ;est(s#mols) return or('(clauses,"est,modelY'>t"ue), '(clauses,"est,modelY'>.alse))
- i
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 22/25
F-cienc#
a[/e implementation o. ': sol/e \1&& /a"iale
FEt"as: ]a"iale and /alue o"de"ing (."om *'s)
i/ide and conue"
aching unsol/ale sucases as eEt"a clauses to a/oid "e
ool indeEing and inc"emental "ecomputation t"icks so th
step o. the ' algo"ithm is e-cient (t#picall# L(1)) IndeE o. clauses in hich each /a"iale appea"s ^/e$+/e
=eep t"ack nume" o. satised clauses, update hen /a"iales
=eep t"ack o. nume" o. "emaining lite"als in each clause
;eal implementation o. ': sol/e \1&&&&&&& /a"
*AT l i i
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 23/25
*AT sol/e"s in p"actice
i"cuit /e"ication: does this ]*I ci"cuit com
"ight anse"D *o.ta"e /e"ication: does this p"og"am com
"ight anse"D
*o.ta"e s#nthesis: hat p"og"am compute
anse"D '"otocol /e"ication: can this secu"it# p"oto
"okenD
'"otocol s#nthesis: hat p"otocol is secu"e .
taskD
*
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 24/25
*umma"#
Lne possile agent a"chitectu"e: knoledge
in.e"ence ogics p"o/ide a .o"mal a# to encode kno
A logic is dened #: s#ntaE, set o. possile o"condition
ogical in.e"ence computes entailment "elatamong sentences
eEt: a logical 'acman agent
< k i
7/23/2019 FA15 CS188 Lecture 08 PL Semantics and Inference.pptx-2
http://slidepdf.com/reader/full/fa15-cs188-lecture-08-pl-semantics-and-inferencepptx-2 25/25
<"eak ui_
enite clauses a"e a
special kind o. <ooleanconst"aint
In.e"ence ith deniteclauses # ! (o" ') islinea"+time
In.e"ence in t"ee+st"uctu"ed *'s is linea"+time
Is the"e a connectionD
ot uite2
A complete sea"c
ala#s nds a soeEists
A complete in.e"ealgo"ithm ala#sp"oo. i. the ue"#
an e use compalgo"ithms to uiin.e"ence algo"ith
es2 *&>=<, R > ue"#
added