9.3 Relation to logic programming
649
Relational statement
Logical formula
skip
true
fail
false
±
s
²
1
±
s
²
2
T
(
±
s
²
1
)
∧
T
(
±
s
²
2
)
local
X
in
±
s
²
end
∃
x.T
(
±
s
²
)
X=Y
x
=
y
X=f(l1:X1 .
.. ln:Xn)
x
=
f
(
l
1
:
x
1
, ..., l
n
:
x
n
)
if
X
then
±
s
²
1
else
±
s
²
2
end
(
x
= true
∧
T
(
±
s
²
1
))
∨
(
x
= false
∧
T
(
±
s
²
2
))
case
X
of
f(l1:X1 .
.. ln:Xn)
(
∃
x
1
, ..., x
n
.x
=
f
(
l
1
:
x
1
, ..., l
n
:
x
n
)
∧
T
(
±
s
²
1
))
then
±
s
²
1
else
±
s
²
2
end
∨
(
¬∃
x
1
, ..., x
n
.x
=
f
(
l
1
:
x
1
, ..., l
n
:
x
n
)
∧
T
(
±
s
²
2
))
proc
{P X1 .
.. Xn}
±
s
²
end
∀
x
1
, ..., x
n
.p
(
x
1
, ..., x
n
)
↔
T
(
±
s
²
)
{P Y1 .
.. Yn}
p
(
y
1
, ..., y
n
)
choice
±
s
²
1
[] .
.. []
±
s
²
n
end
T
(
±
s
²
1
)
∨
...
∨
T
(
±
s
²
n
)
Table 9.2: Translating a relational program to logic
proc
{Append A B ?C}
case
A
of
nil
then
C=B
[] XAs
then
Cs
in
C=XCs
{Append As B Cs}
end
end
According to Table 9.2, this procedure has the following logical semantics:
∀
a, b, c.
append
(
a, b, c
)
↔
(
a
=
nil
∧
c
=
b
)
∨
(
∃
x, a
±
,c
±
.a
=
x

a
±
∧
c
=
x

c
±
∧
append
(
a
±
,b,c
±
))