logic abc - suendermannsuendermann.com/su/pdf/l_20130128.pdf · r) (b) (r ↔ p → p → r ......
TRANSCRIPT
.abc
.
Logic
David
Suenderm
ann
http://suendermann.com
Baden-W
uertte
mberg
Coopera
tiveSta
teU
nive
rsity
Stu
ttgart,
Germ
any
D.Suenderm
ann
Logic
January
28,2012
1
.G
enera
lre
mark
s.
The
most
up-to
-date
versio
nofth
isdocu
ment
as
well
as
auxiliary
mate
rialca
nbe
found
onlin
eat
http://suendermann.com
D.Suenderm
ann
Logic
January
28,2012
2
.Logica
lopera
tors
.
Pro
positio
nallo
gic
(aka
pro
positio
nalca
lculu
s)is
asyste
moffo
rmula
s
repre
sentin
gpro
positio
ns.
We
areusin
gth
efo
llow
ing
logica
lopera
tors
(aka
logica
lco
nnective
s):
¬(n
ot)
∧(a
nd)
∨(o
r)
→(if
...th
en)
↔(if
and
only
if(a
kaiff
))
D.Suenderm
ann
Logic
January
28,2012
5
.W
ell-fo
rmula
ted
form
ula
s.
In
ord
erto
build
valid
(well-fo
rmula
ted)
form
ula
s(W
FFs)
inpro
positio
nal
logic,
we
startw
itha
set
ofpro
positio
nalvaria
ble
sP
=p1,...,p
N.
Give
nP
,we
can
derive
the
set
ofW
WFs
Fin
ductive
lyas
follo
ws:
1.
1∈
F(tru
e)
2.
0∈
F(fa
lse)
3.
ifp∈
Pth
en
p∈
F(e
very
variable
isa
WFF)
4.
iff∈
Fth
en¬
f∈
F(th
enegatio
nofa
WFF
isa
WFF)
5.
iff,g∈
Fth
en
a)
(f∧
g)∈
F
b)
(f∨
g)∈
F
c)(f→
g)∈
F
d)
(f↔
g)∈
F
D.Suenderm
ann
Logic
January
28,2012
6
.W
ell-fo
rmula
ted
form
ula
s:exa
mple
s.
Assu
me
the
follo
win
gvaria
ble
s
P=p,q,r.
(1)
These
areW
WFs:
p(p∧
q)
((¬p→
q)∨
(q→¬
r))
these
arenot:
p¬
(p←
q)
→q
D.Suenderm
ann
Logic
January
28,2012
7
.Pre
cedence
and
asso
ciativity
oflo
gica
lco
nnective
s.
O
ute
rmost
pare
nth
esis
can
be
dro
pped:
(p∧
q)⇔
p∧
q(2)
Consid
erth
efo
llow
ing
pre
cedence
s:
.....
opera
tor
pre
cedence
¬1
(strongest)
∧2
∨3
→4
↔5
(weake
st)
E.g
.,we
have
:
(p∧
q)→
(q∨
r)⇔
p∧
q→
q∨
r(3)
Assu
me
opera
tors
ofth
esa
me
pre
cedence
tobe
left-a
ssocia
tive:
(p→
q)→
r⇔
p→
q→
r(4)
D.Suenderm
ann
Logic
January
28,2012
8
.Pre
cedence
and
asso
ciativity
oflo
gica
lco
nnective
s:exe
rcise.
Set
pare
nth
ese
sto
indica
teth
eord
erofeva
luatio
n:
p↔
q∨
r∧
s→
t∧¬
u∧
v↔
w(5)
Dro
pas
many
pare
nth
ese
sas
possib
le:
((¬¬
((((((p↔
q)∨
r)∨
s)∨
t)↔
u)∧
v)∧
w)∧
x)
(6)
D.Suenderm
ann
Logic
January
28,2012
9
.Som
eapplica
tions
ofpro
positio
nallo
gic
.
D
esig
nand
analysis
ofdig
italcircu
its
–Seve
ralm
illion
logica
lgate
s(p
hysica
lre
aliza
tions
oflo
gica
l
connective
s)are
imple
mente
din
nowadays’
micro
poce
ssors.
–A
circuit
com
pariso
nalg
orith
mch
eck
sw
heth
erth
epro
positio
nal
form
ula
sre
pre
sentin
gtw
ocircu
itsare
equiva
lent.
Pla
nnin
g
–In
many
pla
nnin
gta
sks
(such
as
inlo
gistics,
train
orairlin
e
schedulin
g),
multip
leco
mpulso
ryre
strictions
apply.
–These
restrictio
ns
can
ofte
nbe
exp
resse
din
term
sofpro
positio
nal
logic.
–O
ptim
also
lutio
ns
may
be
dete
rmin
ed
by
means
oflo
gica
lre
solu
tion
tech
niq
ues
(we
will
learn
about
this
late
rin
this
lectu
re).
D.Suenderm
ann
Logic
January
28,2012
10
.Som
eapplica
tions
ofpro
positio
nallo
gic
.
Com
pute
r-assiste
dpro
of
–O
ften,pro
ofs
ofco
nje
cture
sin
am
ath
em
atica
ldiscip
line
may
be
very
com
ple
x(1
00s
ofpages).
–If
the
discip
line’s
axio
ms
aregive
nin
form
oflo
gica
lfo
rmula
s(th
e
know
ledge
base
),th
e(in
)valid
ityofco
nje
cture
sm
aybe
pro
ven
by
reso
lutio
n.
–This
appro
ach
allo
ws
for
pro
ofs
ofa
com
ple
xityhum
ans
arenot
able
tohandle
(1,0
00,0
00s
ofpages).
Gam
eth
eory
–M
any
one-,
two-,
or
multi-p
layergam
es
can
be
exp
resse
din
term
sof
form
ula
sofpro
positio
nallo
gic.
–Exa
mple
sin
clude
chess,
the
8-p
uzzle
,or
the
8-q
ueens
puzzle
.
–Again
,re
solu
tion
may
be
applie
dto
solve
these
puzzle
sor
derive
“optim
al”
solu
tions.
D.Suenderm
ann
Logic
January
28,2012
11
.D
eep
Blu
e.
chess-p
laying
com
pute
rby
IBM
On
May
11,1997,D
eep
Blu
ewon
asix-
gam
em
atch
again
stGarry
Kasp
arov.
base
don
bru
te-fo
rceco
mputin
gpower
(30
nodes
with
480
VLSIch
ess
chip
s)
w
ritten
inC
underAIX
The
eva
luatio
nfu
nctio
nco
nta
ined
mul-
tiple
para
mete
rstu
ned
on
700,0
00
gra
ndm
aste
rgam
es.
pic:–
source
:http://flickr.com/photos/22453761@N00/592436598/
–auth
or:
Jam
es
the
photo
gra
pher
–lice
nse
:Cre
ativ
eCom
mons
Attrib
utio
n2.0
Generic
D.Suenderm
ann
Logic
January
28,2012
12
.8-p
uzzle
.
Da
s 8
-Pu
zzle
51
6
32
4
12
3
45
6
?
87
78
"NP
Vll
täd
i"
51
6
51
32
6
87
4
51
6
32
87
4...
...
8-P
uzzle
"NP
V
51
6
32
4
87
51
6
32
87
45
16
32
87
4
87
4
51
6
37
2
84
...
...
8P
uzzle
-8
75
16
32
4
87
...
84
56
31
2
87
4...
87
4
"NP
Vll
täd
i"
51
68
74
...8
-Pu
zzle
"NP
V
87
51
68
74
84
...8
Pu
zzle
-8
78
4
87
48
74
D.Suenderm
ann
Logic
January
28,2012
13
.8
queens
puzzle
.
Pla
ce8
chess
queens
on
ach
essb
oard
that
no
two
queens
atta
ckeach
oth
er.
There
are
648
=
4,426,165,368
possib
learra
ngm
ents.
But
only
92
solu
tions.
......
D.Suenderm
ann
Logic
January
28,2012
14
.Sem
antics
ofpro
positio
nalfo
rmula
s.
So
far,we
have
inve
stigate
dth
esyn
tax
(structu
re)
ofpro
positio
nal
form
ula
s.
N
ow
,we
want
tolo
ok
at
the
sem
antics,
that
isth
em
eanin
g,or
truth
,of
pro
positio
nalfo
rmula
s.
Ingenera
l,w
ithout
furth
erknow
ledge
about
the
variable
sofa
form
ula
,
we
cannot
tell
wheth
er
afo
rmula
istru
eor
false
.
E.g
.,w
ithout
know
ing
the
truth
valu
eof
pand
q,th
efo
rmula
p∨
q(7)
may
be
true
or
false
.
To
that
end,we
intro
duce
the
valu
atio
n,orin
terp
reta
tion
ofa
form
ula
as
the
functio
n
I:F→
Bw
ithB
=0,1.
(8)
D.Suenderm
ann
Logic
January
28,2012
15
.Valu
atio
n.
W
edefine
the
valu
atio
nI
inductive
lyas
follo
ws:
1.
I(1
)=
1
2.
I(0
)=
0
3.
I(p
)∈
Bfo
rall
p∈
P
(valu
es
forall
p∈
Pappearin
gin
the
form
ula
have
tobe
pro
vided)
4.
I(¬
f)
=I
¬(I
(f))
for
all
f∈
F
5.
I(f∧
g)
=I
∧(I
(f),
I(g
))fo
rall
f,g∈
F
6.
I(f∨
g)
=I
∨(I
(f),
I(g
))fo
rall
f,g∈
F
7.
I(f→
g)
=I
→(I
(f),
I(g
))fo
rall
f,g∈
F
8.
I(f↔
g)
=I
↔(I
(f),
I(g
))fo
rall
f,g∈
F
D.Suenderm
ann
Logic
January
28,2012
16
.Valu
atio
noflo
gica
lco
nnective
s.
I¬(p
):p
01
10
I∧(p
,q):
p
01
q0
00
10
1
I∨(p
,q):
p
01
q0
01
11
1
I→
(p,q):
p
01
q0
10
11
1
I↔
(p,q):
p
01
q0
10
10
1
D.Suenderm
ann
Logic
January
28,2012
17
.Valu
atio
n:exa
mple
.
W
eare
give
nth
efo
rmula
f:=
p→
q→
(¬p→
q→
q).
(9)
N
ow
,we
want
toeva
luate
ffo
rall
possib
lein
terp
reta
tions
of
pand
q.
A
handy
way
todo
sois
touse
atru
thta
ble
:
pq
g:=¬
ph
:=g→
qi:=
h→
qj
:=p→
qj→
i
00
10
11
1
01
11
11
1
10
01
00
1
11
01
11
1
with
p→
q︸
︷︷
︸
j
→(
h︷
︸︸
︷¬
p︸︷︷︸
g
→q→
q)
︸︷︷
︸
i
.(10)
D.Suenderm
ann
Logic
January
28,2012
18
.Valu
atio
n:exce
rcise.
Eva
luate
the
follo
win
gfo
rmula
sfo
rall
possib
lein
terp
reta
tions
(a)
r∨
r∧¬
q→
p∧
(¬q∧¬¬
r)
(b)
(r↔
p→
p→
r∧¬¬¬¬¬¬(¬
q↔
q))∧
r
Hin
t:You
do
not
need
touse
the
truth
table
exce
ssively
ifyo
uca
napply
simplifi
catio
ns
deriva
ble
from
the
valu
atio
nta
ble
oflo
gica
lco
nnective
s
such
as
¬¬
p⇔
p(11)
p∧
0⇔
0(12)
p∧¬
p⇔
0(13)
p→
p⇔
1(14)
p↔
0⇔¬
p(15)
p↔¬
p⇔
0(16)
D.Suenderm
ann
Logic
January
28,2012
19
.Turn
ing
natu
ralla
nguage
into
pro
positio
nalfo
rmula
s.
In
specto
rW
atso
nis
calle
dto
aje
welry
store
that
has
been
subje
ctto
a
robbery
where
thre
esu
bje
cts,Austin
,Bria
n,and
Colin
,were
arreste
d.
Afte
reva
luatio
nofall
facts,
this
isknow
n:
1.
At
least
one
ofth
esu
bje
ctsis
guilty:
f1
:=a∨
b∨
c.
(17)
2.
IfAustin
isguilty
he
had
exa
ctlyone
acco
mplice
:
f2
:=a→
b∧¬
c∨¬
b∧
c.
(18)
3.
IfBria
nis
innoce
nt,
sois
Colin
:
f3
:=¬
b→¬
c.
(19)
4.
Ifexa
ctlytw
osu
bje
ctsare
guilty,
Colin
isone
ofth
em
.H
ence
,out
of
thre
epossib
lepairs
ofsu
bje
cts,th
ere
isonly
one
impossib
le:
f4
:=¬
(a∧
b∧¬
c).
(20)
5.
IfColin
isin
noce
nt
then
Austin
isguilty:
f5
:=¬
c→
a.
(21)
Exe
rcise:W
ho
areth
ecu
lprits?
(Hin
t:co
nju
nctive
lyco
mbin
ef1 ,
...,f5)
D.Suenderm
ann
Logic
January
28,2012
20
.Tauto
logie
s.
W
ehave
seen
that
Form
ula
9is
true
for
eve
rypro
positio
nalva
luatio
n.
Such
afo
rmula
isca
lled
tauto
logy
(Ludw
igW
ittgenste
in,1921).
Iff
fis
ata
uto
logy
this
isalso
denote
das
|=f.
(22)
Wittg
enste
inon
logic
language
and
the
myste
ryofth
eworld
:
http://www.youtube.com/watch?v=Pv68v
reEQM
Exa
mple
s:
1.|=
p∨¬
p
2.|=
p→
p
3.|=
p∧
q→
p
4.|=
p→
p∨
q
5.|=
p→
0↔¬
p
6.|=
p∧
q↔
q∧
p
D.Suenderm
ann
Logic
January
28,2012
21
.Valid
ity,sa
tisfiability,
contin
gency
.
va
lidity:
fis
valid⇔
fis
ata
uto
logy,
i.e.,
all
inte
rpre
tatio
ns
make
ftru
e.
satisfi
ability:
At
least
one
inte
rpre
tatio
nm
ake
sf
true.
unsa
tisfiability,
contra
dictio
n:All
inte
rpre
tatio
ns
make
ffa
lse.
contin
gency:
Inte
rpre
tatio
ns
of
fare
contin
gent
upon
the
truth
valu
es
of
f’s
ato
mic
parts.
I.e.,
contin
gent
pro
positio
ns
areneith
ernece
ssarilytru
e
nor
nece
ssarilyfa
lse.
D.Suenderm
ann
Logic
January
28,2012
22
.Equiva
lence
.
Two
form
ula
sf
and
gare
equiva
lent
iff
|=f↔
g.
(23)
Exa
mple
s:
1)|=¬
0↔
1|=¬
1↔
0
2)|=
p∨¬
p↔
1|=
p∧¬
p↔
0te
rtium
non
datu
r
3)|=
p∨
0↔
p|=
p∧
1↔
pneutra
lele
ment
4)|=
p∨
1↔
1|=
p∧
0↔
0
5)|=
p∧
p↔
p|=
p∨
p↔
pid
em
pote
ncy
6)|=
p∧
q↔
q∧
p|=
p∨
q↔
q∨
pco
mm
uta
tivity
7)|=
p∧
(q∧
r)↔
|=p∨
(q∨
r)↔
asso
ciativity
|=↔
(p∧
q)∧
r|=↔
(p∨
q)∨
r
8)|=¬¬
p↔
pdouble
-negatio
n
9)|=
p∧
(p∨
q)↔
p|=
p∨
p∧
q↔
pabso
rptio
n
D.Suenderm
ann
Logic
January
28,2012
23
.Equiva
lence
(cont.)
.
10)|=
p∧
(q∨
r)↔
|=p∨
q∧
r↔
distrib
utivity
|=↔
p∧
q∨
p∧
r|=↔
(p∨
q)∧
(p∨
r)
11)|=¬
(p∧
q)↔¬
p∨¬
q|=¬
(p∨
q)↔¬
p∧¬
qde
Morg
an’s
rule
s
12)|=
(p→
q)↔¬
p∨
qelim
inatio
nof→
13)|=
(p↔
q)⇔
elim
inatio
nof↔
|=⇔
(¬p∨
q)∧
(¬q∨
p)
D.Suenderm
ann
Logic
January
28,2012
24
.Equiva
lence
:exe
rcise.
We
aregive
nth
efo
rmula
f:=
p→
q→
(¬p→
q→
q).
(24)
Pro
veth
at
fis
ata
uto
logy
usin
gequiva
lence
rule
s.
D.Suenderm
ann
Logic
January
28,2012
25
.Lite
rals
and
clause
s.
Tra
nsfo
rmatio
ns
such
as
the
ones
inth
ela
stexe
rciseca
nbe
applie
d
alg
orith
mica
llytu
rnin
gan
arbitrary
form
ula
into
anorm
alize
dfo
rm.
In
ord
erto
show
this,
we
need
aco
uple
ofdefinitio
ns.
A
pro
positio
nalfo
rmula
fis
calle
da
litera
liff
eith
erofth
efo
llow
ing
case
sapplie
s:
1.
f=
0or
f=
1.
2.
f=
pw
ithp∈
P( p
ositive
litera
l)
3.
f=¬
pw
ithp∈
P( n
egative
litera
l)
The
set
ofall
litera
lsis
denote
das
L.
Apro
positio
nalfo
rmula
cis
calle
da
clause
iffc
has
the
form
c=
l1∨···∨
lm
(25)
where
l1,...,lm∈
L.
That
is,a
clause
isa
disju
nctio
noflite
rals.
The
set
ofall
clause
sis
denote
das
C.
D.Suenderm
ann
Logic
January
28,2012
26
.Set
nota
tion
ofcla
use
s.
D
ue
toth
easso
ciativity,
com
muta
tivity,and
idem
pote
ncy
ofth
e∨
connective
,in
acla
use
c,th
eord
eroflite
rals
isarb
itrary,and
repeate
d
litera
lsca
nbe
dro
pped.
This
isw
hy
we
can
inte
rpre
teth
elite
rals
of
cas
the
ele
ments
ofa
set:
l1 ,
...,lm.
(26)
Due
toth
eequiva
lence
|=l1∨···∨
lm∨
0↔
l1∨···∨
lm
,(27)
we
have|=l1 ,
...,lm
,0↔l1
,...,lm
(28)
(dro
ppin
gof0
from
acla
use
).
Asp
ecia
lca
seis
|=0↔
(29)
(the
em
pty
clause
).
D.Suenderm
ann
Logic
January
28,2012
27
.Trivia
lcla
use
s.
A
clause
cis
calle
dtrivia
l,i.e
.
|=c
(30)
iffwe
have
one
ofth
efo
llow
ing
case
s:
1.
Due
toth
eequiva
lence
|=l1∨···∨
lm∨
1↔
1(31)
we
have|=l1 ,
...,lm
,1↔1
(32)
(clause
conta
ins
1).
2.
Due
toth
eequiva
lence
|=l1∨···∨
lm∨
p∨¬
p↔
l1∨···∨
lm∨
1(33)
we
have
(usin
gIte
m1)
|=l1 ,
...,lm
,p,¬
p↔1
(34)
(clause
conta
ins
com
ple
mentary
litera
ls).
D.Suenderm
ann
Logic
January
28,2012
28
.Conju
nctive
norm
alfo
rm.
A
form
ula
fis
inco
nju
nctive
norm
alfo
rm(C
NF)
ifff
has
the
form
f=
c1∧···∧
cn
with
c1,...,c
n∈
C.
(35)
Due
toth
easso
ciativity,
com
muta
tivity,and
idem
pote
ncy
ofth
e∧
connective
,in
afo
rmula
f,th
eord
er
ofcla
use
sis
arbitrary,
and
repeate
d
clause
sca
nbe
discard
ed.
This
isw
hy
we
can
inte
rpre
teth
ecla
use
sof
fas
the
ele
ments
ofa
set
which
,in
turn
,are
sets
oflite
rals:
c1,...,c
n.
(36)
D.Suenderm
ann
Logic
January
28,2012
29
.Conju
nctive
norm
alfo
rm:exa
mple
.
The
form
ula
(p∨
q∨¬
r)∧
(q∨¬
r∨
p∨
q)∧
(¬r∨
p∨¬
q)
(37)
isin
CN
F,and
itsse
tnota
tion
is
p,q,¬
r,p,¬
q,¬
r.
(38)
D.Suenderm
ann
Logic
January
28,2012
30
.Conju
nctive
norm
alfo
rm:ta
uto
logy
.
D
ue
toth
eequiva
lence
|=c1∧···∧
cm∧
1↔
c1∧···∧
lm
,(39)
we
have|=c1,...,c
m,1↔c1,...,c
m
(40)
(dro
ppin
gof1
from
afo
rmula
inCN
F).
Asp
ecia
lca
seis
|=1↔
(41)
(em
pty
CN
F).
That
is,if
f=c1,...,c
n
the
follo
win
gca
ses
areequiva
lent
a)|=
f
b)|=
ci
forall
i∈1,...,n
c)c
i↔1
forall
i∈1,...,n
d)
f↔
(tauto
logy
pro
pertie
s).
D.Suenderm
ann
Logic
January
28,2012
31
.Conju
nctive
norm
alfo
rm:alg
orith
m.
This
alg
orith
mtu
rns
an
arbitrary
pro
positio
nalfo
rmula
fin
toCN
F:
1.
Elim
inate↔
by
Equiva
lence
13:
|=(p↔
q)⇔
(¬p∨
q)∧
(¬q∨
p)
(42)
2.
Elim
inate→
by
Equiva
lence
12:
|=(p→
q)↔¬
p∨
q(43)
3.
Sim
plify
the
form
ula
usin
gth
eEquiva
lence
s1,8,11:
a)|=¬
0↔
1
b)|=¬
1↔
0
c)|=¬¬
p↔
p
d)|=¬
(p∧
q)↔¬
p∨¬
q
e)|=¬
(p∨
q)↔¬
p∧¬
q
Now
,th
eco
nnective
¬w
illonly
appear
infro
nt
ofpro
positio
nal
variable
s(th
efo
rmula
isin
negatio
nnorm
alfo
rm).
D.Suenderm
ann
Logic
January
28,2012
32
.Conju
nctive
norm
alfo
rm:alg
orith
m(co
nt.)
.
4.
Exp
and
the
form
ula
usin
gth
efo
llow
ing
variants
ofth
elaw
of
distrib
utivity
(Equiva
lence
10):
a)|=
p∨
q∧
r↔
(p∨
q)∧
(p∨
r)
b)|=
p∧
q∨
r↔
(p∨
r)∧
(q∨
r)
This
isto
transfo
rmth
efo
rmula
into
aco
nju
nctio
nofdisju
nctio
ns.
5.
Tra
nsfo
rmth
efo
rmula
into
set
nota
tion.
D.Suenderm
ann
Logic
January
28,2012
33
.Conju
nctive
norm
alfo
rm:alg
orith
m:exa
mple
.
Let
us
dem
onstra
teth
ealg
orith
musin
gth
efo
rmula
f:=
p→
q→
(¬p→¬
q).
(44)
1.
(skip
ped)
2.
.|=
f⇔¬
p∨
q→
(¬p→¬
q)
⇔¬
(¬p∨
q)∨
(¬p→¬
q)
⇔¬
(¬p∨
q)∨
(¬¬
p∨¬
q)
(45)
3.
.|=
f⇔¬
(¬p∨
q)∨
(p∨¬
q)
⇔¬¬
p∧¬
q∨
(p∨¬
q)
⇔p∧¬
q∨
(p∨¬
q)
(46)
4.
.|=
f⇔
(p∨
(p∨¬
q))∧
(¬q∨
(p∨¬
q))
(47)
5.
.|=
f⇔p,¬
q
(48)
D.Suenderm
ann
Logic
January
28,2012
34
.Conju
nctive
norm
alfo
rm:deriva
tion
from
truth
table
.
In
case
there
arenot
too
many
variable
sin
volve
d,th
eCN
Fca
nalso
be
derive
ddire
ctlyfro
mth
etru
thta
ble
.
To
dem
onstra
teth
is,le
tus
consid
erth
eabove
exa
mple
f:=
p→
q︸
︷︷
︸
g
→(¬
p→¬
q)
︸︷︷
︸
h
.(49)
pq
gh
f
00
11
1
01
10
0
10
01
1
11
11
1
Fro
mth
ose
row
sw
here
feva
luate
sto
0,we
can
derive
the
CN
Fas
|=f⇔¬
(¬p∧
q)⇔
p∨¬
q(50)
or,
alte
rnative
ly,fro
mro
ws
turn
ing
1th
edisju
nctive
norm
alfo
rm(D
NF)
|=f⇔¬
p∧¬
q∨
p∧¬
q∨
p∧
q.
(51)
D.Suenderm
ann
Logic
January
28,2012
35
.Conju
nctive
norm
alfo
rm:exe
rcise.
Tra
nsfo
rmin
toCN
F:
a)
f:=
p→
(q↔
r)
b)
g:=
p→
q→
r↔¬
s∨
t
D.Suenderm
ann
Logic
January
28,2012
36
.Form
alpro
ofs
.
Pro
ofs
areone
ofth
em
ain
notio
ns
oflo
gic.
Give
n
–a
set
offo
rmula
sf1,...,f
n
(the
know
ledge
base
)and
–a
form
ula
g(th
eco
nje
cture
),
we
ask
wheth
er
gca
nbe
pro
ven
base
don
(or
infe
rred
from
the
know
ledge
base
.
That
is,we
ask
wheth
er
f1∧
...∧
fn→
g(52)
isa
tauto
logy.
One
possib
ilityto
answ
erth
isquestio
nis
toco
nve
rtForm
ula
52
into
CN
F
and
toch
eck
wheth
er
all
itscla
use
sare
trivial.
D.Suenderm
ann
Logic
January
28,2012
37
.Form
alpro
ofs:
exa
mple
(hyp
oth
etica
lsyllo
gism
).
Give
nth
eknow
ledge
base
f1
:=p→
q
f2
:=q→
r(53)
pro
veth
eco
nje
cture
g:=
p→
r(54)
This
is,we
need
topro
vew
heth
er
|=(p→
q)∧
(q→
r)→
(p→
r)
(55)
This
pro
ofca
nbe
done
usin
ga
truth
table
or
by
conve
rsion
into
CN
F.
This
specifi
cru
leis
calle
dhyp
oth
etica
lsyllo
gism
.
D.Suenderm
ann
Logic
January
28,2012
38
.In
fere
nce
rule
s.
Anoth
erway
topro
vea
conje
cture
from
aknow
ledge
base
isto
use
infe
rence
rule
s.
An
infe
rence
rule
isa
pair
consistin
gofa
set
ofpre
mise
sf1,...,f
n
and
aco
nclu
sion
gw
ritten
as
f1 ,···
,f
n
∴g
read
as
Fro
mf1 ,
...,f
n,we
can
infer
that
g.
D.Suenderm
ann
Logic
January
28,2012
39
.In
fere
nce
rule
s:exa
mple
s.
sim
plifi
catio
n
p∧
q
∴p
modus
ponens
p→
q,p
∴q
bico
nditio
nalelim
inatio
n
p↔
q,p∨
q
∴p∧
q
modus
tolle
ns
¬q,p→
q
∴¬
p
hyp
oth
etica
lsyllo
gism
p→
q,q→
r
∴p→
r
re
solu
tion
p∨
q,¬
p∨
r
∴q∨
r
D.Suenderm
ann
Logic
January
28,2012
40
.Cut
rule
.
Retu
rnin
gto
the
set
repre
senta
tion
ofCN
F,a
handy
infe
rence
rule
for
clause
sis
the
cut
rule
.
Give
na
pro
positio
nalvaria
ble
pand
two
clause
sc1
and
c2,th
ecu
tru
leis:
p∪
c1,¬
p∪
c2
∴c1∪
c2
D.Suenderm
ann
Logic
January
28,2012
41
.Cut
rule
:pro
of
.
W
etra
nsfo
rmth
eco
nve
ntio
nalre
pre
senta
tion
ofth
ecu
tru
lein
toCN
F:
f:=
(p∨
c1)∧
(¬p∨
c2)→
c1∨
c2
⇔¬
((p∨
c1)∧
(¬p∨
c2))∨
c1∨
c2
⇔¬
(p∨
c1)∨¬
(¬p∨
c2)∨
c1∨
c2
⇔¬
p∧¬
c1∨
p∧¬
c2∨
c1∨
c2
︸︷︷
︸
a
⇔(¬
p∨
a)∧
(¬c1∨
a)
a⇔
(p∨
c1∨
c2)
︸︷︷
︸
b
∧(¬
c2∨
c1∨
c2)
︸︷︷
︸
c
f⇔
((¬p∨
b)∧
(¬p∨
c))∧
((¬c1∨
b)∧
(¬c1∨
c))
⇔¬
p,p,c1,c2,¬
p,¬
c2,c1,c2,
¬
c1,p,c1,c2,¬
c1,¬
c2,c1,c2
(56)
Sin
ceall
clause
sin
fare
trivial,
|=f.
(57)
D.Suenderm
ann
Logic
January
28,2012
42
.Cut
rule
:sp
ecia
lca
ses
.
U
sing
Equiva
lence
12
(elim
inatio
nof→
),th
efo
llow
ing
ofourin
fere
nce
rule
exa
mple
sca
nbe
regard
ed
as
specia
lca
ses
ofth
ecu
tru
le:
–M
odus
ponens.
With
c1
:=
and
c2
:=q,we
have
p∪,¬
p∪q
∴∪q
–M
odus
tolle
ns
(show
this).
–H
ypoth
etica
lsyllo
gism
(show
this).
–Reso
lutio
n.
D.Suenderm
ann
Logic
January
28,2012
43
.Pro
vability
.
Give
na
set
ofcla
use
sM
(the
assu
mptio
ns;
aknow
ledge
base
)and
a
single
clause
f,we
define
are
latio
n
M⊢
f(58)
read
as
fis
pro
vable
from
M.
This
rela
tion
isin
ductive
lydefined
as
a)
Mpro
ves
all
itsassu
mptio
ns:
Iff∈
Mth
en
M⊢
f.
(59)
b)
Iftw
ocla
use
sp∪
c1
and¬
p∪
c2
arepro
vable
from
Mth
en
the
clause
c1∪
c2
ispro
vable
(applyin
gth
ecu
tru
le):
IfM⊢p∪
c1
and
M⊢¬
p∪
c2
then
M⊢
c1∪
c2.
(60)
D.Suenderm
ann
Logic
January
28,2012
44
.Pro
vability:
exa
mple
.
W
ewant
tosh
ow
that
¬
p,q,¬
q,¬
p,¬
q,p,q,p⊢0.
(61)
This
isone
way
todo
so:
1.¬
p,q,¬
q,¬
p⊢¬
p
2.¬
q,p,q,p⊢p
3.¬
p,p⊢
D.Suenderm
ann
Logic
January
28,2012
45
.Pro
vability:
exe
rcise.
W
eare
give
nth
efo
llow
ing
know
ledge
base
f1
:=p→
q
f2
:=q→
r
f3
:=r→
s
f4
:=s→
t
f5
:=t→
u
f6
:=u→
p
f7
:=p∨
q∨
r∨
s∨
t∨
u
f8
:=¬
p∨¬
q∨¬
r∨¬
s∨¬
t∨¬
u(62)
Show
that
0ca
nbe
infe
rred
from
the
know
ledge
base
.
D.Suenderm
ann
Logic
January
28,2012
46
.Satisfi
ability
ofse
tsofcla
use
s.
In
multip
leapplica
tions,
itis
nece
ssaryto
dete
rmin
ea
variable
inte
rpre
tatio
nre
nderin
gall
the
clause
sin
ase
tC
0tru
e.
That
is,we
want
todete
rmin
ew
heth
er
C0
issa
tisfiable
and,if
so,a
solu
tion,i.e
.,a
satisfyin
gin
terp
reta
tion.
Consid
erth
efo
llow
ing
obvio
us
case
s
1)
C1
=p,¬
q,r,¬
s,¬
t
(satisfi
able
)
2)
C2
=,p,¬
q,r
(unsa
tisfiable
)
3)
C3
=p,¬
q,¬
p
(unsa
tisfiable
)
D.Suenderm
ann
Logic
January
28,2012
47
.U
nit
clause
and
trivialse
tofcla
use
s.
A
clause
isca
lled
unit
clause
iffit
conta
ins
one
litera
l:
c=p
or
c=¬
p
with
p∈
P.
(63)
Ase
tofcla
use
sC
0is
calle
dtrivia
lin
one
ofth
ese
case
s:
1)
C0
conta
ins
the
em
pty
clause
:
∈
C0 .
(64)
That
is,C
0is
unsa
tisfiable
.
2)
C0
conta
ins
only
unit
clause
sofdiff
ere
nt
pro
positio
nalvaria
ble
s:
∀c(c∈
C0→∃p(p∈
P∧
(c=p∨
c=¬
p)))∧
∀p(p∈
P→¬
(p∈
C0∧¬
p∈
C0 )).
(65)
That
is,C
0is
satisfi
able
as
dete
rmin
ed
by
C0 ’s
unit
clause
s.
D.Suenderm
ann
Logic
January
28,2012
48
.T
he
alg
orith
mofD
avis
and
Putn
am
:basic
prin
ciple
s.
The
Davis
and
Putn
am
(DP)
alg
orith
mis
tofind
asa
tisfying
clause
give
n
ase
tofcla
use
sby
applyin
g
1)
cut
rule
2)
subsu
mptio
n
3)
case
distin
ction
D.Suenderm
ann
Logic
January
28,2012
49
.T
he
alg
orith
mofD
avis
and
Putn
am
:cu
tru
le.
The
DP
alg
orith
muse
sa
specia
lca
seofth
ecu
tru
le:
l1 ,
...,ln,¬
l,l
∴l1 ,
...,ln
reducin
gth
eorig
inalcla
use
length
by
one.
Genera
lly,th
isopera
tion
isperfo
rmed
by
the
functio
n
cut:2
C×
L→
2C
(66)
defined
as
cut(C
0 ,l)
=c\¬
l|c∈
C0∧¬
l∈
c.
(67)
Exa
mple
:
cut(p,q,¬
p,r,¬
q,¬
p)
=q
(68)
D.Suenderm
ann
Logic
January
28,2012
50
.T
he
alg
orith
mofD
avis
and
Putn
am
:su
bsu
mptio
n.
Assu
me
the
exa
mple
C0
:=p,q,¬
r,p.
(69)
As
we
have
|=p→
p∨
q∨¬
r,(70)
we
can
dro
p(su
bsu
me)p,q,¬
r
from
C0 .
Form
ally,
we
intro
duce
the
functio
n
sub
:2
C×
L→
2C
(71)
that
subsu
mes
all
clause
sin
C0
conta
inin
gth
eunit
clausel
:
sub(C
0 ,l)
=c∈
C0 |l6∈
c∪l.
(72)
Exa
mple
:
sub(p,q,¬
p,r,¬
q,¬
p)
=p,q,¬
q,¬
p
(73)
D.Suenderm
ann
Logic
January
28,2012
51
.T
he
alg
orith
mofD
avis
and
Putn
am
:re
ductio
n.
Sin
cecu
tru
leand
subsu
mptio
nhave
the
sam
earg
um
ent
space
sth
ey
can
be
com
bin
ed
toa
genera
lre
ductio
nfu
nctio
n.
In
doin
gso
,co
nsid
erth
at
applyin
gth
ecu
tru
lere
turn
sonly
cut
versio
ns
ofth
ose
clause
sth
at
orig
inally
conta
ined¬
l.
Hence
,we
add
all
those
clause
snotco
nta
inin
g¬
lbefo
reapplyin
g
subsu
mptio
n.
This
yield
s
red(C
0,l)
=su
b(C
1∪
C2,l)
(74)
with
C1
=cu
t(C0,l)
=c\¬
l|c∈
C0∧¬
l∈
c
(75)
and
C2
=c∈
C0|¬
l6∈
c.
(76)
D.Suenderm
ann
Logic
January
28,2012
52
.T
he
alg
orith
mofD
avis
and
Putn
am
:re
ductio
n(co
nt.)
.
Assu
min
gC
0is
not
trivial,
we
know
that
applyin
gsu
bsu
mptio
nto
C1
does
not
affect
any
ofits
clause
ssin
ceth
ey
orig
inally
conta
ined¬
l,i.e
.,
they
do
not
conta
inl.
Hence
,su
bsu
mptio
nca
nonly
affect
C2
which
isw
hy
we
can
write
red(C
0,l)
=su
b(C
1∪
C2 ,
l)
=C
1∪
sub(C
2 ,l)
=c\¬
l|c∈
C0∧¬
l∈
c∪
c∈
C0 |l6∈
c∧¬
l6∈
c∪l.
(77)
Exa
mple
:
red(p,q,¬
p,r,¬
q,¬
p)
=q,¬
q,¬
p
(78)
D.Suenderm
ann
Logic
January
28,2012
53
.T
he
alg
orith
mofD
avis
and
Putn
am
:ca
sedistin
ction
.
This
prin
ciple
isbase
don
the
follo
win
gpro
positio
n:
C0
issa
tisfiable
iffC
0∪p
or
C0∪¬
p
aresa
tisfiable
.
Here
,C
0is
ase
tofcla
use
s;p
isa
pro
positio
nalvaria
ble
occu
rring
inC
0.
This
sounds
likea
trivialprin
ciple
since
ifth
ere
isa
variable
inte
rpre
tatio
n
satisfyin
gC
0it
will
inclu
de
the
variable
pw
hich
must
be
eith
er
0or
1in
this
specifi
cin
terp
reta
tion.
The
case
distin
ction
prin
ciple
is,howeve
r,esse
ntia
lto
the
DP
alg
orith
m
as
itin
jects
unit
clause
sre
quire
dfo
rcu
tru
leand
subsu
mptio
n.
D.Suenderm
ann
Logic
January
28,2012
54
.T
he
alg
orith
mofD
avis
and
Putn
am
.
W
eare
give
na
set
ofcla
use
sC
0and
search
for
apro
positio
nalva
luatio
n
satisfyin
gC
0 .
1.
Itera
tively
apply
Ci+
1:=
red(C
i ,l)
forall
.....l∈p,¬
p|p∈
P∩
Ci ,
i=
0,1,...
IfC
i+1
turn
sout
tobe
trivial,
stop.
2.
Oth
erw
ise(ca
sedistin
ction),
choose
avaria
ble
pfro
mC
i(sh
ould
not
be
aunit
clause
since
those
had
been
tried
in1.)
a)
Itera
tively
apply
Ci+
1:=
red(C
i∪p,l)
for
all
l∈p,¬
p|p∈
P∩
Ci .
IfC
i+1
isfo
und
tobe
satisfi
able
,sto
p.
b)
Itera
tively
apply
Ci+
1:=
red(C
i∪¬
p,l)
for
all
l∈p,¬
p|p∈
P∩
Ci .
IfC
i+1
isfo
und
tobe
satisfi
able
,sto
p.
c)O
therw
ise,
C0
isnot
satisfi
able
.
Ste
p2
mig
ht
need
tobe
recu
rsively
applie
dm
ultip
letim
es
until
a
solu
tion
(satisfi
ability
orco
ntra
dictio
n)
isfo
und.
D.Suenderm
ann
Logic
January
28,2012
55
.T
he
alg
orith
mofD
avis
and
Putn
am
:exa
mple
.
W
eare
give
n
C0
:=p,q,s,¬
p,r,¬
t,r,
s,¬
r,q,¬
p,¬
s,p
C0
:=¬
p,¬
q,s,¬
r,p,¬
q,s,¬
r,¬
s,¬
p,¬
s
(79)
1.
(skip
ped—
C0
conta
ins
no
unit
clause
s)
2.
pick
p
a)
.C
1:=
red(C
0∪p,p)
=r,¬
t,r,
s,¬
r,q,¬
q,s,¬
r,¬
r,¬
s,¬
s,p
C2
:=re
d(C
1 ,¬
s)
=r,¬
t,r,¬
r,q,¬
q,¬
r,¬
s,p
C3
:=re
d(C
2 ,r)
=r,q,¬
q,¬
s,p
C4
:=re
d(C
3 ,q)
=r,q,,¬
s,p
(unsa
tisfiable
)(80)
D.Suenderm
ann
Logic
January
28,2012
56
.T
he
alg
orith
mofD
avis
and
Putn
am
:exa
mple
.
b)
.C
5:=
red(C
0∪¬
p,¬
p)
=q,s,r,
s,¬
s,¬
q,s,¬
r,¬
s,¬
p
C6
:=re
d(C
5 ,¬
s)
=q,r,¬
s,¬
q,¬
p
C7
:=re
d(C
6 ,q)
=q,r,¬
s,,¬
p
(unsa
tisfiable
)
(81)
c)C
0is
unsa
tisfiable
(contra
dictio
n).
D.Suenderm
ann
Logic
January
28,2012
57
.T
he
alg
orith
mofD
avis
and
Putn
am
:exe
rcise.
Apply
the
DP
alg
orith
mto
the
pro
vability
exe
rcisew
ith
a)
C0
:=f1 ,
...,f8,
b)
C0
:=f1 ,
...,f7.
D.Suenderm
ann
Logic
January
28,2012
58
.Reso
lutio
nte
chniq
ue
.
In
ord
erto
pro
vea
conje
cture
base
don
aknow
ledge
base
,we
can
apply
the
reso
lutio
nte
chniq
ue:
1.
All
sente
nce
sin
the
know
ledge
base
and
the
negatio
nofth
ese
nte
nce
tobe
pro
ven
(the
conje
cture
)are
conju
nctive
lyco
nnecte
d.
2.
The
resu
lting
sente
nce
istra
nsfo
rmed
into
CN
F.
3.
Ifth
eem
pty
clause
can
be
derive
dafte
ran
applica
tion
ofth
eD
P
alg
orith
m(o
r,alte
rnative
ly,th
epro
vability
tech
niq
ue),
the
orig
inal
sente
nce
isunsa
tisfiable
,i.e
.,th
eco
nje
cture
follo
ws
from
the
know
ledge
base
.
D.Suenderm
ann
Logic
January
28,2012
59
.Reso
lutio
nte
chniq
ue:exe
rcise.
Let
us
revisit
the
crimin
alca
sefro
mearlie
r.
Rem
em
ber,
we
were
give
nth
efo
llow
ing
facts
(ourknow
ledge
base
):
f1
:=a∨
b∨
c
f2
:=a→
b∧¬
c∨¬
b∧
c
f3
:=¬
b→¬
c
f4
:=¬
(a∧
b∧¬
c)
f5
:=¬
c→
a(82)
Dr.
Watso
n’s
gut
feelin
gis
that
Bria
nand
Colin
areth
ecu
lprits.
Pro
vehis
conje
cture
usin
gth
ere
solu
tion
tech
niq
ue.
D.Suenderm
ann
Logic
January
28,2012
60
.n
queens
puzzle
:exe
rcise.
Usin
gth
eD
Palg
orith
m,sh
ow
that
–th
e2
queens
puzzle
has
no
solu
tion,
–th
e3
queens
puzzle
has
no
solu
tion,
–th
e4
queens
puzzle
has
aso
lutio
nand
which
one
itis.
D.Suenderm
ann
Logic
January
28,2012
61
.O
utlin
e.
pro
positio
nallo
gic
first-o
rderlo
gic
Pro
log
D.Suenderm
ann
Logic
January
28,2012
62
.N
otio
ns
offirst-o
rder
logic
.
Term
sdenote
obje
cts.
Term
sare
com
pose
dofvaria
ble
sor
functio
nsym
bols:
fath
er(x
),m
oth
er(isa
ac),
x+
7.
(83)
with
the
variable
xand
the
functio
nsym
bols
fath
er,
moth
er,
isaac,
+,7
Obje
ctsca
nbe
put
into
rela
tion
by
pre
dica
tesym
bols
pro
ducin
gato
mic
form
ula
s :
isBro
ther(a
dam
,fa
ther(b
rian)),
x+
7<
x·7,
n∈
I.(84)
with
the
pre
dica
tesym
bols
IsBro
ther,
<,∈
Form
ula
sca
nbe
com
bin
ed
usin
glo
gica
lco
nnective
s:
isHum
an(x
)→
isMorta
l(x),
x>
1→
x+
7<
x·7.
(85)
Form
ula
sca
nco
nta
inquantifi
ers
definin
gth
ese
mantics
(scope)
of
variable
s:
∀x(isH
um
an(x
)→∃y(y
=m
oth
er(x
))).(86)
D.Suenderm
ann
Logic
January
28,2012
63
.Sig
natu
res
and
term
s.
A
signatu
reis
aquatru
ple
definin
ga
specifi
csyste
moffirst-o
rderlo
gic:
Σ=〈V
,F
,P
,arity〉.
(87)
The
mem
bers
ofΣ
are
–th
ese
tofvaria
ble
sV
,
–th
ese
toffu
nctio
nsym
bols
F,
–th
ese
tofpre
dica
tesym
bols
P,and
–a
functio
nassig
nin
gan
arityto
all
functio
nand
pre
dica
tesym
bols:
arity:F∪
P→
I.(88)
Give
na
signatu
reΣ
,we
define
the
set
ofΣ
term
sT
Σin
ductive
lyas:
1.∀x(x∈
V→
x∈
TΣ).
2.
Iff∈
Fand
n=
arity(f)
and
t1 ,
...,tn∈
TΣ
then
f(t
1 ,...,tn)∈
TΣ
.(89)
Specia
lca
se:If
f∈
Fand
arity(f)=
0th
en
we
can
write
fin
stead
of
f()
(aka
consta
nt).
D.Suenderm
ann
Logic
January
28,2012
64
.Sig
natu
res
and
term
s:exa
mple
.
W
eare
give
nth
esig
natu
reΣ
a=〈V
,F
,P
,arity〉
with
V=x,y,z
F=0,1,+
,·
P==
,≤
arity=〈0
,0〉〈1
,0〉〈+
,2〉〈·,
2〉〈=
,2〉〈≤
,2〉
Now
,we
can
derive
Σa
term
sas
follo
ws:
1.
x,y,z∈
TΣ
a
2.0,1∈
TΣ
a(0
-aryfu
nctio
nsym
bols)
3.
+(1
,x)∈
TΣ
a
4.·(+
(1,x),
y)∈
TΣ
a
Inth
efo
llow
ing,we
will
use
an
infix
nota
tion
forbin
aryre
latio
nand
functio
nsym
bols.
E.g
.,Term
4would
read
(1+
x)·y
(90)
D.Suenderm
ann
Logic
January
28,2012
65
.Ato
mic
form
ula
s.
Give
nth
esig
natu
reΣ
=〈V
,F
,P
,arity〉,
ifp∈
Pand
n=
arity(p)
and
t1,...,tn∈
TΣ
then
p(t
1 ,...,tn)∈
AΣ
,(91)
the
set
ofall
ato
mic
form
ula
s.
Specia
lca
se:If
p∈
Pand
arity(p)
=0
then
we
can
write
pin
stead
of
p()
(aka
pro
positio
nalvaria
ble
).
Contin
uin
gw
ithourabove
exa
mple
:
=(·(+
(1,x),
y),0)∈
AΣ
a(92)
or
inin
fix
nota
tion
(1+
x)·y
=0∈
AΣ
a.
(93)
D.Suenderm
ann
Logic
January
28,2012
66
.Fre
eand
bound
variable
s.
Consid
eran
exa
mple
from
calcu
lus:
x∫0
yzdz
=12
yx
2.
(94)
Eq.94
featu
res
the
thre
evaria
ble
sx,
yand
t.
Tryin
gto
substitu
tevaria
ble
son
both
sides
ofth
eequatio
n,e.g
.,x
by
yy
∫0
yzdz
=12
yy
2(95)
or
zby
yx∫0
yydy
=13
x3
!6=12
xx
2(96)
show
sth
at
there
can
be
two
types
ofvaria
ble
sin
form
ula
s:fre
e(x
,y)
and
bound
(z)
ones.
The
variable
zin
this
exa
mple
isbound
by
the
diff
ere
ntia
lopera
tor
d.
D.Suenderm
ann
Logic
January
28,2012
67
.Fre
eand
bound
variable
s(co
nt.)
.
Infirst-o
rderlo
gic,
variable
sare
bound
by
the
quantifi
ers∀
and∃.
Acco
rdin
gly,
inth
efo
llow
ing
exa
mple
∀x,y(P
(x)→
Q(x
,f(x
),z))
(97)
xand
yare
bound
variable
s,and
zis
free.
Afo
rmula
with
no
free
variable
sis
calle
da
sente
nce
.
D.Suenderm
ann
Logic
January
28,2012
68
.Fre
eand
bound
variable
s:exe
rcise.
Consid
erth
efo
llow
ing
exa
mple
s:
a)∀x(F
(x)→∃y(G
(y,z)))
b)∀x(F
(x)→∃y(G
(x,y)))
c)∃x(y
+x≤
y)
Which
variable
sare
free,and
which
ones
arebound?
Which
ofth
ese
form
ula
sare
sente
nce
s?
D.Suenderm
ann
Logic
January
28,2012
69
.Form
ula
s.
The
set
ofvaria
ble
svar(t)
occu
rring
ina
term
tis
inductive
lydefined
as
1.
var(x)
:=x
for
all
x∈
V.
2.
var(f(t
1 ,...,tn))
:=var(t
1 )∪···∪
var(tn).
Give
na
signatu
reΣ
,in
the
follo
win
g,we
denote
–th
ese
toffo
rmula
sas
FΣ,
–th
ese
tofall
bound
variable
sofa
form
ula
f∈
FΣ
as
bound(f
),and
–th
ese
tofall
free
variable
sof
fas
as
free(f
).
These
sets
arein
ductive
lydefined
as
1.
0,1∈
FΣ
(truth
valu
es)
and
free(0
)=
free(1
)=
bound(0
)=
bound(1
)=
(98)
2.∀f(f∈
AΣ→
f∈
FΣ)
(ato
mic
form
ula
s)and
free(f
)=
var(t1 )∪···∪
var(tn);
bound(f
)=
with
f=
p(t
1,...,tn)(99)
D.Suenderm
ann
Logic
January
28,2012
70
.Form
ula
s(co
nt.)
.
3.∀f(f∈
FΣ→¬
f∈
FΣ)
(negatio
n)
and
free(¬
f)
=fre
e(f
);bound(¬
f)
=bound(f
)(100)
4.∀f,g(f
,g∈
FΣ∧
free(f
)∩
bound(g
)=∧
bound(f
)∩
free(g
)=
→
(f∨
g)∈
FΣ)
(logica
lco
nnective
s)and
free(f∨
g)
=fre
e(f
)∪fre
e(g
);bound(f∨
g)
=bound(f
)∪bound(g
)(101)
applyin
gto
all
logica
lco
nnective
s(∨
,∧
,→
,↔
)
5.∀f,x(f∈
FΣ∧
x∈
V\bound(f
)→
(∀x(f
)),(∃
x(f
))∈
FΣ)
(quantifi
ers)
and
free(∀
x(f
))=
free(∃
x(f
))=
free(f
)\x;
(102)
bound(∀
x(f
))=
bound(∃
x(f
))=
bound(f
)∪x
(103)
D.Suenderm
ann
Logic
January
28,2012
71
.A
dditio
nalco
nve
ntio
ns
.
In
litera
ture
you
enco
unte
rexp
ressio
ns
ofth
efo
rm
∀x∈
R:∃n∈
N:x
<n
.(104)
These
abbre
viatio
ns
can
be
transfo
rmed
into
the
form
erly
intro
duce
d
term
inolo
gy
by
∀x∈
M:f
def
⇐⇒∀x(x∈
M→
f)
∃x∈
M:f
def
⇐⇒∃x(x∈
M∧
f)
(105)
Acco
rdin
gly,
Form
ula
104
can
be
writte
nas
∀x(x∈
R→∃n(n∈
N∧
x<
n)).
(106)
Sequence
sofid
entica
lquantifi
ers
can
be
abbre
viate
d:
∀x,y(f
)d
ef
⇐⇒
∀x(∀
y(f
)).(107)
Quantifi
ers
have
ahig
her
pre
cedence
than
logica
lco
nnective
s:
∀x(f
)∧
gd
ef
⇐⇒
(∀x(f
))∧
g.
(108)
D.Suenderm
ann
Logic
January
28,2012
72
.Stru
cture
s.
So
far,we
have
learn
ed
how
tocre
ate
(well-fo
rmula
ted)
form
ula
sin
first-o
rderlo
gic,
i.e.,
we
have
deale
dw
ithsyn
tax.
The
next
step
isth
ese
mantics
offirst-o
rderlo
gic.
To
that
end,give
na
signatu
reΣ
,we
intro
duce
the
notio
nofa
structu
re
S=〈U
,J〉
(109)
with
1.
the
unive
rseU
,a
non-e
mpty
set
conta
inin
gall
the
valu
es
that
can
occu
rw
hen
eva
luatin
gte
rms,
2.
the
inte
rpre
tatio
nJ
ofall
functio
nand
pre
dica
tesym
bols
ofΣ
.
D.Suenderm
ann
Logic
January
28,2012
73
.In
terp
reta
tion
.
Form
ally,
Jis
defined
as
1.
Eve
ryfu
nctio
nsym
bolf∈
Fw
ithth
earity
n=
arity(f)
ism
apped
toan
n-ary
functio
n
fJ
:U×···×
U︸
︷︷
︸
ntim
es
→U
.(110)
2.
Eve
rypre
dica
tesym
bolp∈
Pw
ithth
earity
n=
arity(f)is
mapped
toan
n-ary
rela
tion
pJ⊆
Un.
(111)
3.
If=∈
Pth
en
itsin
terp
reta
tion
should
be
natu
ral,
i.e.
=J
=〈u
,v〉|u
,v∈
U∧
u=
v.
(112)
D.Suenderm
ann
Logic
January
28,2012
74
.Stru
cture
s:exa
mple
.
U
sing
Σa
as
inth
eabove
exa
mple
,we
define
astru
cture
Sa
=〈U
,J〉
(113)
as
follo
ws:
1.
U=a,b
2.0
J=
a
3.1
J=
b
4.
+J
=〈〈a
,a〉,
a〉,〈〈a
,b〉,
b〉,〈〈b
,a〉,
b〉,〈〈b
,b〉,
a〉
5.·J
=〈〈a
,a〉,
a〉,〈〈a
,b〉,
a〉,〈〈b
,a〉,
a〉,〈〈b
,b〉,
b〉
6.
=J
=〈a
,a〉,〈b
,b〉
7.≤
J=〈a
,a〉,〈a
,b〉,〈b
,b〉
D.Suenderm
ann
Logic
January
28,2012
75
.Varia
ble
assig
nm
ent
.
Give
na
signatu
reΣ
and
astru
cture
S=〈U
,J〉,
we
define
avaria
ble
assig
nm
ent
I:V→
U(114)
assig
nin
ga
valu
efro
mth
eunive
rseU
toeve
ryvaria
ble
inV
.
E.g
.,usin
gth
esig
natu
reΣ
aand
the
structu
reS
a,a
possib
levaria
ble
assig
nm
ent
is
Ia
=〈x
,a〉,〈y
,b〉,〈z
,a〉
.(115)
D.Suenderm
ann
Logic
January
28,2012
76
.Varia
ble
assig
nm
ent
.
Furth
erm
ore
,we
intro
duce
the
variable
repla
cem
ent
I[x
1/c1]···[x
n/c
n](y
)=
c1
:y
=x
1;
...
cn
:y
=x
n;
I(y
):
oth
erw
ise
(116)
with
x1,...,x
n,y∈
Vand
c1,...,c
n∈
Ure
pla
cing
the
valu
eofa
variable
yby
ci
ifth
evaria
ble
happens
tobe
identica
lto
xi .
Usin
gth
eabove
exa
mple
,we
have
Ia[y
/a][z
/b]=〈x
,a〉,〈y
,a〉,〈z
,b〉
.(117)
D.Suenderm
ann
Logic
January
28,2012
77
.Eva
luatio
nofte
rms
.
Give
na
signatu
reΣ
,a
structu
reS
=〈U
,J〉,
and
avaria
ble
assig
nm
ent
I,fo
reve
ryte
rmt,
itsva
lue
(writte
nas
S(I
,t))
can
be
derive
d
inductive
lyas
1.∀x(x∈
V→
S(I
,x)
=I(x
))
2.
Iff∈
Fand
n=
arity(f)
and
t1 ,
...,tn∈
TΣ
then
S(I
,f(t
1 ,...,tn))
=f
J(S
(I,t1 ),
...,S(I
,tn)).
(118)
Exe
rcise:U
sing
the
above
signatu
reΣ
a,stru
cture
Sa,and
variable
assig
nm
ent
Ia,w
hat
isth
eeva
luatio
nofTerm
4:
S(I
a,(1
+x)·y)?
(119)
D.Suenderm
ann
Logic
January
28,2012
78
.Eva
luatio
nofato
mic
form
ula
s.
Give
na
signatu
reΣ
,a
structu
reS
=〈U
,J〉,
and
avaria
ble
assig
nm
ent
I,fo
reve
ryato
mic
form
ula
p(t
1 ,...,tn),
itsva
lue
can
be
derive
das
S(I
,p(t
1 ,...,tn))
=
1:〈S
(I,t1 ),
...,S(I
,tn)〉∈
pJ,
0:
oth
erw
ise.
(120)
Exe
rcise:U
sing
the
above
signatu
reΣ
a,stru
cture
Sa,and
variable
assig
nm
ent
Ia,w
hat
isth
eeva
luatio
nofForm
ula
93:
S(I
,(1
+x)·y
=0)?
(121)
D.Suenderm
ann
Logic
January
28,2012
79
.Eva
luatio
noffo
rmula
s.
Give
na
signatu
reΣ
,a
structu
reS
=〈U
,J〉,
and
avaria
ble
assig
nm
ent
I,fo
reve
ryfo
rmula
f∈
FΣ,its
valu
eca
nbe
derive
din
ductive
lyas
1.
S(I
,0)
=0;S(I
,1)
=1
2.
S(I
,¬
f)
=I
¬(S
(I,f))
3.
S(I
,f∨
g)
=I
∨(S
(I,f),
S(I
,g))
4.
S(I
,f∧
g)
=I
∧(S
(I,f),
S(I
,g))
5.
S(I
,f→
g)
=I
→(S
(I,f),
S(I
,g))
6.
S(I
,f↔
g)
=I
↔(S
(I,f),
S(I
,g))
7.
S(I
,∀x(f
)=
1:∀c(c∈
U→
S(I
[x/c],
f)
=1)
0:
oth
erw
ise
8.
S(I
,∃x(f
)=
1:∃c(c∈
U∧
S(I
[x/c],
f)
=1)
0:
oth
erw
ise
D.Suenderm
ann
Logic
January
28,2012
80
.Eva
luatio
noffo
rmula
s:exe
rcise.
U
sing
the
above
signatu
reΣ
a,stru
cture
Sa,and
variable
assig
nm
ent
Ia,
dete
rmin
eth
eeva
luatio
nofth
efo
llow
ing
form
ula
s:
1.∃x((1
+x)·y
=0),
2.∀x((1
+x)·y
=0),
3.∀x,y((1
+x)·y
=0),
4.∀x∃y((1
+x)·y
=0),
5.∀y∃x((1
+x)·y
=0→∀z(x·z
=0)).
D.Suenderm
ann
Logic
January
28,2012
81
.U
nive
rsalva
lidity
.
If
fis
afo
rmula
resu
lting
in
S(I
,f)
=1
(122)
for
eve
rypossib
levaria
ble
assig
nm
ent
I,th
en
fis
unive
rsally
valid
.
Bein
gth
eequiva
lent
toa
tauto
logy
inpro
positio
nallo
gic,
unive
rsal
valid
ityofa
form
ula
fis
writte
nas
|=f.
(123)
Iffre
e(f
)=,th
en
S(I
,f)
does
not
depend
on
I.In
this
case
,f
is
calle
da
close
dfo
rmula
.
For
close
dfo
rmula
s,we
use
an
abbre
viate
dte
rmin
olo
gy:
S(f
):=
S(I
,f)
iffre
e(f
)=.
(124)
Also
,in
the
case
that
S(f
)=
1,
(125)
we
sayth
at
the
structu
reS
isa
modelfo
rf
writte
nas
S|=
f.
(126)
D.Suenderm
ann
Logic
January
28,2012
82
.Equiva
lence
,(u
n)sa
tisfiability
.
Also
the
notio
ns
ofequiva
lence
and
(un)sa
tisfiability
arein
herite
dfro
m
pro
positio
nallo
gic.
Two
form
ula
sf
and
gare
equiva
lent
iff
|=f↔
g.
(127)
Ase
toffo
rmula
sM⊆
FΣ
issa
tisfiable
,if
there
isa
variable
assig
nm
ent
Isu
chth
at
∀m
(m∈
M→
S(I
,m
)=
1).
(128)
Oth
erw
ise,
Mis
calle
dunsa
tisfiable
writte
nas
M|=
0.
(129)
D.Suenderm
ann
Logic
January
28,2012
83
.Is
afo
rmula
unsa
tisfiable
?.
O
ur
next
goalis
todefine
an
alg
orith
mth
at
check
sw
heth
er
M|=
0.
(130)
In
genera
l,th
isquestio
nis
undecid
able
(as
show
nla
ter).
We
will,
howeve
r,be
able
todefine
aca
lculu
s⊢
for
which
we
have
M⊢
0↔
M|=
0.
(131)
This
calcu
lus
will
be
base
don
ase
mi-d
ecisio
nalg
orith
m.
I.e.,
ifin
deed
M|=
0,th
ealg
orith
mw
illeve
ntu
ally
disco
verth
isfa
ct.
If,howeve
r,M
issa
tisfiable
,th
ealg
orith
mm
ayru
nete
rnally.
Motiva
tion
ofse
mi-d
ecid
ability:
Gold
bach
conje
cture
.
D.Suenderm
ann
Logic
January
28,2012
84
.Im
porta
nt
equiva
lence
s.
In
ord
erto
define
the
calcu
lus⊢,we
will
transfo
rmfo
rmula
sin
to
first-o
rdercla
use
s.
This
transfo
rmatio
nw
illm
ake
use
ofth
efo
llow
ing
equiva
lence
s(in
additio
nto
the
ones
we
know
from
pro
positio
nallo
gic):
21.|=¬∀x(f
)↔∃x(¬
f)
22.|=¬∃x(f
)↔∀x(¬
f)
23.|=∀x(f
)∧∀x(g
)↔∀x(f∧
g)
24.|=∃x(f
)∨∃x(g
)↔∃x(f∨
g)
25.|=∀x,y(f
)↔∀y,x(f
)
26.|=∃x,y(f
)↔∃y,x(f
)
27.
Ifx∈
V∧
x6∈
free(f
)th
en
a)|=∀x(f
)↔
f
b)|=∃x(f
)↔
f
D.Suenderm
ann
Logic
January
28,2012
85
.Im
porta
nt
equiva
lence
s(co
nt.)
.
28.
Ifx∈
V∧
x6∈
free(g
)∪
bound(g
)th
en
a)|=∀x(f
)∨
g↔∀x(f∨
g)
b)|=∃x(f
)∧
g↔∃x(f∧
g)
c)|=
g∨∀x(f
)↔∀x(g∨
f)
d)|=
g∧∃x(f
)↔∃x(g∧
f)
Ince
rtain
situatio
ns,
itis
nece
ssaryto
renam
ebound
variable
s.
Iff∈
FΣ
and
x,y∈
Vth
en
f[x
/y]is
the
form
ula
which
we
obta
inby
repla
cing
eve
ryoccu
rrence
of
xby
z.
For
exa
mple
(∀u∃v(P
(u,v)))[u
/z]=∀z∃v(P
(z,v)).
(132)
This
leads
us
toourla
stequiva
lence
:
29.
Ifx∈
bound(f
)∧
y6∈
free(f
)∪
bound(f
)th
en
|=f↔
f[x
/y]
D.Suenderm
ann
Logic
January
28,2012
86
.Pre
nex
norm
alfo
rm.
The
above
equiva
lence
sca
nbe
use
dto
rew
ritean
arbitrary
form
ula
such
that
all
quantifi
ers
appear
at
the
begin
nin
gofth
efo
rmula
.
This
repre
senta
tion
isca
lled
pre
nex
norm
alfo
rm.
Exa
mple
1:
∀x(p
(x))→∃x(p
(x))
(close
d)
12↔¬∀x(p
(x))∨∃x(p
(x))
21↔∃x(¬
p(x
))∨∃x(p
(x))
24↔∃x(¬
p(x
)∨
p(x
))
2↔∃x(1
)
27b↔
1(u
nive
rsally
valid
)(133)
D.Suenderm
ann
Logic
January
28,2012
87
.Pre
nex
norm
alfo
rm:exa
mple
.
Exa
mple
2:
∃x(p
(x))→∀x(p
(x))
(close
d)
12↔¬∃x(p
(x))∨∀x(p
(x))
21↔∀x(¬
p(x
))∨∀x(p
(x))
29↔∀x(¬
p(x
))∨∀y(p
(y))
28a↔∀x(¬
p(x
)∨∀y(p
(y)))
28c↔∀x,y(¬
p(x
)∨
p(y
))(134)
This
form
ula
says,if
there
isat
least
one
xtu
rnin
gp(x
)tru
eth
en
p(x
)
isalw
aystru
e.
Intu
rn,if
there
isno
xtu
rnin
gp(x
)tru
eth
en
p(x
)is,
logica
lly,alw
ays
false
.
Conse
quently,
p(x
)is
independently
of
xeith
ertru
eorfa
lse(a
pro
positio
nalvaria
ble
).
D.Suenderm
ann
Logic
January
28,2012
88
.Equisa
tisfiability
.
The
next
norm
aliza
tion
step
require
sa
wid
er
notio
nofequiva
lence
.
W
ew
illre
fer
toit
as
equisa
tisfiability.
Consid
erth
eexa
mple
form
ula
s
f1
=∀x∃y(p
(x,y))
(135)
and
f2
=∀x(p
(x,s(x
))).(136)
f1
and
f2
arenot
equiva
lent.
E.g
.,p(x
,y)
:=x
>y.
They
do
not
eve
nuse
the
sam
esig
natu
re(f
2use
sth
efu
nctio
nsym
bols
not
existin
gin
f1 ).
D.Suenderm
ann
Logic
January
28,2012
89
.Equisa
tisfiability
(cont.)
.
H
oweve
r,we
can
rela
tef1
and
f2
as
follo
ws:
If
astru
cture
S1
isa
modelfo
rf1,i.e
.,
S1(f
1 )=
1(137)
then
itca
nbe
exte
nded
toa
structu
reS
2bein
ga
modelfo
rf2 ,
S2(f
2 )=
1.
(138)
This
can
be
done
by
definin
gan
inte
rpre
tatio
ns
Jsu
chth
at
p(x
,s(x
))(139)
istru
efo
rall
possib
lex
ofth
eunive
rse.
Inour
above
exa
mple
,th
isco
uld
for
insta
nce
be
s(x
):=
x−
1.
Form
ally,
two
form
ula
sf1
and
f2
areequisa
tisfiable
if
|=S
1(f
1 )↔
S2(f
2 )(140)
also
writte
nas
f1≈
f2.
(141)
D.Suenderm
ann
Logic
January
28,2012
90
.Sko
lem
izatio
n.
W
eare
give
na
signatu
reΣ
=〈V
,F
,P
,arity〉
and
aclo
sed
form
ula
fof
the
formf
=∀x
1,...,x
n∃y(g
(x1,...,x
n,y)).
(142)
W
ech
oose
anew
n-ary
functio
nsym
bols6∈
Fand
exte
nd
the
signatu
re:
Σ′=〈V
,F∪s,P
,arity∪〈s
,n〉〉.
(143)
Now
,we
define
the
form
ula
f′as
follo
ws:
f′:=
skole
m(f
):=∀x
1,...,x
n(g
(x1,...,x
n,s(x
1,...,x
n))).
(144)
Here
,we
have
dro
pped
the
existe
ntia
lquantifi
er.
Eve
ryoccu
rrence
ofth
evaria
ble
yhas
been
repla
ced
by
the
term
s(x
1,...,x
n).
For
the
resu
lting
form
ula
f′,
we
have
f′≈
f.
(145)
D.Suenderm
ann
Logic
January
28,2012
91
.Sko
lem
izatio
n:exa
mple
s.
f1
=∀x,y∃z(p
(x,y,z)),
skole
m(f
1 )=∀x,y(p
(x,y,s1z(x
,y)));
f2
=∀x∃y∀z(p
(x,y,z)),
skole
m(f
2 )=∀x,z(p
(x,s2y(x
),z));
f3
=∃x∀y∃z(p
(x,y,z)),
skole
m(f
3 )=∀y∃z(p
(s3x,y,z)),
skole
m(sko
lem
(f3 ))
=∀y(p
(s3x,y,s3z(y
)))(146)
D.Suenderm
ann
Logic
January
28,2012
92
.Cla
usa
lnorm
alfo
rm.
This
alg
orith
mtu
rns
an
first-o
rderfo
rmula
fin
tocla
usa
lnorm
alfo
rm:
1.
Conve
rtf
into
pre
nex
norm
alfo
rm.
2.
Elim
inate
all
existe
ntia
lquantifi
ers
by
skole
miza
tion.The
resu
ltis
a
form
ula
ofth
efo
rm
f′=∀x
1,...,x
n(g
)(147)
where
gco
nta
ins
no
quantifi
ers.
3.
Sin
ceg
conta
ins
only
ato
mic
form
ula
sco
nnecte
dby
logica
l
connective
s,it
can
be
turn
ed
into
conju
nctive
norm
alfo
rmw
hich
pro
duce
s
f′′=∀x
1,...,x
n(d
1∧···∧
dm
)(148)
where
di
aredisju
nctio
ns
oflite
rals
(infirst-o
rderlo
gic,
litera
lsare
ato
mic
form
ula
sor
their
negatio
ns).
D.Suenderm
ann
Logic
January
28,2012
93
.Cla
usa
lnorm
alfo
rm(co
nt.)
.
4.
Applyin
gEquiva
lence
23,th
eunive
rsalquantifi
ers
can
be
distrib
ute
d
onto
all
di s
resu
lting
inth
ecla
usa
lnorm
alfo
rm
f′′′=
c1∧···∧
cm
with
ci=∀x
1,...,x
n(d
i ),(149)
aco
nju
nctio
nofth
efirst-o
rdercla
use
sc1,...,c
m.
5.
This
nota
tion
can
furth
erbe
simplifi
ed
by
agre
ein
gth
at
all
free
variable
sare
implicite
lyunive
rsally
quantifi
ed:
f(4)
=d
1∧···∧
dm
⇔d
1,...,d
m.
(150)
D.Suenderm
ann
Logic
January
28,2012
94
.Cla
usa
lnorm
alfo
rm:exe
rcise.
Turn
the
follo
win
gfo
rmula
sin
tocla
usa
lnorm
alfo
rm:
1.
f1
=∀y∃x((1
+x)·y
=0→∀z(x·z
=0)),
2.
f2
=∃x,y(p
(x)∧
p(y
)↔∃z(p
(z))),
3.¬
f2.
For
Task
1,give
nth
estru
cture
Sa,find
afu
nctio
nin
gin
terp
reta
tion
of
the
skole
mfu
nctio
nre
pla
cing
the
variable
x.
D.Suenderm
ann
Logic
January
28,2012
95
.Pro
vability
.
O
ur
goalis
tofind
out
wheth
er
afo
rmula
fis
unive
rsally
valid
:
|=f.
(151)
This
isth
esa
me
as
tote
llw
heth
er
f’s
negatio
nis
unsa
tisfiable
:
¬
f|=
0.
(152)
This
can
be
done
by
1.
transfo
rmin
g¬
fin
tocla
usa
lnorm
alfo
rm
c1∧···∧
cm≈¬
f,
(153)
2.
trying
topro
vein
consiste
ncy
from
the
set
ofcla
use
s:
c1,...,c
m⊢.
(154)
D.Suenderm
ann
Logic
January
28,2012
96
.Pro
vability:
exa
mple
.
W
ewant
tofind
out
wheth
erth
efo
rmula
f:=∃x∀y(p
(x,y))→∀y∃x(p
(x,y))
(155)
isunive
rsally
valid
.
This
can
be
done
by
usin
gth
epro
vability
alg
orith
m:
1.
Tra
nsfo
rmin
g¬
fin
tocla
usa
lnorm
alfo
rm:
1.1
Conve
rsion
into
pre
nex
norm
alfo
rm:
¬(∃
x∀y(p
(x,y))→∀y∃x(p
(x,y)))
12↔¬
(¬∃x∀y(p
(x,y))∨∀y∃x(p
(x,y)))
11↔∃x∀y(p
(x,y))∧¬∀y∃x(p
(x,y))
21↔∃x∀y(p
(x,y))∧∃y¬∃x(p
(x,y))
22↔∃x∀y(p
(x,y))∧∃y∀x(¬
p(x
,y))
29↔∃x∀y(p
(x,y))∧∃v∀u(¬
p(u
,v))
28b↔∃x(∀
y(p
(x,y))∧∃v∀u(¬
p(u
,v)))
D.Suenderm
ann
Logic
January
28,2012
97
.Pro
vability:
exa
mple
(cont.)
.
28d↔∃x,v(∀
y(p
(x,y))∧∀u(¬
p(u
,v)))
27a↔∃x,v(∀
y(p
(x,y))∧∀y,u(¬
p(u
,v)))
23↔∃x,v∀y(p
(x,y)∧∀u(¬
p(u
,v)))
27a↔∃x,v∀y(∀
u(p
(x,y))∧∀u(¬
p(u
,v)))
23↔∃x,v∀y,u(p
(x,y)∧¬
p(u
,v))
=:
f′
(156)
1.2
Sko
lem
izatio
n:
–f
′is
ofth
efo
rm
f′=∃x(g
(x))
with
g=∃v∀y,u(p
(x,y)∧¬
p(u
,v)).
(157)
–H
ere
,g
is1-ary
since
there
areno
unive
rsalquantifi
ers
infro
nt
of
the
existe
ntia
lquantifi
er.
D.Suenderm
ann
Logic
January
28,2012
98
.Pro
vability:
exa
mple
(cont.)
.
–Conse
quently,
skole
miza
tion
intro
duce
sth
e0-ary
functio
ns
x
repla
cing
x:
f′′
=sko
lem
(f′)
=g(s
x())
=g(s
x)
=∃v∀y,u(p
(sx,y)∧¬
p(u
,v)).
(158)
–In
ase
cond
step,th
eexiste
ntia
lquantifi
erin
front
of
vis
repla
ced
by
skole
miza
tion:
f′′′
=sko
lem
(f′′)
=∀y,u(p
(sx,y)∧¬
p(u
,s
v)
︸︷︷
︸
h
).(159)
1.3
-5Cla
usa
lnorm
alfo
rm:
Sin
ceh
isalre
ady
inco
nju
nctive
norm
alfo
rm,we
have
f(4)=
p(s
x,y)∧¬
p(u
,s
v).
(160)
D.Suenderm
ann
Logic
January
28,2012
99
.Pro
vability:
exa
mple
(cont.)
.
2.
Pro
ving
inco
nsiste
ncy:
–W
eare
give
ncla
usa
lnorm
alfo
rm
M:=p(s
x,y)
,¬
p(u
,s
v).
(161)
–Sin
ceall
variable
sin
first-o
rdercla
use
sare
implicite
lyunive
rsally
bound,we
can
substitu
tey
by
sv
and
uby
sx
resu
lting
in
M⊢p(s
x,s
v)
,¬
p(s
x,s
v).
(162)
–Applica
tion
ofth
ecu
tru
legive
s
M⊢.
(163)
–Conse
quently,
we
have
show
nth
at
|=f.
(164)
D.Suenderm
ann
Logic
January
28,2012
100
.Substitu
tion
.
In
the
pro
vability
exa
mple
,we
have
“guesse
d”
the
term
ss
xand
sv
tobe
able
toapply
the
cut
rule
.
W
enow
want
tostu
dy
am
eth
od
todo
system
atica
llyca
lcula
tete
rms
which
the
cut
rule
can
be
applie
dto
.
Inord
erto
do
so,fo
ra
give
nsig
natu
reΣ
,we
define
asu
bstitu
tion
σ=〈x
1,t1 〉,
...,〈x
n,tn〉
=:[x
17→
t1 ,
...,x
n7→
tn]
(165)
with
xi∈
V,ti∈
TΣ
for
i∈1,...,n
and
xi6=
xj
for
i6=
j.(166)
The
dom
ain
ofth
esu
bstitu
tion
isdefined
as
dom
(σ)
=x
1,...,x
n.
(167)
D.Suenderm
ann
Logic
January
28,2012
101
.A
pplica
tion
ofa
substitu
tion
.
Give
na
term
tand
asu
bstitu
tion
σ,we
define
the
applica
tion
of
σto
t
(writte
ntσ
)in
ductive
lyas
1.
xi σ
:=ti
for
xi∈
dom
(σ),
2.
yσ
:=y
for
y∈
V∧
y6∈
dom
(σ),
3.
f(s
1,...,s
m)σ
:=f(s
1σ,...,s
mσ)
oth
erw
ise.
Exa
mple
:W
eare
give
nth
esu
bstitu
tion
σ=
[x7→
c,y7→
f(d
)].(168)
Then,we
have
the
follo
win
gapplica
tions:
1.
zσ
=z,
2.
f(y
)σ=
f(f
(d)),
3.
h(x
,g(y
))σ=
h(c
,g(f
(d))),
4.p(y
),q(d
,h(z
,x))
σ=p(f
(d)),
q(d
,h(z
,c))
.
D.Suenderm
ann
Logic
January
28,2012
102
.Syn
tactica
lequatio
ns
and
unifi
ers
.
A
synta
cticalequatio
n(S
E)
isa
constru
ctofth
efo
rms
.=t
where
sand
tare
eith
er
both
term
sor
both
ato
mic
form
ula
s.
A
system
ofsyn
tactica
lequatio
ns
(SSE)
isa
set
ofSEs:
E:=s1
.=t1 ,
...,s
n.=
tn.
(169)
Give
nan
SSE
Eand
asu
bstitu
tion
σ,we
define
the
applica
tion
of
σto
Eas
Eσ
:=s1σ
.=t1 σ
,...,s
nσ
.=tnσ.
(170)
Asu
bstitu
tion
σso
lves
an
SE
s.=
tiff
we
have
sσ
=tσ
.
IfE
isan
SSE
then
the
substitu
tion
σis
calle
da
unifi
eriff
itso
lves
eve
ry
SE
inE
.
Exa
mple
:Show
that
σ=
[x17→
x2,x
37→
f(x
4)]
(171)
isa
unifi
erofth
eSSE
E=p(f
(x4))
.=p(x
3),
q(x
1,x
2)
.=q(x
2,x
1)
.(172)
D.Suenderm
ann
Logic
January
28,2012
103
.U
nifi
catio
n.
W
enow
want
tostu
dy
an
alg
orith
mca
lcula
ting
aunifi
er
σfo
ra
give
n
SSE
E.
A
num
berofre
ductio
nru
les
will
transfo
rma
tuple
consistin
gofan
SSE
and
asu
bstitu
tion
into
anoth
ersu
chtu
ple
:
〈E1,σ
1〉 〈E
2,σ
2〉.
(173)
Here
com
eth
ere
ductio
nru
les:
1.
Ify∈
V∧
t∈
TΣ∧
y6∈
var(t)th
en
〈E∪y
.=t
,σ〉 〈E
[y7→
t],σ∪〈y
,t〉〉.
(174)
–If
an
SSE
conta
ins
an
SE
ofth
efo
rmy
.=t
where
yis
avaria
ble
not
conta
ined
inte
rmt
then
the
SE
isso
lved
by
the
substitu
tion
[y7→
t].
–Conse
quently,
the
SE
can
be
dro
pped
infa
vor
ofapplyin
gth
e
substitu
tion
toall
oth
erSEs
inth
eSSE
and
addin
git
toσ.
–E.g
.,x
.=s(y
).
D.Suenderm
ann
Logic
January
28,2012
104
.U
nifi
catio
n(co
nt.)
.
2.
Ify∈
V∧
t∈
TΣ∧
y∈
var(t)∧
y6=
tth
en
〈E∪y
.=t
,σ〉
Ω.
(175)
–If
an
SSE
conta
ins
an
SE
ofth
efo
rmy
.=t
where
yis
avaria
ble
conta
ined
inte
rmt
but
not
titse
lfth
en
the
SE
isnot
solva
ble
.
–That
isbeca
use
eve
rypossib
lete
rmwe
can
substitu
tefo
ry
will
also
affect
tand
render
itdiff
ere
nt.
–E.g
.,x
.=s(x
).
3.
Ify∈
V∧
t∈
TΣ∧
t6∈
Vth
en
〈E∪t
.=y,σ〉 〈E∪y
.=t
,σ〉.
(176)
–M
ove
sth
evaria
ble
toth
efro
nt.
–E.g
.,s(y
).=
x.
4.
〈E∪t
.=t
,σ〉 〈E
,σ〉.
(177)
–D
rops
trivialSEs.
–E.g
.,s(y
).=
s(y
).
D.Suenderm
ann
Logic
January
28,2012
105
.U
nifi
catio
n(co
nt.)
.
5.
Iff∈
F∪
P∧
n=
arity(f)∧
s1,...,s
n,t1 ,
...,tn∈
TΣ
then
〈E∪f(s
1,...,s
n)
.=f(t
1 ,...,tn)
,σ〉
〈E∪s1
.=t1 ,
...,s
n.=
tn,σ〉.
(178)
–Fro
mth
earg
um
ents
ofan
n-ary
functio
n(p
redica
te)
pre
sent
on
both
sides
ofan
SE,
nin
divid
ualSEs
arederive
d.
–E.g
.,s(s
(x),
y)
.=s(y
,z).
6.
Iff,g∈
F∪
P∧
f6=
g∧
m=
arity(f)∧
n=
arity(g)
∧s1,...,s
m,t1 ,
...,tn∈
TΣ
then
〈E∪f(s
1,...,s
m)
.=g(t
1 ,...,tn)
,σ〉
Ω.
(179)
–D
iffere
nt
functio
ns
(pre
dica
tes)
cannot
be
unifi
ed.
–E.g
.,f(x
).=
g(x
).
D.Suenderm
ann
Logic
January
28,2012
106
.U
nifi
catio
nalg
orith
m.
Give
nan
SSE
E,to
dete
rmin
ea
unifi
er,
we
startoff
with
an
em
pty
substitu
tion:
〈E,[]〉.
(180)
Now
,we
apply
the
reductio
nru
les
until
we
have
eith
er
ofth
efo
llow
ing
case
s:
a)
We
can
derive
Ωm
eanin
gth
at
Eis
not
solva
ble
.
b)
We
can
show
that
〈E,[]〉 〈,σ〉.
(181)
Here
,σ
isth
eunifi
erof
Ealso
writte
nas
σ=
mgu(E
)(182)
(the
most
genera
lunifi
er)
with
the
specia
lca
se
mgu(s
,t)
:=m
gu(
s.=
t).
(183)
D.Suenderm
ann
Logic
January
28,2012
107
.U
nifi
catio
n:exa
mple
.
W
eare
give
nan
SSE
with
asin
gle
SE:
E=p(x
1,f(x
4))
.=p(x
2,x
3)
with
(184)
V=x
1,...
,F
=f,P
=.
N
ow
,we
atte
mpt
todete
rmin
ea
unifi
er:
〈p(x
1,f(x
4))
.=p(x
2,x
3)
,[]〉
5 〈
x1
.=x
2,f(x
4 ).=
x3,[]〉
1 〈
f(x
4)
.=x
3,[x
17→
x2]〉
3 〈
x3
.=f(x
4)
,[x
17→
x2]〉
1 〈,[x
17→
x2,x
37→
f(x
4)]〉
(185)
That
is,we
have
mgu(E
)=
mgu(p
(x1,f(x
4)),
p(x
2,x
3))
=[x
17→
x2,x
37→
f(x
4)].
(186)
D.Suenderm
ann
Logic
January
28,2012
108
.U
nifi
catio
n:exe
rcise.
D
ete
rmin
e,if
possib
le,a
unifi
er
ofth
efo
llow
ing
SSEs:
a)
E1
=p(d
,x
4)
.=p(x
2,h(c
,d)),
q(h
(d,x
1))
.=q(x
4)
,
b)
E2
=p(h
(x1,c))
.=p(x
2),
q(x
2,d)
.=q(h
(d,c),
x4)
,
c)E
3=p(h
(x2,d))
.=p(h
(x1,d)),
q(x
1,c)
.=q(h
(x2,d),
c)
.
Inth
ese
exe
rcises,
assu
me
V=x
1,...
,F
=c,d,h,P
=p,q.
D.Suenderm
ann
Logic
January
28,2012
109
.First-o
rderre
solu
tion
.
The
first-o
rderca
lculu
sm
ake
suse
oftw
oin
fere
nce
rule
swe
will
define
next.
The
first-o
rder
reso
lutio
nru
leexp
ects
1.
two
first-o
rdercla
use
sc1
and
c2
and
2.
two
ato
mic
form
ula
sp(s
1,...,s
n)
and
p(t
1 ,...,tn)
whose
synta
cticalequatio
nis
solva
ble
,i.e
.,we
can
dete
rmin
eth
eunifi
er
µ=
mgu(p
(s1,...,s
n),
p(t
1,...,tn)).
(187)
Then,th
isis
the
definitio
nofth
ere
solu
tion
rule
:
c1∪p(s
1,...,s
n)
,c2∪¬
p(t
1 ,...,tn)
∴c1µ∪
c2µ
The
reso
lutio
nru
lem
ake
suse
ofth
ecu
tru
leand
the
substitu
tion
rule
c
∴cσ
where
cis
afirst-o
rdercla
use
and
σis
asu
bstitu
tion.
D.Suenderm
ann
Logic
January
28,2012
110
.First-o
rder
reso
lutio
n:varia
ble
renam
ing
.
W
hen
applyin
gth
ere
sultio
nru
le,it
isso
metim
es
nece
ssaryto
renam
e
variable
s.
In
the
follo
win
gfirst-o
rdercla
use
set
M=p(x
),¬
p(f
(x)),
(188)
unifi
catio
nw
illre
sult
inΩ
since
both
invo
lved
clause
suse
the
sam
e
variable
x.
Substitu
ting
xby
yin
one
ofth
ecla
use
sdoes
not
change
sem
antics
M′=p(x
),¬
p(f
(y))
(189)
simply
beca
use
∀x(¬
p(f
(x)))
29↔∀y(¬
p(f
(y))).
(190)
Now
,we
areable
todete
rmin
eth
eunifi
er
µ=
mgu(p
(x),
p(f
(y)))
=[x7→
f(y
)](191)
Inco
nclu
sion,we
can
pro
veco
ntra
dictio
nby
applyin
gth
ere
sultio
nru
le:
p(x
),¬
p(f
(y))
res.
[x7→
f(y)]
⊢.
(192)
D.Suenderm
ann
Logic
January
28,2012
111
.Facto
rizatio
n:m
otiva
tion
.
Consid
erth
efo
llow
ing
exa
mple
M=p(x
),p(y
),¬
p(x
),¬
p(y
)
(193)
Applica
tion
ofth
ere
solu
tion
rule
usin
gc1
=p(x
)and
c2
=¬
p(x
)and
the
unifi
er
µ=
mgu(p
(y),
p(y
))=
[]pro
duce
s
p(x
),p(y
),¬
p(x
),¬
p(y
)
res.
[]
⊢p(y
),¬
p(y
)
⊢1.
(194)
D.Suenderm
ann
Logic
January
28,2012
112
.Facto
rizatio
n:m
otiva
tion
(cont.)
.
This
resu
ltdoes
not
help
since
we
areatte
mptin
gto
pro
veco
ntra
dictio
n.
In
stead,one
could
facto
rizeM
as
follo
ws:
p(x
),p(y
),¬
p(x
),¬
p(y
)
↔p(x
),p(y
),¬
p(v
),¬
p(w
)
↔∀x,y,v,w
((p(x
)∨
p(y
))∧
(¬p(v
)∨¬
p(w
)))
↔∀x,y,v,w
(p(x
)∧¬
p(v
)∨
p(x
)∧¬
p(w
)∨
p(y
)∧¬
p(v
)∨
p(y
)∧¬
p(w
))
↔∀x,v(p
(x)∧¬
p(v
))∨∀x,w
(p(x
)∧¬
p(w
))∨
∀y,v(p
(y)∧¬
p(v
))∨∀y,w
(p(y
)∧¬
p(w
)))
↔∀x(p
(x))∧∀x(¬
p(x
))∨∀x(p
(x))∧∀x(¬
p(x
))∨
∀y(p
(y))∧∀y(¬
p(y
))∨∀y(p
(y))∧∀y(¬
p(y
)))
↔∀x(p
(x)∧¬
p(x
))∨∀y(p
(y)∧¬
p(x
))
↔0.
(195)
D.Suenderm
ann
Logic
January
28,2012
113
.Facto
rizatio
n:m
otiva
tion
(cont.)
.
Anoth
erpossib
ilityis,
as
inpro
positio
nallo
gic,
toapply
case
distin
ction
toacco
unt
for
multip
leoccu
rrence
sofnegate
dlite
rals:
Pickp(x
):
p(x
),p(x
),p(y
),¬
p(x
),¬
p(y
)
res.
[]
⊢p(x
),p(x
),p(y
),¬
p(y
)
res.
[x7→
y]
⊢,p(x
),p(y
)
⊢0.
(196)
D.Suenderm
ann
Logic
January
28,2012
114
.Facto
rizatio
n:m
otiva
tion
(cont.)
.
Pick¬p(x
)↔¬∀x(p
(x))↔∃x(¬
p(x
))≈¬
p(s
)↔¬
p(s
):
¬
p(s
),p(x
),p(y
),¬
p(x
),¬
p(y
)
res.
[x7→
s]
⊢¬
p(s
),p(y
),¬
p(x
),¬
p(y
)
res.
[y7→
s]
⊢,¬
p(x
),¬
p(y
)
⊢0.
(197)
So,in
conclu
sion,we
have
p(x
),p(y
),¬
p(x
),¬
p(y
)⊢
0.
(198)
D.Suenderm
ann
Logic
January
28,2012
115
.Facto
rizatio
n.
In
genera
l,we
acco
unt
for
multip
leoccu
rrence
sofunifi
able
pre
dica
tes
in
acla
use
by
means
offa
ctoriza
tion
rule
s.
Give
n
1.
the
first-o
rdercla
use
cand
2.
two
ato
mic
form
ula
sp(s
1,...,s
n)
and
p(t
1 ,...,tn)
whose
synta
cticalequatio
nis
solva
ble
,i.e
.,we
can
dete
rmin
eth
eunifi
er
µ=
mgu(p
(s1,...,s
n),
p(t
1,...,tn)).
(199)
Then,th
ese
areth
edefinitio
ns
ofth
efa
ctoriza
tion
rule
s:
c∪p(s
1,...,s
n),
p(t
1 ,...,tn)
∴cµ∪p(s
1,...,s
n)µ
and
c∪¬
p(s
1,...,s
n),¬
p(t
1 ,...,tn)
∴cµ∪¬
p(s
1,...,s
n)µ
D.Suenderm
ann
Logic
January
28,2012
116
.Facto
rizatio
n:exa
mple
.
Retu
rnin
gto
the
above
exa
mple
,applica
tion
ofth
efa
ctoriza
tion
rule
s
pro
duce
s
p(x
),p(y
),¬
p(x
),¬
p(y
)
fact.
⊢p(y
),¬
p(x
),¬
p(y
)
fact.
⊢p(y
),¬
p(y
)
res.
[]
⊢0.
(200)
D.Suenderm
ann
Logic
January
28,2012
117
.U
nifi
catio
n/re
solu
tion/fa
ctoriza
tion:exe
rcise.
Can
you
derive
contra
dictio
nfro
mth
efo
llow
ing
clause
sets?
a)
M1
=¬
p(y
,y)
,p(f
(x),
y),
p(y
,g(v
))
b)
M2
=p(x
,y),
p(g
(u),
v),
p(z
,v)
,¬
p(x
,y),¬
p(g
(u),
v)
c)M
3=p(x
,f(z
)),p(g
(u),
v),
p(g
(u),
f(z
))
d)
M4
=p(f
(g(u
)),v),¬
p(f
(z),
v)
,¬
p(x
,y),¬
p(g
(u),
v)
D.Suenderm
ann
Logic
January
28,2012
118
.First-o
rderve
rsion
ofD
avis
and
Putn
am
:re
solu
tion
functio
n.
Sim
ilarlyto
the
functio
ncu
tin
troduce
dfo
rth
edefinitio
nofth
eD
P
alg
orith
min
pro
positio
nallo
gic,
we
intro
duce
the
functio
nre
sfo
r
first-o
rderlo
gic.
The
functio
nre
sapplie
sth
ere
solu
tion
rule
toa
set
ofcla
use
sC
0w
ith
resp
ect
toa
litera
l(u
nit
clause
).
As
oppose
dto
cut,
itdoes
not
dro
pany
clause
sfro
mC
0but
simply
adds
conclu
sions
from
the
reso
lutio
nru
leto
the
clause
set.
The
reaso
nth
at
clause
sare
not
dro
pped
isth
at
diff
ere
nt
ato
mic
form
ula
s
may
be
base
don
the
sam
epre
dica
tebut
diff
ere
nt
argum
ents
which
may
pro
duce
adiff
ere
nt
unifi
er
and,hence
,a
diff
ere
nt
resu
ltcla
use
.
Ifth
eorig
inalcla
use
would
have
been
dro
pped,th
isdiff
ere
nt
clause
would
have
been
misse
d.
D.Suenderm
ann
Logic
January
28,2012
119
.First-o
rder
versio
nofD
avis
and
Putn
am
:re
solu
tion
functio
n(e
xam
ple
s).
Exa
mple
1:
res(p(x
),¬
q(f
(t)),q(x
),q(x
))=
p(x
),¬
q(f
(t)),p(f
(t)),q(x
)
(201)
Exa
mple
2:
res(p(y
),¬
q(x
),p(f
(y)),¬
q(x
),¬
p(x
),¬
p(x
))=
(202)
p(y
),¬
q(x
),¬
q(x
),p(f
(y)),¬
q(x
),¬
q(f
(y))
,¬
p(x
)
Exa
mple
3(in
finite
loop):
C0
:=¬
p(x
),p(f
(x))
,p(x
)
C1
:=re
s(C0 ,
p(x
))
=¬
p(x
),p(f
(x))
,p(f
(x))
,p(x
)
=¬
p(x
),p(f
(x))
,p(f
(y))
,p(x
)
C2
:=re
s(C1 ,
p(f
(y)))
=¬
p(x
),p(f
(x))
,p(f
(f(y
))),p(f
(y))
,p(x
)
C3
:=re
s(C2 ,
p(f
(f(y
))))...
(203)
D.Suenderm
ann
Logic
January
28,2012
120
.First-o
rder
calcu
lus:
exa
mple
.
W
ehave
now
learn
ed
all
the
pie
ces
nece
ssaryto
apply
first-o
rderca
lculu
s
ina
system
atic
way.
Let
us
reite
rate
on
the
invo
lved
steps
by
means
ofan
exa
mple
.
This
isourknow
ledge
base
:
a)
Every
dra
gon
ishappy
ifall
his
child
renknow
how
tofly.
b)
Every
reddra
gon
know
show
tofly.
c)Child
renofred
dra
gons
arered
.
Now
,le
tus
tryto
pro
vew
heth
er
ornot
d)
All
reddra
gons
arehappy.
D.Suenderm
ann
Logic
January
28,2012
121
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
To
get
started,we
define
asig
natu
reΣ
a=〈V
,F
,P
,arity〉
with
V=x,y
F=
P=r,
f,h
,c
arity=〈r,
1〉〈f
,1〉〈h
,1〉〈c
,2〉
We
assu
me
that
the
unive
rseco
nta
ins
all
dra
gons.
The
pre
dica
tes
have
the
follo
win
gin
terp
reta
tions:
–r(x
)is
1iff
xis
red.
–f(x
)is
1iff
xknow
show
tofly.
–h(x
)is
1iff
xis
happy.
–c(x
,y)
is1
iffx
isy’s
child
.
D.Suenderm
ann
Logic
January
28,2012
122
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
Form
alizin
gknow
ledge
base
and
claim
:
a)
f1
:=∀x(∀
y(c
(y,x)→
f(y
))→
h(x
))
b)
f2
:=∀x(r
(x)→
f(x
))
c)f3
:=∀x(∃
y(c
(x,y)∧
r(y
))→
r(x
))
d)
f4
:=∀x(r
(x)→
h(x
))
Now
,to
see
wheth
erth
ecla
imd)
can
be
derive
dfro
mth
eknow
ledge
base
a)
toc)
isto
pro
veth
at
f:=
f1∧
f2∧
f3→
f4
(204)
isunive
rsally
valid
.
D.Suenderm
ann
Logic
January
28,2012
123
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
This
isth
esa
me
as
topro
veth
at¬
fis
aco
ntra
dictio
n:
¬f↔¬
(f1∧
f2∧
f3→
f4)
↔¬
(¬(f
1∧
f2∧
f3 )∨
f4)
↔¬¬
(f1∧
f2∧
f3 )∨¬
f4)
↔¬¬
(f1∧
f2∧
f3 )∧¬
f4
↔f1∧
f2∧
f3∧¬
f4
(205)
Next,
we
need
totu
rn¬
fin
toa
set
ofcla
use
s.
This
can
be
done
by
turn
ing
f1,
f2 ,
f3 ,
and¬
f4
individ
ually
into
clausa
l
norm
alfo
rm.
D.Suenderm
ann
Logic
January
28,2012
124
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
f1↔∀x(∀
y(c
(y,x)→
f(y
))→
h(x
))
↔∀x(∀
y(¬
c(y
,x)∨
f(y
))→
h(x
))
↔∀x(¬∀y(¬
c(y
,x)∨
f(y
))∨
h(x
))
↔∀x(∃
y(¬
(¬c(y
,x)∨
f(y
)))∨
h(x
))
↔∀x(∃
y(¬¬
c(y
,x)∧¬
f(y
))∨
h(x
))
↔∀x(∃
y(c
(y,x)∧¬
f(y
))∨
h(x
))
↔∀x∃y(c
(y,x)∧¬
f(y
)∨
h(x
))
≈∀x(c
(s(x
),x)∧¬
f(s
(x))∨
h(x
))
↔∀x((c
(s(x
),x)∨
h(x
))∧
(¬f(s
(x))∨
h(x
)))
↔c(s
(x),
x),
h(x
),¬
f(s
(x)),
h(x
)
(206)
f2↔∀x(r
(x)→
f(x
))
↔∀x(¬
r(x
)∨
f(x
))
↔¬
r(x
),f(x
)
(207)
D.Suenderm
ann
Logic
January
28,2012
125
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
f3↔∀x(∃
y(c
(x,y)∧
r(y
))→
r(x
))
↔∀x(¬∃y(c
(x,y)∧
r(y
))∨
r(x
))
↔∀x(∀
y(¬
(c(x
,y)∧
r(y
)))∨
r(x
))
↔∀x(∀
y(¬
c(x
,y)∨¬
r(y
))∨
r(x
))
↔∀x,y(¬
c(x
,y)∨¬
r(y
)∨
r(x
))
↔¬
c(x
,y),¬
r(y
),r(x
)
(208)
¬f4↔¬∀x(r
(x)→
h(x
))
↔¬∀x(¬
r(x
)∨
h(x
))
↔∃x(¬
(¬r(x
)∨
h(x
)))
↔∃x(r
(x)∧¬
h(x
))
≈r(t)∧¬
h(t)
↔r(t)
,¬
h(t)
(209)
D.Suenderm
ann
Logic
January
28,2012
126
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
Applyin
gth
eD
Palg
orith
m:
C0
:=c(s
(x),
x),
h(x
),¬
f(s
(x)),
h(x
),¬
r(x
),f(x
),
¬
c(x
,y),¬
r(y
),r(x
),r(t)
,¬
h(t)
C1
:=re
s(C0 ,
r(t))
=c(s
(x),
x),
h(x
),¬
f(s
(x)),
h(x
),¬
r(x
),f(x
),f(t)
,
¬
c(x
,y),¬
r(y
),r(x
),¬
c(x
,t),
r(x
),r(t)
,¬
h(t)
C2
:=re
s(C1 ,¬
h(t))
=c(s
(x),
x),
h(x
),c(s
(t),t)
,¬
f(s
(x)),
h(x
),¬
f(s
(t)),
¬
r(x
),f(x
),f(t)
,¬
c(x
,y),¬
r(y
),r(x
),¬
c(x
,t),
r(x
),
r(t)
,¬
h(t)
(210)
D.Suenderm
ann
Logic
January
28,2012
127
.First-o
rderca
lculu
s:exa
mple
(cont.)
.
C3
:=re
s(C2 ,
c(s
(t),t))
=c(s
(x),
x),
h(x
),c(s
(t),t)
,¬
f(s
(x)),
h(x
),¬
f(s
(t)),
¬
r(x
),f(x
),f(t)
,¬
c(x
,y),¬
r(y
),r(x
),
¬
r(t),
r(s
(t)),¬
c(x
,t),
r(x
),r(s
(t)),r(t)
,¬
h(t)
C4
:=re
s(C3 ,
r(s
(t)))
=c(s
(x),
x),
h(x
),c(s
(t),t)
,¬
f(s
(x)),
h(x
),¬
f(s
(t)),
¬
r(x
),f(x
),f(s
(t)),f(t)
,¬
c(x
,y),¬
r(y
),r(x
),
¬
c(x
,s(t)),
r(x
),¬
r(t),
r(s
(t)),¬
c(x
,t),
r(x
),r(s
(t)),
r(t)
,¬
h(t)
(unsa
tisfiable
)(211)
D.Suenderm
ann
Logic
January
28,2012
128
.First-o
rder
calcu
lus:
exe
rcises
.
W
eknow
that
Sets
can
only
be
conta
ined
insets
not
conta
ined
inth
eSuen
derm
ann
set.
Now
,pro
veth
at
The
Suen
derm
ann
setdoes
not
conta
initself.
Give
nth
eth
ree
pro
pertie
sofa
tota
lord
er
1)
a<
band
b<
cim
plie
sa
<c
(transitivity),
2)
a<
b,
b<
a,or
a=
bis
true
(trichoto
my),
and
3)
a<
ais
not
true
(anti-re
flexivity),
pro
veth
ere
flexivity
ofth
eequiva
lence
(i.e.
a=
a).
D.Suenderm
ann
Logic
January
28,2012
129
.Pro
log
.
Pro
log
(pro
gra
mm
ing
inlo
gic)
ispro
gra
mm
ing
language
asso
ciate
dw
ith
artificia
lin
tellig
ence
as
well
as
com
pute
rlin
guistics.
In
acco
rdance
with
the
archite
cture
ofXPSs,
the
main
com
ponents
of
logica
lpro
gra
mm
ing
are
1.
aknow
ledge
base
(facts
and
rule
s),
2.
an
infe
rence
engin
e.
Adva
nta
ge
oflo
gica
lpro
gra
mm
ing
isth
at
one
does
not
have
todeve
lop
an
alg
orith
mto
solve
the
pro
ble
msin
ceth
isjo
bis
done
by
the
infe
rence
engin
e.
Inste
ad,we
describ
eth
epro
ble
mby
means
oflo
gica
lfo
rmula
s.
The
open-so
urce
SW
I-Pro
log
isava
ilable
as
part
ofth
em
ajo
rLin
ux
distrib
utio
ns
as
well
as
Cyg
win
(http://cygwin.com)
orca
nbe
obta
ined
fromhttp://www.swi-prolog.org
D.Suenderm
ann
Logic
January
28,2012
130
.Facts
and
rule
s.
Facts
areato
mic
form
ula
sw
ithth
ePro
log
synta
x
p(t
1 ,...,tn)
(212)
featu
ring
the
pre
dica
tep
and
the
term
st1 ,
...,tn.
All
the
variable
sin
facts
areunive
rsally
bound,i.e
.,Eq.212
repre
sents
the
logica
lfo
rmula
∀x
1,...,x
m(p
(t1,...,tn)).
(213)
Rule
sare
conditio
nalpro
positio
ns
with
the
Pro
log
synta
x
A:−
B1,...,B
n.
(214)
featu
ring
the
ato
mic
form
ula
sA
,B
1,...,B
n.
Again
,all
the
variable
sin
rule
sare
unive
rsally
bound,so
,Eq.214
repre
sents
the
form
ula
∀x
1,...,x
m(B
1∧
...∧
Bn→
A).
(215)
This
genera
llyre
quire
sfo
rmula
sto
be
give
nas
Horn
clause
s.
D.Suenderm
ann
Logic
January
28,2012
131
.Som
eco
nve
ntio
ns
.
The
first
chara
cter
ofvaria
ble
sis
aca
pita
lle
tteror
an
undersco
re.
The
first
chara
cter
ofpre
dica
tes
or
functio
ns
isa
lower-ca
sele
tter.
The
pre
dica
tetrue
repre
sents
valid
ity.
The
symbols+,-,*,/,.
arefu
nctio
nsym
bols
you
can
use
inin
fix
nota
tion.
The
symbols<,>,=,=<,>=,\=,==,\==
arepre
dica
tesym
bols
you
can
use
inin
fix
nota
tion.N
ote
that
==
tests
forequality,
\==
tests
for
inequality,
and
=is
the
unifi
catio
nopera
tor.
The
symbol\+
(or,
alte
rnative
ly,not())
isth
enegatio
nopera
tor.
The
symbol%
isuse
dfo
rco
mm
ents.
The
symbols,
and;
isuse
dfo
rco
nju
nctio
nand
disju
nctio
n,re
spective
ly.
D.Suenderm
ann
Logic
January
28,2012
132
.O
nPro
log’s
disju
nctio
n.
The
follo
win
gderiva
tion
show
sth
at
disju
nctio
ns
inPro
log
rule
sare
effective
lyno
additio
nalfe
atu
re:
A:−
B1;...;B
n.⇔
B1∨
...∨
Bn→
A.
⇔¬
(B1∨
...∨
Bn)∨
A
⇔¬
B1∧
...∧¬
Bn∨
A
⇔(¬
B1∨
A)∧
...∧
(¬B
n∨
A)
⇔A
:−
B1.
···
A:−
Bn.
(216)
D.Suenderm
ann
Logic
January
28,2012
133
.A
nexa
mple
.
Let
us
now
consid
era
realistic
exa
mple
:
–All
students
aresm
art.
–W
hoeve
ris
smart
ispowerfu
l.
–W
hoeve
ris
com
pute
rscie
ntist
and
pro
fesso
ris
powerfu
l.
–Com
pute
rscie
ntists
arecra
zy.
–Ala
nis
astu
dent.
–Bra
dis
astu
dent.
–Colin
isa
com
pute
rscie
ntist.
–Colin
isa
pro
fesso
r.
D.Suenderm
ann
Logic
January
28,2012
134
.A
nexa
mple
(cont.)
.
This
isth
ere
spective
Pro
log
code
(seestudent.pl
inth
eauxiliary
packa
gekbs
*.zip):
1smart(X):-student(X).
2powerful(X):-smart(X).
3powerful(X):-cs(X),prof(X).
4crazy(X):-cs(X).
5student(alan).
6student(brad).
7cs(colin).
8prof(colin).
D.Suenderm
ann
Logic
January
28,2012
135
.A
nexa
mple
(cont.)
.
W
ewant
tofind
out
wheth
er
there
isa
powerfu
land
crazy
individ
ual.
The
resp
ective
logica
lfo
rmula
is
∃x(powerful(x
)∧crazy(x
)).(217)
Inord
erto
find
out,
we
first
launch
Pro
log
with
the
com
mand
pl
and
get
the
com
mand
pro
mpt
?-
To
load
ourknow
ledge
base
,we
type
consult(student).
Now
,we
can
use
the
Pro
log
synta
xofEq.217
toch
eck
the
valid
ityof
our
conje
cture
:
powerful(X),crazy(X).
D.Suenderm
ann
Logic
January
28,2012
136
.A
nexa
mple
(cont.)
.
W
eobta
inth
ere
sponse
X=
colin
tellin
gus
that
Colin
isa
powerfu
land
crazy
individ
ual.
Inord
erto
identify
oth
erpote
ntia
lca
ndid
ate
s,we
type
;
resu
lting
inth
ere
sponse
No
which
indica
tes
that
there
areno
more
solu
tions
toth
epro
ble
m.
D.Suenderm
ann
Logic
January
28,2012
137
.Pro
log’s
infe
rence
alg
orith
m.
W
eare
give
nth
ePro
log
pro
gra
mP
consistin
gofa
num
berofru
les
of
the
formR
:=A
:−
B1,...,B
m(218)
and
aquery
ofth
efo
rm
G=
Q1,...,Q
n.
(219)
Here
,fa
ctsare
exp
anded
toru
les
by
A↔
A:−true.
(220)
The
infe
rence
alg
orith
mwork
sas
follo
ws:
1.
Search
(inord
er
ofappeara
nce
)all
the
rule
sA
inP
,fo
rw
hich
there
exists
aunifi
er
µ=
[]if
Q1
=true
mgu(Q
1,A
)oth
erw
ise(221)
D.Suenderm
ann
Logic
January
28,2012
138
.Pro
log’s
infe
rence
alg
orith
m(co
nt.)
.
2.
Inca
seth
ere
arem
ultip
lesu
chru
les,
a)
sele
ctth
efirst
rule
(inord
er
ofappeara
nce
),
b)
set
ach
oice
poin
t(C
P)
toperfo
rma
diff
ere
nt
sele
ction
at
this
poin
tin
case
itbeco
mes
nece
ssaryat
ala
ter
mom
ent.
3.
Here
,tw
oca
ses
aredistin
guish
ed:
a)
m+
n=
1:This
means
succe
ss,and
Pro
log
retu
rns
the
last
non-e
mpty
µ.
b)
Oth
erw
ise,we
recu
rsively
contin
ue
with
the
query
G:=
B1µ
,...,B
mµ
,Q
2µ
,...,Q
nµ
.(222)
Ifwe
do
not
find
aso
lutio
n,we
retu
rnto
the
last
choice
poin
t
reve
rsing
the
repla
cem
ents
G:=
Gµ
acco
rdin
gly.
Negatio
nis
imple
mente
din
Pro
log
as
negatio
nas
failu
re.
I.e.,
ifQ
1in
1is
ofth
esyn
taxnot(Q
′1 )th
ealg
orith
mtrie
sto
pro
veQ
′1 .
Ifit
succe
eds,
we
know
that
Q1
isfa
lse,oth
erw
ise,we
assu
me
itis
true.
D.Suenderm
ann
Logic
January
28,2012
139
.Pro
log’s
infe
rence
alg
orith
m:exa
mple
.
IDCP
GR
µ
11
powerful(X
),crazy(X
)powerful(X
):−smart(X
)[]
21
smart(X
),crazy(X
)smart(X
):−student(X
)[]
33
student(X
),crazy(X
)student(alan):−true
[X7→
alan]
43
true,crazy(alan)
[]
53
crazy(alan)
crazy(X
):−cs(X
)[X7→
alan]
63
cs(alan)
cs(colin):−true
Ω
71
student(X
),crazy(X
)student(brad):−true
[X7→
brad]
83
true,crazy(brad)
[]
91
crazy(brad)
crazy(X
):−cs(X
)[X7→
brad]
10
1cs(brad)
cs(colin):−true
Ω
D.Suenderm
ann
Logic
January
28,2012
140
.Pro
log’s
infe
rence
alg
orith
m:exa
mple
(cont.)
.
IDCP
GR
µ
11
powerful(X
),crazy(X
)powerful(X
):−cs(X
),prof(X
)[]
12
cs(X
),prof(X
),crazy(X
)cs(colin):−true
[X7→
colin]
13
true,prof(colin),crazy(colin)
[]
14
prof(colin),crazy(colin)
prof(colin):−true
[]
15
true,crazy(colin)
[]
16
crazy(colin)
crazy(X
):−cs(X
)[X7→
colin]
17
cs(colin)
cs(colin):−true
[]
18
true
[]
Pro
log’s
resp
onse
ishence
:[X7→
colin].
D.Suenderm
ann
Logic
January
28,2012
141
.D
rawback
sofPro
log’s
infe
rence
alg
orith
m.
Consid
erth
ePro
log
pro
gra
m:
1a:-not(true).
Let
us
query
wheth
era:
IDCP
GR
µ
1a
a:−not(true)
[]
2∗
true
[]
The
query
infe
rsfa
lseby
negatio
nas
failu
re(in
dica
ted
by∗
which
means
that
are
sult
derive
dfro
mth
isste
pneeds
tobe
inve
rted).
This,
howeve
r,does
not
coin
cide
with
ourundersta
ndin
gofth
ese
mantics
ofth
eim
plica
tion:⊥→
ais
true
independent
ofw
heth
era
ornot.
The
reaso
nis
Pro
log’s
close
d-w
orld
assu
mptio
n:It
assu
med
the
data
base
isco
mple
te;I.e
.,if
the
answ
er
cannot
be
deduce
d,it
isfa
lse.
Eve
nworse
,th
ere
sponse
toth
equery
not(a
)is
true
due
totw
o
applica
tions
ofin
versio
n.
D.Suenderm
ann
Logic
January
28,2012
142
.D
rawback
sofPro
log’s
infe
rence
alg
orith
m(co
nt.)
.
Consid
erth
ePro
log
pro
gra
m:
1a:-b.
2b:-a.
Let
us
query
wheth
era,b:
IDCP
GR
µ
1a,b
a:−b
[]
2b,b
b:−a
[]
3a,b
a:−b
[]
4b,b
b:−a
[]
···
The
pro
gra
mente
rsan
infinite
loop
eve
nth
ough
the
query
could
be
pro
ven
true
ina
few
steps:
(b→
a)∧
(a→
b)→
a∧b⇔⊤
.(223)
The
natu
reofPro
log
bein
gbase
don
Horn
logic
and
itsnegatio
nand
loop
handlin
gsh
ow
aco
nsid
era
ble
weakness
ofits
infe
rence
alg
orith
m.
D.Suenderm
ann
Logic
January
28,2012
143
.Lists
.
Apart
from
Pro
log’s
infe
rence
engin
e,a
pre
dom
inant
featu
reis
itslist
handlin
g.
Lists
can
be
writte
nin
thre
eways:
1.
.(s,t)
defines
alist
with
the
ele
ment
sand
the
tail
t;
2.
[s|t]
does
the
sam
e;
3.
[s1,...,s
n]defines
alist
with
the
ele
ments
s1,...,s
n
Acco
rdin
gly,
these
areequiva
lent
lists:
.(1,.(2
,.(3
,[])))
(224)
[1|[2|[3|[]]]]
(225)
[1,2,3]
(226)
D.Suenderm
ann
Logic
January
28,2012
144
.Lists:
exa
mple
functio
n.
W
ewant
todesig
na
functio
ncat
that
conca
tenate
stw
olists
L1
andL2
resu
lting
inth
elist
L2.
In
the
world
oflo
gica
lpro
gra
mm
ing,th
isco
uld
be
conce
ived
as
the
3-ary
functio
ncat(L1,L2,L3)
which
beco
mes
true
iffL3
isth
eco
nca
tenatio
nof
L2
andL2.
Are
spective
Pro
log
pro
gra
mis:
1cat([X|L1],L2,[X|L3]):-cat(L1,L2,L3).
2cat([],L,L).
This
pro
gra
mre
ads
An
em
pty
listco
nca
tenate
dw
itha
listL
resu
ltsin
the
sam
elist
L
(Fact
2).
Furth
erm
ore
,if
the
conca
tenatio
nofth
elists
L1
and
L2
resu
ltsin
L3 ,
then
L1
with
an
pre
cedin
gele
ment
Xco
nca
tenate
d
with
L2
must
resu
ltin
L3
with
the
sam
epre
cedin
gele
ment
X
(Rule
1).
Inth
efo
llow
ing,we
run
an
exa
mple
toundersta
nd
the
pro
gra
m’s
functio
nality.
D.Suenderm
ann
Logic
January
28,2012
145
.Lists:
exa
mple
functio
n(co
nt.)
.
IDCP
GR
µ
1cat([1
,2],
[3,4],
Y)cat([X|L
1],
L2,[X|L
3])
:−
[X7→
[1],
L17→
[2],
cat(L
1,L
2,L
3)
L27→
[3,4],
Y7→
[1|L
3]]
2cat([2
],[3
,4],
L3)
cat([X
′|L′1],
L′2,[X
′|L′3])
:−
[X′7→
[2],
L′17→
[],
cat(L
′1,L
′2,L
′3)
L′27→
[3,4],
L37→
[2|L
′3]]
3cat([],
[3,4],
L′3)
cat([X
′′|L
′′
1],
L′′
2,[X
′′|L
′′
3])
:−
Ω
cat(L
′′
1,L
′′
2,L
′′
3)
4cat([],
[3,4],
L′3)
cat([],
L,L)
:−
[L7→
[3,4],
L′37→
[3,4]]
Pro
log’s
resp
onse
ishence
:
Y7→
[1|L
3]
7→[1|[2|L
′3]]
7→[1|[2|[3
,4]]]
=[1
,2,3,4]
(227)
D.Suenderm
ann
Logic
January
28,2012
146
.Lists:
exa
mple
functio
n(co
nt.)
.
You
may
perce
iveso
me
flavo
rofPro
log’s
ele
gance
ifyo
uco
nsid
erw
hich
use
case
sth
eabove
exa
mple
functio
nfe
atu
res:
–Conca
tenate
two
lists:
cat([1
,2],
[3,4],
Y).
(228)
–Check
wheth
era
listre
sulte
dfro
manoth
erlist
by
way
of
conca
tenatio
n:
cat([1
,2],
Y,[1
,2,3,4]).
(229)
–Fin
dall
possib
lesp
litsofa
listin
totw
olists:
cat(X
,Y
,[1
,2,3,4]).
(230)
D.Suenderm
ann
Logic
January
28,2012
147
.H
ow
ord
er
matte
rs.
Consid
erth
efo
llow
ing
pro
gra
m:
1a.
2a:-b.
3b:-a.
W
eget
the
query
resu
lt
a.→
Yes.
(231)
Now
,we
reord
erth
eru
les:
1a:-b.
2a.
3b:-a.
This,
time,th
equery
resu
ltis
a.→
ERROR
:Outoflocalstack.
(232)
The
infe
rence
alg
orith
mke
eps
acce
ssing
Rule
1ove
rand
ove
ragain
.
Oth
erth
an
the
exa
mple
on
Page
145,th
istim
e,we
do
not
get
an
infinite
loop
but
asta
ckove
rflow
.
This
isbeca
use
Pro
log
has
tocre
ate
ach
oice
poin
tfo
reve
ryre
cursio
n
due
toth
epre
sence
ofth
ealte
rnative
Rule
3.
D.Suenderm
ann
Logic
January
28,2012
148
.H
ow
ord
er
matte
rs(co
nt.)
.
Consid
erth
efo
llow
ing
pro
gra
m:
1s([X],[X]).
2s([A,B],[A,D]):-s([B],[D]),A<D.
W
eget
the
query
resu
lt
s([1
,2],X).→
X=
[1,2].
(233)
Now
,we
switch
the
ele
ments
inRule
2’s
body:
1s([X],[X]).
2s([A,B],[A,D]):-A<D,s([B],[D]).
This
time,we
get
s([1
,2],X).→
ERROR
:Argumentsarenotsufficientlyinstantiated.
The
infe
rence
alg
orith
mtrie
sto
eva
luate
A<
Dfirst,
befo
reD
had
been
dete
rmin
ed
by
way
ofeva
luatin
gs([B
],[D
]).
D.Suenderm
ann
Logic
January
28,2012
149
.Sym
bolic
vs.num
erica
lco
mputa
tion
.
Consid
erth
efo
llow
ing
pro
gra
m:
1p(X,Y):-Y==X+1.
2q(X,Y):-Y>X+0.9999999,Y<X+1.0000001.
3r(X,Y):-Y
is
X+1.
4s(X,Y):-Y=X+1.
We
get
the
follo
win
gquery
resu
lts:
p(1
,2).→
No.
q(1
,2).→
Yes.
r(1
,2).→
Yes.
s(1
,2).→
No.
p(1
,Y).→
No.
q(1
,Y).→
ERROR
:Argumentsarenotsufficientlyinstantiated.
r(1
,Y).→
Y=
2.
s(1
,Y).→
Y=
1+
1.
D.Suenderm
ann
Logic
January
28,2012
150
.Sym
bolic
vs.num
erica
lco
mputa
tion
(cont.)
.
The
check
forequality
(==
)fa
ilsdue
toissu
es
with
Pro
log’s
num
erica
l
pre
cision.
Rath
er
than
forequality,
qch
eck
sfo
ra
small
range
around
the
exp
ecte
d
valu
eand
there
by
succe
eds.
When
querie
dw
ithth
efre
epara
mete
rY,
howeve
r,Pro
log
isnot
able
tolim
itth
e(re
al-va
lued)
search
space
and
com
pla
ins
about
insu
fficie
nt
insta
ntia
tion.
Pro
log’s
keyw
ord
is
assig
ns
the
exa
ctva
lue
ofX
+1
toY
and
there
fore
succe
eds.
Acco
rdin
gly,
the
free
para
mete
rY
gets
assig
ned
the
sum
of1
and
1.
The
unifi
catio
nopera
tor=
tries
toso
lveth
esyn
tactica
lequatio
n
2=
1+
1w
hich
isnot
possib
lesin
cediff
ere
nt
functio
nsym
bols
cannot
be
unifi
ed.H
ence
,it
fails.
When
querie
dw
itha
free
para
mete
r,howeve
r,
the
synta
cticalequatio
nisY
=1
+1
whose
solu
tion
isth
ere
sult
set.
D.Suenderm
ann
Logic
January
28,2012
151
.Pro
log:exe
rcises
.
W
ritepro
gra
ms
to
1)
dete
rmin
eth
em
axim
um
oftw
onum
bers
(2lin
es)
2)
calcu
late
the
facto
rial(2
lines)
3)
uniq
alist
(3lin
es)
4)
find
identica
lele
ments
intw
olists
(3lin
es)
5)
sort
alist
(4lin
es)
D.Suenderm
ann
Logic
January
28,2012
152
.Conju
nctive
norm
alfo
rm:so
lutio
nto
exe
rcise.
Tra
nsfo
rmin
toCN
F:
g:=
p→
q→
r︸
︷︷
︸
a
↔¬
s∨
t︸
︷︷
︸
b
(234)
1.
g⇔
(¬a∨
b)
︸︷︷
︸
c
∧(¬
b∨
a)
︸︷︷
︸
d
(235)
2.
.a⇔¬
p∨
q→
r
⇔¬
(¬p∨
q)∨
r(236)
3.
.a⇔
p∧¬
q∨
r(237)
¬a⇔¬
(p∧¬
q)∧¬
r
⇔(¬
p∨
q)∧¬
r(238)
¬b⇔
s∧¬
t(239)
D.Suenderm
ann
Logic
January
28,2012
154
.Conju
nctive
norm
alfo
rm:so
lutio
nto
exe
rcise(co
nt.)
.
4.
.c⇔
(¬p∨
q)∧¬
r∨
b
⇔(¬
p∨
q∨
b)∧
(¬r∨
b)
(240)
⇔(¬
p∨
q∨¬
s∨
t)∧
(¬r∨¬
s∨
t)
d⇔
s∧¬
t∨
a
⇔(s∨
a)
︸︷︷
︸
e
∧(¬
t∨
a)
︸︷︷
︸
f
(241)
e⇔
p∧¬
q∨
r∨
s
⇔(p∨
r∨
s)∧
(¬q∨
r∨
s)
(242)
f⇔
(p∨
r∨¬
t)∧
(¬q∨
r∨¬
t)(243)
5.
.g⇔¬
p,q,¬
s,t
,¬
r,¬
s,t
,p,r,
s,¬
q,r,
s,
p,r,¬
t,¬
q,r,¬
t
(244)
D.Suenderm
ann
Logic
January
28,2012
155
.First-o
rder
calcu
lus:
solu
tion
toexe
rcise.
W
eknow
that
Everyb
ody
loves
only
those
peo
ple
who
do
not
love
agard
ener.
Let
us
use
the
pre
dica
tes
–l(x
,y)
which
is1
iffx
love
sy
and
–g(x
)w
hich
is1
iffx
isa
gard
ener.
Let
us
furth
eruse
an
auxiliary
pre
dica
te
–n(x
)w
hich
is1
iffx
does
not
love
agard
ener.
Usin
gn(x
)’sdefinitio
n,th
eabove
axio
mco
uld
be
writte
nas
Every
xlo
vesonly
those
yfo
rw
hich
n(y
)
which
can
be
form
ally
exp
resse
das
f:=∀x,y(l(x
,y)→
n(y
)).(245)
D.Suenderm
ann
Logic
January
28,2012
156
.First-o
rder
calcu
lus:
solu
tion
toexe
rcise(co
nt.)
.
Exp
ressin
gn(y
)in
term
sof
l(y,z)
and
g(z
):
n(y
)↔¬∃z(l(y
,z)∧
g(z
)).(246)
H
ence
,Form
ula
248
beco
mes
f↔∀x,y(l(x
,y)→¬∃z(l(y
,z)∧
g(z
)))
↔∀x,y(¬
l(x,y)∨¬∃z(l(y
,z)∧
g(z
)))
↔∀x,y(¬
l(x,y)∨∀z(¬
(l(y,z)∧
g(z
))))
↔∀x,y,z(¬
l(x,y)∨¬
l(y,z)∨¬
g(z
))
↔¬
l(x,y),¬
l(y,z),¬
g(z
)
(247)
Our
conje
cture
isth
at
Gard
eners
do
not
love
them
selves
which
can
be
form
ally
exp
resse
das
g:=∀x(g
(x)→¬
l(x,x)).
(248)
D.Suenderm
ann
Logic
January
28,2012
157
.First-o
rder
calcu
lus:
solu
tion
toexe
rcise(co
nt.)
.
To
pro
veg,we
need
toco
nju
nctive
lyco
mbin
ef
with
g’s
negatio
n,so
,
let
us
atta
ckth
ela
tternow
:
¬g↔¬
(∀x(g
(x)→¬
l(x,x)))
↔¬
(∀x(¬
g(x
)∨¬
l(x,x)))
↔∃x(¬
(¬g(x
)∨¬
l(x,x)))
↔∃x(g
(x)∧
l(x,x))
≈g(s
)∧
l(s,s)
↔g(s
),l(s
,s)
(249)
D.Suenderm
ann
Logic
January
28,2012
158
.First-o
rder
calcu
lus:
solu
tion
toexe
rcise(co
nt.)
.
Applyin
gth
eD
Palg
orith
m:
C0
:=¬
l(x,y),¬
l(x,z),¬
g(z
),g(s
),l(s
,s)
C1
:=re
s(C0 ,
g(s
))
=¬
l(x,y),¬
l(x,z),¬
g(z
),¬
l(x,y),¬
l(x,s)
,
g(s
),l(s
,s)
C2
:=re
s(C1 ,
l(s,s))
=¬
l(x,y),¬
l(x,z),¬
g(z
),¬
l(s,z),¬
g(z
),
¬
l(x,y),¬
l(x,s)
,¬
l(s,s)
,g(s
),l(s
,s)
(250)
This
pro
ves
that
the
conje
cture
istru
e.
D.Suenderm
ann
Logic
January
28,2012
159