HiLog

A

Foundation

for

Higher-Order

Logic

Programming

Weidong

Cheny

Michael

Kiferz

David

S.

Warren

Department

of

Computer

Science

State

University

of

New

York

at

Stony

Brook

Stony

Brook

NY

Abstract

We

describe

a

novel

logic

called

HiLog

and

show

that

it

provides

a

more

suitable

basis

for

logic

programming

than

does

traditional

predicate

logic

HiLog

has

a

higher-order

syntax

and

allows

arbitrary

terms

to

appear

in

places

where

predicates

functions

and

atomic

formulas

occur

in

predicate

calculus

But

its

semantics

is

first-order

and

admits

a

sound

and

complete

proof

procedure

Applications

of

HiLog

are

discussed

including

DCG

grammars

higher-order

and

modular

logic

programming

and

deductive

databases

Preface

Manipulating

predicates

functions

and

even

atomic

formulas

is

a

commonplace

in

logic

programming

For

example

Prolog

combines

predicate

calculus

higher-order

and

meta-level

programming

in

one

working

system

allowing

programmers

routine

use

of

generic

predicate

definitions

-LRB-

e.g.

transitive

closure

sorting

-RRB-

where

predicates

can

be

passed

as

parameters

and

returned

as

values

-LSB-

-RSB-

Another

well-known

useful

feature

is

the

call

meta-predicate

of

Prolog

Applications

of

higher-order

constructs

in

the

database

context

have

been

pointed

out

in

many

works

including

-LSB-

-RSB-

Although

predicate

calculus

provides

the

basis

for

Prolog

it

does

not

have

the

wherewithal

to

support

any

of

these

features

which

consequently

have

an

ad

hoc

status

in

logic

programming

In

this

paper

we

investigate

the

fundamental

principles

underlying

higher-order

logic

programming

and

in

particular

shed

new

light

on

why

and

how

these

Prolog

features

appear

to

work

in

practice

We

propose

a

novel

logic

called

HiLog

which

provides

a

clean

declarative

semantics

to

much

of

this

higher-order

logic

programming

From

the

outset

even

the

terminology

of

higher-orderness

seems

ill-defined

A

number

of

works

have

proposed

various

higher-order

constructs

in

the

logic

framework

-LSB-

-RSB-

but

with

such

a

diversity

of

syntax

and

semantics

it

is

not

always

clear

what

kind

of

higher-orderness

is

being

claimed

In

our

opinion

there

are

at

least

two

different

facets

to

the

issue

a

higher-order

This

paper

is

an

expanded

version

of

the

work

previously

reported

in

-LSB-

-RSB-

yPresent

address

Computer

Science

and

Engineering

Southern

Methodist

University

Dallas

TX

zWork

of

M.

Kifer

was

partially

supported

by

the

NSF

grant

syntax

and

a

higher-order

semantics

Logicians

seem

to

have

been

long

aware

of

this

distinction

and

for

example

Enderton

-LSB-

page

-RSB-

describes

a

translation

of

the

syntactically

second-order

predicate

calculus

into

a

first-order

multi-sorted

logic

that

admits

a

first-order

semantics

Informally

by

higher-order

syntax

logicians

mean

a

language

in

which

variables

are

allowed

to

appear

in

places

where

normally

predicate

and/or

function

symbols

do

In

contrast

higher-order

semantics

is

manifested

by

semantic

structures

in

which

variables

may

range

over

domains

of

relations

and

functions

constructed

out

of

the

domains

of

individuals

In

a

first-order

semantics

variables

can

only

range

over

domains

of

individuals

or

over

the

names

of

predicates

and

functions

The

third

component

in

this

picture

is

the

equality

theory

that

is

built

into

the

semantics

of

the

logic

As

explained

below

an

equality

theory

may

bring

the

first-order

and

higher-order

semantics

closer

to

each

other

In

the

extreme

case

this

theory

may

imply

a

correspondence

between

the

domain

of

individuals

and

the

domains

of

higher-order

constructs

In

this

case

higher-order

and

first-order

semantics

become

virtually

indistinguishable

We

note

that

the

classification

based

upon

semantics

has

no

implication

whatsoever

regarding

the

intrinsic

higher-orderness

that

is

whether

there

exists

a

sound

and

complete

proof

theory

for

a

higher-order

semantics

It

is

quite

possible

to

replace

a

higher-order

semantics

for

some

languages

by

an

entailment-equivalent

first-order

semantics

On

the

other

hand

it

is

well

known

that

some

semantics

-LRB-

e.g.

the

standard

semantics

of

second-order

predicate

calculus

-RRB-

are

inherently

higher-order

and

no

equivalent

first-order

substitute

exists

for

the

corresponding

languages

Predicate

calculus

is

the

primary

example

of

a

logic

where

syntax

and

semantics

are

both

firstorder

There

are

logics

that

have

a

higher-order

syntax

but

a

first-order

semantics

F-logic

-LSB-

-RSB-

is

one

example

HiLog

to

be

discussed

in

this

paper

also

falls

into

this

category

Examples

of

logics

with

higher-order

syntax

and

semantics

include

COL

-LSB-

-RSB-

and

Church

's

simple

theory

of

types

-LRB-

under

the

standard

and

Henkin

's

semantics

-RRB-

-LSB-

-RSB-

On

the

other

hand

LDL

-LSB-

-RSB-

is

a

language

with

a

first-order

syntax

and

a

higher-order

semantics

Let

us

examine

the

equational

theories

underlying

various

logics

more

closely

Under

a

higher-order

semantics

an

equation

between

predicate

-LRB-

or

function

-RRB-

symbols

e.g.

p

q

is

true

if

and

only

if

these

symbols

are

interpreted

via

the

same

relation

-LRB-

resp.

function

-RRB-

Another

way

of

saying

this

is

that

logics

with

a

higher-order

semantics

have

a

built-in

extensional

equality

theory

of

predicates

and

functions

In

contrast

in

HiLog

and

F-logic

predicates

and

other

higher-order

syntactic

objects

are

not

equal

unless

they

-LRB-

i.e.

their

names

-RRB-

are

equated

explicitly

Thus

it

is

possible

for

two

predicate

symbols

say

p

and

q

to

be

interpreted

by

the

same

relation

and

yet

the

equality

p

q

be

false

The

above

examples

represent

the

two

extreme

cases

in

a

sense

There

are

higher-order

languages

with

a

first-order

semantics

that

embody

a

non-trivial

equality

theory

An

example

is

a

subset

of

Prolog

-LSB-

-RSB-

that

has

no

type

variables

and

whose

syntax

is

essentially

the

same

as

Church

's

simple

theory

of

types

-LSB-

-RSB-

Equality

in

Prolog

corresponds

to

equivalence

and

is

not

extensional

there

may

exist

predicates

that

are

not

equivalent

but

still

extensionally

equal

To

better

see

the

role

of

equational

theories

on

the

classification

of

logical

theories

note

that

there

are

two

different

aspects

associated

with

an

expression

that

denotes

a

predicate

or

a

function

For

instance

in

Prolog

one

aspect

is

the

meaning

of

the

expression

as

a

term

-LRB-

or

more

precisely

as

an

equivalence

class

of

terms

-RRB-

which

we

call

the

intension

the

other

aspect

is

the

relation

or

a

function

associated

with

the

expression

which

we

call

the

extension

These

two

aspects

become

indistinguishable

if

extensionality

axioms

are

built

into

the

logic

For

instance

in

Henkin

's

semantics

of

Church

's

type

theory

-LSB-

-RSB-

it

makes

no

difference

whether

predicate

variables

are

considered

to

range

over

the

domain

of

interpretation

for

predicate

names

-LRB-

predicate

intensions

-RRB-

or

over

relations

-LRB-

predicate

extensions

-RRB-

since

each

extension

now

becomes

associated

with

exactly

one

intension

and

vice

versa

The

distinction

between

intensions

and

extensions

is

important

It

is

known

that

extensions

can

be

notoriously

difficult

to

handle

in

an

efficient

manner

Separating

intensions

from

extensions

makes

it

possible

to

have

an

equational

theory

over

predicate

and

function

names

that

is

separate

from

the

extensional

equality

of

relations

and

functions

A

logic

that

avoids

an

overly

strong

equational

theory

of

intensions

can

have

a

simple

first-order

semantics

a

decidable

unification

problem

and

at

the

same

time

a

higher-order

syntax

In

a

type-free

logic

the

same

term

may

appear

in

different

contexts

as

predicates

or

functions

of

different

arities

and

even

as

atomic

formulas

Thus

the

same

intension

can

be

associated

with

different

extensions

in

different

contexts

For

instance

in

the

Lambda

Calculus

-LSB-

-RSB-

a

term

is

considered

a

function

or

an

object

depending

on

its

syntactic

position

In

HiLog

the

same

symbol

may

denote

a

predicate

a

function

or

an

atomic

formula

Semantics

of

a

type-free

logic

has

to

maintain

the

distinctions

between

various

extensions

associated

with

the

same

intension

Since

the

same

variable

may

appear

in

different

contexts

and

have

different

extensions

it

makes

better

sense

for

variables

to

range

over

intensions

rather

than

extensions

because

only

intensions

remain

the

same

across

different

contexts

In

this

paper

we

present

a

simple

logical

framework

in

which

predicates

functions

and

atomic

formulas

can

be

manipulated

as

first-class

entities

It

is

quite

clear

that

in

order

to

support

such

manipulation

naturally

enough

the

syntax

has

to

be

higher-order

As

explained

earlier

this

leaves

open

two

possibilities

for

the

semantics

Under

higher-order

semantics

predicates

and

functions

are

identified

by

their

extensions

that

is

two

predicates

represent

the

same

thing

if

and

only

if

their

extensions

coincide

in

every

appropriate

semantic

structure

Unfortunately

extensional

equality

of

predicates

and

functions

is

not

decidable

in

general

which

carries

over

to

the

unification

problem

For

genuine

second-order

theories

-LRB-

e.g.

second-order

predicate

calculus

and

Church

's

simple

theory

of

types

both

under

the

standard

semantics

-RRB-

extensional

equality

is

not

even

semi-decidable

In

contrast

under

first-order

semantics

predicates

and

functions

have

intensions

that

can

be

manipulated

directly

Furthermore

depending

on

the

context

the

same

intension

may

assume

different

roles

acting

as

a

relation

a

function

or

even

a

proposition

The

logical

consequence

relation

under

a

first-order

semantics

is

likely

to

be

semi-decidable

unless

a

too

strong

equality

theory

destroys

this

property

This

observation

motivates

our

choice

for

HiLog

The

basic

idea

is

to

construct

a

logic

that

distinguishes

between

intensional

and

extensional

aspects

of

the

semantics

and

embodies

only

a

trivial

equality

theory

of

intensions

Intensions

can

be

thought

of

as

names

of

abstract

or

concrete

entities

while

extensions

correspond

to

various

roles

these

entities

play

in

the

real

world

It

has

also

been

argued

by

Maida

and

Shapiro

-LSB-

-RSB-

that

knowledge

representation

is

part

of

the

conceptual

structure

of

cognitive

agents

and

therefore

should

not

-LRB-

and

even

can

not

-RRB-

contain

extensions

The

reason

is

that

cognitive

agents

do

not

have

direct

access

to

the

world

but

only

to

one

of

its

representations

Our

approach

is

in

the

same

spirit

and

consequently

extensions

of

predicates

and

functions

are

not

available

for

direct

manipulation

On

the

other

hand

intensions

of

higher-order

entities

such

as

predicates

functions

and

even

atomic

formulas

can

be

freely

manipulated

Their

extensions

come

into

play

only

when

the

respective

expressions

need

be

evaluated

Thus

HiLog

combines

advantages

of

higher-order

syntax

with

the

simplicity

of

first-order

semantics

benefiting

from

both

The

rest

of

the

paper

is

organized

as

follows

After

a

brief

motivational

discussion

we

formally

present

the

syntax

and

semantics

of

HiLog

Then

we

give

several

examples

of

applying

HiLog

to

higherorder

logic

programming

DCG

grammars

and

modular

logic

programming

After

that

we

discuss

the

relationship

of

HiLog

to

predicate

calculus

its

relationship

to

some

of

the

recently

proposed

database

rule

of

thumb

has

exceptions

though

For

instance

type

theory

under

Henkin

's

semantics

has

a

proof

theory

despite

the

fact

that

Henkin

's

semantics

is

higher-order

In

contrast

for

certain

strains

of

first-order

annotated

logics

-LSB-

-RSB-

complete

proof

procedures

may

not

exist

in

general

languages

is

discussed

in

Section

A

resolution-based

proof

theory

of

HiLog

is

described

in

Section

Syntax

and

Semantics

of

HiLog

Motivation

Prolog

syntax

is

quite

flexible

it

allows

symbols

to

assume

different

roles

depending

upon

their

context

-LRB-

e.g.

to

have

different

arities

or

to

be

viewed

as

a

constant

a

function

or

a

predicate

-RRB-

For

instance

in

the

clause

r

-LRB-

X

-RRB-

p

-LRB-

X

f

-LRB-

a

-RRB-

-RRB-

q

-LRB-

p

-LRB-

X

f

-LRB-

a

-RRB-

-RRB-

f

-LRB-

p

b

-RRB-

-RRB-

the

symbol

f

occurs

both

as

a

unary

and

as

a

binary

function

and

p

appears

as

a

binary

predicate

as

well

as

a

binary

function

symbol

Furthermore

the

same

syntactic

object

p

-LRB-

X

f

-LRB-

a

-RRB-

-RRB-

is

an

atomic

formula

in

the

first

literal

of

the

clause-body

and

an

individual

term

in

the

second

The

support

for

multiple

roles

for

non-logical

parameters

-LRB-

constants

functions

and

predicates

-RRB-

is

a

handy

feature

of

Prolog

but

unfortunately

this

support

is

provided

in

a

rather

ad

hoc

way

For

instance

while

in

the

above

example

different

occurrences

of

the

same

symbol

can

be

semantically

disambiguated

simply

by

renaming

the

occurrences

of

f

and

p

this

can

not

be

done

in

the

following

rule

p

-LRB-

X

Y

-RRB-

q

-LRB-

Y

-RRB-

X.

Here

the

individual

variable

X

occurs

as

a

first-order

term

and

as

an

atomic

formula

and

renaming

its

different

occurrences

will

intuitively

yield

a

semantically

different

statement

HiLog

supports

multiple

roles

for

parameter

symbols

in

a

much

more

general

and

elegant

manner

Parameters

are

arityless

and

the

distinction

between

predicate

function

and

constant

symbols

is

eliminated

In

particular

a

HiLog

term

can

be

constructed

from

any

logical

symbol

followed

by

any

finite

number

of

arguments

Different

occurrences

of

the

same

parameter

are

related

to

the

same

object

characterized

by

the

same

intension

Associated

with

such

an

intension

are

several

different

extensions

that

capture

the

different

roles

the

symbol

may

assume

in

different

contexts

The

same

view

is

extended

to

arbitrary

terms

HiLog

allows

complex

terms

-LRB-

not

just

parameter

symbols

-RRB-

to

be

viewed

as

functions

predicates

and

atomic

formulas

For

example

a

generic

transitive

closure

predicate

can

be

defined

as

follows

closure

-LRB-

R

-RRB-

-LRB-

X

Y

-RRB-

R

-LRB-

X

Y

-RRB-

closure

-LRB-

R

-RRB-

-LRB-

X

Y

-RRB-

R

-LRB-

X

Z

-RRB-

closure

-LRB-

R

-RRB-

-LRB-

Z

Y

-RRB-

Here

closure

is

-LRB-

syntactically

-RRB-

a

second-order

function

which

given

any

relation

R

returns

its

transitive

closure

closure

-LRB-

R

-RRB-

Generic

definitions

can

be

used

in

various

ways

For

instance

parent

-LRB-

john

bill

-RRB-

parent

-LRB-

bill

bob

-RRB-

manager

-LRB-

john

mary

-RRB-

manager

-LRB-

mary

kathy

-RRB-

relation

-LRB-

parent

-RRB-

relation

-LRB-

manager

-RRB-

reports

to

-LRB-

Person

-RRB-

-LRB-

Superior

-RRB-

relation

-LRB-

Relname

-RRB-

closure

-LRB-

Relname

-RRB-

-LRB-

Person

Superior

-RRB-

will

return

f

bill

mary

bob

kathy

g

in

response

to

the

query

reports

to

-LRB-

john

-RRB-

-LRB-

X

-RRB-

which

is

the

set

of

john

's

ancestors

and

bosses

Often

various

applications

of

Prolog

require

term

traversal

In

HiLog

binary

terms

can

be

traversed

as

follows

traverse

-LRB-

X

-LRB-

Y

Z

-RRB-

-RRB-

traverse

-LRB-

Y

-RRB-

traverse

-LRB-

Z

-RRB-

Notice

that

X

is

a

variable

that

ranges

over

functors

of

the

language

and

therefore

this

program

is

independent

of

the

alphabet

of

that

language

In

contrast

in

Prolog

one

would

have

to

either

specify

such

a

rule

for

every

functor

in

the

alphabet

of

the

program

e.g.

traverse

-LRB-

f

-LRB-

Y

Z

-RRB-

-RRB-

traverse

-LRB-

Y

-RRB-

traverse

-LRB-

Z

-RRB-

traverse

-LRB-

g

-LRB-

Y

Z

-RRB-

-RRB-

traverse

-LRB-

Y

-RRB-

traverse

-LRB-

Z

-RRB-

or

use

a

built-in

predicate

as

in

traverse

-LRB-

Tree

-RRB-

arg

-LRB-

Tree

Left

-RRB-

arg

-LRB-

Tree

Right

-RRB-

traverse

-LRB-

Left

-RRB-

traverse

-LRB-

Right

-RRB-

In

the

latter

the

structure

of

Tree

is

less

visible

and

even

is

not

enforced

-LRB-

unless

we

add

another

subgoal

for

checking

the

total

number

of

arguments

-RRB-

In

databases

schema

browsing

is

common

-LSB-

-RSB-

In

HiLog

browsing

can

be

performed

through

the

same

query

language

as

the

one

used

for

data

retrieval

For

instance

relations

-LRB-

Y

-RRB-

-LRB-

X

-RRB-

X

-LRB-

Y

Z

-RRB-

relations

-LRB-

Z

-RRB-

-LRB-

X

-RRB-

X

-LRB-

Y

Z

-RRB-

relations

-LRB-

john

-RRB-

-LRB-

X

-RRB-

will

return

the

names

of

all

binary

predicates

whose

extensions

-LRB-

under

Herbrand

interpretations

-RRB-

contain

one

or

more

tuples

with

the

token

john

HiLog

shares

this

browsing

capability

with

another

recently

proposed

language

called

F-logic

-LSB-

-RSB-

The

ability

to

use

sets

is

very

important

in

logic

programming

Prolog

supports

the

use

of

sets

by

means

of

the

setof

construct

which

has

only

an

operational

semantics

Although

newer

logic

languages

such

as

LDL

-LSB-

-RSB-

or

COL

-LSB-

-RSB-

do

provide

semantics

for

sets

they

have

to

severely

restrict

their

use

to

avoid

logical

paradoxes

and/or

computational

intractability

In

HiLog

sets

can

be

represented

naturally

by

parameterized

predicates

mentioned

earlier

For

instance

the

following

HiLog

rule

defines

groups

of

satisfied

employees

working

for

each

manager

An

employee

is

satisfied

with

the

job

if

and

only

if

he

earns

more

than

his

boss

sat

empl

-LRB-

Boss

-RRB-

-LRB-

Empl

-RRB-

supervises

-LRB-

Boss

Empl

-RRB-

salary

-LRB-

Boss

B

sal

-RRB-

salary

-LRB-

Empl

E

sal

-RRB-

E

sal

B

sal

The

set-term

sat

empl

-LRB-

Boss

-RRB-

is

akin

to

the

setof

and

the

grouping

constructs

of

Prolog

and

LDL

respectively

although

HiLog

sets

are

not

constructed

or

used

the

same

way

Having

defined

sets

intensionally

via

terms

we

can

go

on

and

use

these

sets

in

other

relationships

as

in

the

following

fragment

that

associates

packages

of

benefits

with

groups

of

satisfied

employees

-LRB-

health

ins

-RRB-

-LRB-

life

ins

-RRB-

-LRB-

free

car

-RRB-

-LRB-

long

vacations

-RRB-

benefits

-LRB-

sat

empl

-LRB-

john

-RRB-

-RRB-

benefits

-LRB-

sat

empl

-LRB-

bob

-RRB-

-RRB-

The

following

is

a

query

regarding

benefit

packages

that

bob

enjoys

as

an

employee

in

the

above

enterprise

benefits

-LRB-

X

Y

-RRB-

Y

-LRB-

bob

-RRB-

Note

that

the

above

information

about

sets

can

be

also

encoded

in

Prolog

but

less

naturally

A

more

detailed

discussion

of

these

issues

appears

in

Sections

and

As

seen

from

the

earlier

examples

HiLog

terms

are

also

atomic

formulas

In

this

capacity

their

semantics

is

indirectly

captured

by

the

truth

value

assigned

to

each

ground

term

For

instance

instead

of

saying

that

a

pair

a

b

is

in

the

relation

for

a

predicate

p

we

say

that

the

term

p

-LRB-

a

b

-RRB-

denotes

a

true

proposition

Formal

details

are

provided

in

the

next

two

subsections

Language

In

addition

to

parentheses

connectives

and

quantifiers

the

alphabet

of

a

language

L

of

HiLog

contains

a

countably

infinite

set

V

of

variables

and

a

countable

set

S

of

parameter

symbols

We

assume

that

V

and

S

are

disjoint

The

set

T

of

HiLog

terms

of

L

is

a

minimal

set

of

strings

over

the

alphabet

satisfying

the

following

conditions

ffl

V

-LSB-

S

T

ffl

If

t

tn

are

in

T

then

t

-LRB-

tn

-RRB-

T

where

n

Notice

that

according

to

this

definition

a

term

can

be

applied

to

any

finite

number

of

terms

and

parameter

symbols

are

arityless

An

atomic

formula

is

a

term

More

complex

formulas

are

built

from

atomic

formulas

in

the

usual

way

by

means

of

connectives

-LRB-

also

written

as

-RRB-

and

quantifiers

and

In

addition

we

use

and

ae

to

denote

the

implication

where

-LRB-

OE

-RRB-

-LRB-

OE

ae

-RRB-

-LRB-

OE

-RRB-

Likewise

OE

and

OE

oe

will

stand

for

OE

The

bi-directional

implication

also

has

the

standard

definition

A

literal

is

either

an

atomic

formula

a

positive

literal

or

the

negation

A

of

an

atomic

formula

A

a

negative

literal

A

clause

is

of

the

form

Xk

-LRB-

Ln

-RRB-

where

Ln

are

literals

and

Xk

are

all

the

variables

occurring

in

Ln

It

is

usually

written

simply

as

Ln

When

n

a

clause

is

called

the

empty

clause

A

Horn

clause

is

a

clause

that

contains

at

most

one

positive

literal

A

definite

clause

is

a

Horn

clause

of

the

form

A

Bn

where

A

Bn

are

atomic

formulas

definite

clauses

are

usually

written

as

A

Bn

where

A

is

the

head

and

the

conjunction

Bn

is

the

body

of

the

clause

A

negative

clause

is

a

clause

containing

no

positive

literals

A

goal

is

a

conjunction

of

literals

and

a

query

is

the

negation

of

a

goal

which

can

be

written

as

a

negative

clause

For

practical

applications

we

consider

definite

logic

programs

that

consist

of

a

finite

number

of

definite

clauses

Section

briefly

deals

with

logic

programs

with

negation

usual

in

logic

programming

literature

we

use

to

denote

conjunction

of

literals

in

the

clause

body

Semantic

Structures

Since

at

the

first

glance

the

semantics

of

HiLog

may

seem

a

bit

unusual

we

precede

the

formal

description

by

an

informal

discussion

that

shows

how

the

semantics

of

the

first-order

predicate

calculus

has

evolved

to

support

higher-orderness

of

HiLog

First

we

define

the

Herbrand

semantics

because

it

is

especially

close

to

the

Herbrand

semantics

of

predicate

calculus

The

Herbrand

universe

for

a

HiLog

language

L

is

the

set

of

all

ground

-LRB-

i.e.

variable-free

-RRB-

HiLog

terms

in

T

Since

terms

in

HiLog

are

also

atomic

formulas

it

follows

that

Herbrand

universe

is

identical

to

Herbrand

base

-LRB-

cf.

-LSB-

-RSB-

-RRB-

This

is

not

a

coincidence

if

we

want

to

manipulate

atomic

formulas

as

terms

the

former

must

be

elements

of

the

universe

Now

a

Herbrand

interpretation

is

simply

a

subset

of

the

Herbrand

base

-LRB-

universe

-RRB-

the

definition

of

Herbrand

interpretation

commonly

used

in

logic

programming

-LSB-

-RSB-

The

definition

of

formula

satisfaction

in

such

interpretations

simply

repeats

the

corresponding

definition

in

-LSB-

-RSB-

Although

Herbrand

interpretations

suffice

for

many

of

the

needs

of

logic

programming

there

are

at

least

two

important

reasons

to

be

interested

in

a

more

general

notion

of

semantic

structure

-LSB-

-RSB-

programs

with

equality

and

the

semantics

of

negation

by

failure

Recall

that

in

first-order

predicate

calculus

a

semantic

structure

M

for

a

language

L

is

a

pair

U

I

where

U

is

called

the

domain

of

M

and

I

is

a

function

that

interprets

parameters

of

L

-LRB-

i.e.

constants

function

symbols

and

predicate

symbols

-RRB-

I

consists

of

two

different

mappings

F

and

P

The

former

F

interprets

each

k-ary

-LRB-

k

-RRB-

function

symbol

of

L

by

a

function

Uk

U

the

mapping

P

maps

each

n-ary

predicate

symbol

to

an

n-ary

relation

over

U

We

consider

constants

as

function

symbols

so

F

takes

care

of

constants

as

well

In

what

follows

whenever

f

is

a

function

symbol

I

-LRB-

f

-RRB-

will

stand

for

F

-LRB-

f

-RRB-

when

p

is

a

predicate

name

I

-LRB-

p

-RRB-

will

stand

for

P

-LRB-

p

-RRB-

Note

that

the

set

of

function

symbols

and

the

set

of

predicate

symbols

are

disjoint

In

HiLog

one

of

our

original

goals

was

to

eliminate

the

syntactic

distinction

among

constants

function

symbols

and

predicates

so

one

can

not

tell

a

constant

from

a

predicate

or

a

function

symbol

Therefore

F

and

P

must

map

each

parameter

symbol

to

all

of

the

following

an

element

of

U

a

function

over

U

and

a

relation

on

U

Another

of

our

goals

was

to

make

symbols

arityless

So

each

symbol

must

be

mapped

into

an

infinite

tuple

of

functions

and

relations

one

for

each

arity

There

is

a

subtlety

however

How

should

we

interpret

a

formula

like

X

-LRB-

a

-RRB-

where

X

is

a

variable

In

predicate

calculus

such

formulas

are

interpreted

with

respect

to

a

variable

assignment

which

is

a

mapping

V

U

However

-LRB-

X

-RRB-

is

an

element

of

the

semantic

domain

U

and

in

order

to

interpret

X

-LRB-

a

-RRB-

with

respect

to

we

must

associate

relations

with

elements

of

U

rather

then

parameters

of

L.

Thus

the

interpreting

mappings

F

and

P

must

associate

functions

and

relations

with

every

element

in

U

including

I

-LRB-

s

-RRB-

for

each

s

S

not

with

the

symbols

in

S.

Following

the

usual

development

in

predicate

calculus

we

can

extend

a

variable

assignment

recursively

to

the

set

T

of

all

terms

as

follows

ffl

-LRB-

s

-RRB-

I

-LRB-

s

-RRB-

for

every

parameter

symbol

in

S

ffl

-LRB-

t

-LRB-

tn

-RRB-

-RRB-

F

-LRB-

-LRB-

t

-RRB-

-RRB-

-LRB-

-LRB-

-RRB-

-LRB-

tn

-RRB-

-RRB-

However

the

truth

of

an

atomic

formula

t

-LRB-

tn

-RRB-

can

be

determined

either

with

respect

to

the

n-ary

relation

that

P

associates

with

-LRB-

t

-RRB-

that

is

P

-LRB-

-LRB-

t

-RRB-

-RRB-

-LRB-

-LRB-

-RRB-

-LRB-

tn

-RRB-

-RRB-

or

with

respect

to

the

relation

is

not

to

say

that

we

dismiss

the

utility

of

typing

To

the

contrary

we

distinguish

between

well-formedness

and

typing

which

we

feel

are

orthogonal

concepts

Our

goal

here

is

to

relax

the

stringent

well-formedness

requirements

of

predicate

calculus

while

preserving

the

ability

to

talk

about

type

correctness

An

attempt

to

introduce

types

into

HiLog

is

described

in

-LSB-

-RSB-

-LRB-

i.e.

true

or

false

-RRB-

which

it

associates

with

-LRB-

t

-LRB-

tn

-RRB-

-RRB-

that

is

P

-LRB-

-LRB-

t

-LRB-

tn

-RRB-

-RRB-

-RRB-

Both

alternatives

seem

reasonable

but

the

second

one

results

in

a

more

uniform

treatment

of

HiLog

terms

Furthermore

it

turns

out

that

under

certain

natural

assumptions

these

two

choices

lead

to

the

same

semantics

It

is

easy

to

see

now

that

adopting

the

second

alternative

obviates

the

need

for

P

Indeed

all

we

need

is

to

classify

elements

of

the

domain

U

into

the

intensions

of

true

and

false

propositions

A

simple

way

to

do

this

is

by

introducing

a

subset

Utrue

U

that

designates

propositions

that

are

true

in

M.

Coming

back

to

Herbrand

interpretations

discussed

at

the

beginning

of

this

section

we

see

that

in

the

Herbrand

case

Utrue

is

precisely

that

subset

of

the

Herbrand

base

that

determines

the

interpretation

After

this

informal

introduction

we

are

ready

for

the

formal

development

A

semantic

structure

for

HiLog

M

is

a

quadruple

U

Utrue

I

F

where

ffl

U

is

a

nonempty

set

of

intensions

for

the

domain

of

M

ffl

Utrue

is

a

subset

of

U

that

specifies

which

of

the

elements

in

U

are

intensions

of

true

propositions

ffl

I

S

U

is

a

function

that

associates

an

intension

with

each

logical

symbol

ffl

F

U

Y

k

-LSB-

Uk

U

-RSB-

is

a

function

such

that

for

every

u

U

and

k

the

k-th

projection

of

F

-LRB-

u

-RRB-

also

denoted

by

u

-LRB-

k

-RRB-

F

is

a

function

in

-LSB-

Uk

U

-RSB-

Here

Q

denotes

the

Cartesian

product

of

sets

and

-LSB-

Uk

U

-RSB-

is

the

set

of

all

functions

that

map

Uk

to

U

Given

a

semantic

structure

M

and

a

variable

assignment

V

U

we

extend

it

recursively

to

the

set

T

of

terms

as

follows

ffl

-LRB-

s

-RRB-

I

-LRB-

s

-RRB-

for

every

s

S

ffl

-LRB-

t

-LRB-

tn

-RRB-

-RRB-

-LRB-

-LRB-

t

-RRB-

-RRB-

-LRB-

n

-RRB-

F

-LRB-

-LRB-

-RRB-

-LRB-

tn

-RRB-

-RRB-

Let

OE

be

an

atomic

formula

It

is

satisfied

by

M

under

denoted

M

j

OE

if

and

only

if

-LRB-

OE

-RRB-

Utrue

We

thus

see

that

a

HiLog

term

may

represent

an

individual

a

function

a

predicate

or

an

atomic

formula

in

different

contexts

The

intension

of

a

term

is

its

associated

element

in

the

universe

U

Extensional

aspects

of

terms

are

captured

as

follows

The

extensional

aspect

of

a

term

viewed

as

a

proposition

is

its

truth

value

defined

by

its

membership

in

Utrue

while

the

extensional

meaning

of

a

term

in

its

capacity

as

a

function

is

captured

by

F

For

example

if

a

term

t

appears

as

a

k-ary

function

e.g.

in

t

-LRB-

tk

-RRB-

its

extensional

meaning

under

a

variable

assignment

is

the

k-th

projection

of

the

vector

of

functions

associated

with

the

intension

of

t

that

is

-LRB-

-LRB-

t

-RRB-

-RRB-

-LRB-

k

-RRB-

F

On

the

other

hand

the

role

of

the

above

term

as

a

proposition

is

indirectly

captured

through

F

and

Utrue

so

that

t

-LRB-

tk

-RRB-

is

true

if

and

only

if

-LRB-

t

-LRB-

tk

-RRB-

-RRB-

Utrue

Finally

the

meaning

of

complex

formulas

is

defined

in

the

standard

way

ffl

M

j

-LRB-

OE

-RRB-

if

and

only

if

M

j

OE

and

M

j

ffl

M

j

-LRB-

OE

-RRB-

if

and

only

if

M

j

OE

or

M

j

ffl

M

j

-LRB-

OE

-RRB-

if

and

only

if

M

OE

ffl

M

j

-LRB-

-RRB-

OE

if

and

only

if

for

every

variable

assignment

that

may

differ

from

only

on

X

M

j

OE

ffl

M

j

-LRB-

-RRB-

OE

if

and

only

if

for

some

variable

assignment

that

may

differ

from

only

on

X

M

j

OE

For

closed

formulas

-LRB-

i.e.

formulas

all

of

whose

variables

are

quantified

-RRB-

M

j

OE

does

not

depend

on

and

we

can

write

simply

M

j

OE

Interpreted

symbols

such

as

true

and

false

can

be

incorporated

into

HiLog

by

requiring

interpretations

to

satisfy

the

following

restrictions

ffl

I

-LRB-

true

-RRB-

Utrue

ffl

I

-LRB-

false

-RRB-

Utrue

ffl

I

-LRB-

=-RRB-

-LRB-

k

-RRB-

F

-LRB-

uk

-RRB-

Utrue

if

and

only

if

uk

-LRB-

i.e.

if

all

the

ui

's

denote

the

same

element

of

U

-RRB-

Compared

with

other

higher-order

logics

such

as

Church

's

theory

of

types

-LSB-

-RSB-

and

Prolog

-LSB-

-RSB-

HiLog

treats

only

atomic

formulas

as

first-class

objects

Formulas

that

contain

connectives

such

as

and

or

or

not

could

be

built

into

HiLog

by

making

these

connectives

into

constants

and

requiring

every

semantic

structure

to

satisfy

the

following

conditions

ffl

I

-LRB-

and

-RRB-

-LRB-

-RRB-

F

-LRB-

-RRB-

Utrue

if

and

only

if

both

and

are

in

Utrue

for

every

U

ffl

I

-LRB-

or

-RRB-

-LRB-

-RRB-

F

-LRB-

-RRB-

Utrue

if

and

only

if

or

are

in

Utrue

for

every

U

ffl

I

-LRB-

not

-RRB-

-LRB-

-RRB-

F

-LRB-

d

-RRB-

Utrue

if

and

only

if

d

is

not

in

Utrue

for

every

d

U

Alternatively

the

above

connectives

can

be

defined

using

HiLog

clauses

e.g.

and

-LRB-

X

Y

-RRB-

X

Y.

Encoding

formulas

with

quantified

variables

would

require

introduction

of

abstraction

into

HiLog

which

can

be

also

done

but

is

beyond

the

scope

of

this

paper

Relationship

to

Prolog

and

Predicate

Calculus

In

this

section

we

show

from

various

perspectives

that

HiLog

is

in

a

well-defined

sense

a

faithful

extension

of

predicate

calculus

In

the

sequel

we

will

use

PC

as

an

abbreviation

for

predicate

calculus

First

we

compare

HiLog

to

what

we

call

contextual

predicate

calculus

This

is

an

extension

of

ordinary

pure

predicate

calculus

and

is

inspired

by

the

way

Prolog

permits

the

use

of

the

same

symbol

in

different

contexts

-LRB-

e.g.

as

a

predicate

symbol

or

as

a

function

symbol

of

different

arities

-RRB-

Syntactically

formulas

in

contextual

PC

are

also

well-formed

in

HiLog

and

therefore

there

is

a

question

of

whether

the

validity

problems

for

such

formulas

under

the

semantics

of

HiLog

and

contextual

PC

coincide

We

show

that

this

is

not

always

the

case

but

under

certain

conditions

the

two

validity

problems

do

coincide

In

the

second

subsection

we

consider

formulas

in

pure

predicate

calculus

Such

formulas

are

also

well-formed

in

contextual

PC

and

therefore

also

in

HiLog

We

then

establish

that

the

validity

problem

in

pure

PC

coincides

with

the

same

problem

in

HiLog

for

an

even

larger

class

of

formulas

than

in

the

case

of

contextual

PC

The

third

subsection

shows

that

every

HiLog

formula

can

be

encoded

as

a

formula

in

pure

PC

Validity

in

Contextual

Predicate

Calculus

and

HiLog

In

Prolog

the

same

symbol

may

appear

in

different

contexts

as

a

predicate

a

constant

or

a

function

symbol

the

same

symbol

can

even

occur

with

different

arities

in

different

parts

of

the

program

The

exact

role

played

by

an

occurrence

of

a

symbol

depends

on

the

context

in

which

this

symbol

occurs

Such

Prolog

programs

are

normally

understood

as

formulas

in

predicate

calculus

in

which

different

occurrences

of

the

same

symbol

are

replaced

by

different

function

or

predicate

symbols

-LRB-

whichever

is

appropriate

-RRB-

of

suitable

arities

This

ad

hoc

use

of

parameter

symbols

in

multiple

roles

motivates

a

simple

extension

of

PC

which

we

call

contextual

predicate

calculus

A

language

L

of

contextual

PC

contains

a

set

of

parameter

symbols

S

and

a

set

of

variables

V

A

term

is

either

a

variable

a

parameter

symbol

or

an

expression

of

the

form

s

-LRB-

tn

-RRB-

where

s

S

n

and

tn

are

terms

An

atomic

formula

is

any

term

other

than

a

variable

and

the

rest

of

the

definitions

are

as

usual

Clearly

contextual

PC

is

an

extension

of

PC

in

the

direction

of

HiLog

but

is

not

as

radical

It

stops

short

of

introducing

a

higher-order

syntax

-LRB-

because

s

above

is

an

element

of

S

not

a

variable

-RRB-

Every

formula

in

contextual

PC

is

also

a

formula

in

HiLog

On

the

other

hand

X

and

X

-LRB-

a

-RRB-

-LRB-

b

-RRB-

are

well-formed

formulas

in

HiLog

but

not

in

contextual

PC

Similarly

every

PC

formula

is

also

a

formula

in

contextual

PC

but

not

vice

versa

e.g.

s

-LRB-

s

s

-RRB-

is

a

formula

in

contextual

PC

but

not

in

PC

Semantics

of

contextual

PC

is

also

a

middle

ground

between

HiLog

and

pure

PC

A

semantic

structure

for

a

contextual

PC

language

is

a

tuple

M

U

IF

IP

For

each

symbol

s

S

the

function

IF

associates

an

infinite

tuple

where

is

an

element

of

U

and

for

i

fi

is

a

function

U

i

U

Likewise

IP

-LRB-

s

-RRB-

is

a

tuple

where

is

a

relation

is

a

unary

relation

etc.

We

will

denote

the

k-th

components

of

the

above

infinite

tuples

by

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

and

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

respectively

-LRB-

Recall

that

a

relation

is

a

set

of

tuples

and

that

there

is

only

one

such

tuple

the

empty

tuple

Therefore

there

are

only

two

relations

the

empty

one

and

the

relation

f

g

The

former

is

used

to

interpret

false

propositions

while

the

latter

interprets

true

propositions

-RRB-

Given

a

variable

assignment

V

U

we

define

-LRB-

s

-RRB-

s

whenever

s

S

and

-LRB-

s

-LRB-

tn

-RRB-

-RRB-

I

-LRB-

n

-RRB-

F

-LRB-

s

-RRB-

-LRB-

-LRB-

-RRB-

-LRB-

tn

-RRB-

-RRB-

If

s

-LRB-

tn

-RRB-

is

an

atomic

formula

M

j

s

-LRB-

tn

-RRB-

if

and

only

if

-LRB-

-RRB-

-LRB-

tn

-RRB-

I

-LRB-

n

-RRB-

P

-LRB-

s

-RRB-

The

rest

of

the

definition

of

j

is

the

same

as

for

PC

and

HiLog

Although

there

are

contextual

PC

formulas

that

are

not

well-formed

in

PC

any

such

formula

OE

can

be

transformed

into

a

formula

in

PC

by

replacing

occurrences

of

each

parameter

symbol

as

follows

All

occurrences

of

s

as

a

k-ary

function

are

replaced

by

a

new

k-ary

function

symbol

skF

all

occurrences

of

s

in

the

position

of

a

k-ary

predicate

are

replaced

by

a

new

predicate

symbol

skP

For

instance

under

this

transformation

s

-LRB-

s

t

-LRB-

t

-RRB-

-RRB-

becomes

-LRB-

-LRB-

-RRB-

-RRB-

This

transformation

is

explicit

in

Prolog

where

parameter

symbols

can

assume

multiple

roles

A

justification

for

using

this

transformation

stems

from

the

following

easy

fact

Lemma

A

formula

in

contextual

PC

is

valid

if

and

only

if

its

transformation

into

pure

PC

is

valid

A

formula

in

PC

is

valid

if

and

only

if

it

is

also

valid

when

considered

under

the

semantics

of

contextual

PC

Proof

Let

L

be

a

language

of

contextual

PC

and

be

the

corresponding

language

of

pure

PC

in

which

the

transformed

formulas

are

expressed

That

is

if

S

is

a

set

of

parameters

of

L

then

the

set

of

function

symbols

of

is

fskF

jk

s

Lg

where

the

superscript

indicates

the

arity

fskP

jk

s

Lg

is

the

set

of

predicate

symbols

of

The

proof

of

-LRB-

-RRB-

is

then

carried

out

by

constructing

an

isomorphism

M

between

the

sets

of

semantic

structures

for

L

and

such

that

if

M

U

IF

IP

is

a

semantic

structure

for

L

OE

is

a

formula

in

L

and

is

its

translation

to

then

M

j

OE

if

and

only

if

M

-LRB-

M

-RRB-

j

M

-LRB-

M

-RRB-

U

I

is

constructed

in

an

obvious

way

I

-LRB-

skP

-RRB-

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

and

I

-LRB-

skF

-RRB-

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

To

prove

-LRB-

-RRB-

consider

a

language

of

PC

Let

be

a

language

of

contextual

PC

with

the

same

sets

of

parameters

and

variables

Let

U

I

be

a

semantic

structure

of

The

corresponding

semantic

structure

U

IF

IP

is

constructed

thus

If

p

is

a

k-ary

predicate

symbol

in

then

I

-LRB-

k

-RRB-

P

-LRB-

p

-RRB-

I

-LRB-

p

-RRB-

if

f

is

a

k-ary

function

symbol

in

then

I

-LRB-

k

-RRB-

F

-LRB-

f

-RRB-

I

-LRB-

f

-RRB-

The

rest

of

IP

and

IF

can

be

arbitrary

It

is

easy

to

see

that

a

PC

formula

OE

in

is

true

in

if

and

only

if

it

is

true

in

Thus

if

such

a

formula

is

valid

when

considered

as

a

formula

in

then

it

is

valid

as

a

formula

in

By

reversing

the

above

construction

for

every

semantic

structure

of

the

language

of

contextual

PC

one

can

construct

a

PC

structure

for

such

that

a

PC

formula

OE

in

is

true

in

if

and

only

if

it

is

true

in

Thus

if

OE

is

valid

as

a

PC

formula

in

it

is

valid

as

a

formula

in

the

contextual

PC

language

The

above

lemma

essentially

says

that

contextual

PC

is

only

a

minor

extension

of

PC

However

because

of

the

greater

similarity

between

the

syntax

of

contextual

PC

and

HiLog

it

is

instructive

to

investigate

the

relationship

between

the

validity

problems

in

these

two

logics

Suppose

S

and

V

is

a

set

of

parameters

and

variables

respectively

Let

LH

be

a

language

of

HiLog

and

LP

be

the

sublanguage

of

contextual

PC

In

view

of

Lemma

it

is

tempting

to

think

that

every

formula

in

LP

is

valid

under

the

semantics

of

contextual

PC

if

and

only

if

it

is

valid

under

the

semantics

of

HiLog

It

turns

out

that

the

difference

between

these

semantics

is

more

fundamental

than

in

the

case

of

the

two

flavors

of

PC

Consider

the

following

formula

that

is

valid

in

HiLog

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-RRB-

oe

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-RRB-

-LRB-

-RRB-

It

is

easy

to

see

that

this

formula

is

not

valid

in

contextual

PC

for

the

latter

can

assign

relations

to

the

parameters

s

and

r

that

are

not

related

in

any

way

to

the

meaning

assigned

to

the

terms

s

-LRB-

a

-RRB-

and

r

-LRB-

b

c

-RRB-

This

stands

in

sharp

contrast

with

HiLog

where

truth

value

is

assigned

to

intensions

of

atoms

and

according

to

the

premise

of

-LRB-

-RRB-

the

terms

s

-LRB-

a

-RRB-

and

r

-LRB-

b

c

-RRB-

do

have

the

same

intension

hence

as

atomic

formulas

they

also

must

have

the

same

truth

value

Nevertheless

there

is

a

correspondence

between

valid

formulas

of

LP

in

HiLog

and

contextual

PC

in

the

important

cases

described

in

Theorem

below

Definition

Given

a

language

L

of

contextual

PC

a

semantic

structure

M

U

IF

IP

is

free

if

and

only

if

for

every

pair

of

parameter

symbols

f

and

g

and

any

pair

of

arities

n

and

m

the

following

holds

ffl

for

all

un

and

vm

in

U

I

-LRB-

n

-RRB-

F

-LRB-

f

-RRB-

-LRB-

un

-RRB-

I

-LRB-

m

-RRB-

F

-LRB-

g

-RRB-

-LRB-

vm

-RRB-

if

and

only

if

f

and

g

are

identical

symbols

n

m

and

ui

vi

are

identical

elements

in

U

for

all

i

-LRB-

i

n

-RRB-

Definition

A

sentence

OE

in

contextual

PC

is

freely-interpretable

if

it

has

the

following

property

ffl

if

OE

is

satisfied

by

every

free

semantic

structure

then

it

is

satisfied

by

all

semantic

structures

Theorem

Let

as

before

LH

be

a

language

of

HiLog

and

LP

be

the

sublanguage

of

contextual

PC

-LRB-

i.e.

they

share

the

same

set

S

of

parameters

and

the

set

V

of

variables

-RRB-

Let

OE

be

a

formula

in

LP

Then

If

j

cpc

OE

then

j

hilog

OE

If

OE

is

freely-interpretable

then

j

hilog

OE

if

and

only

if

j

cpc

OE

Here

j

cpc

and

j

hilog

denote

the

logical

implication

relation

with

respect

to

the

semantics

of

contextual

PC

and

HiLog

respectively

Proof

We

prove

both

directions

of

-LRB-

-RRB-

The

proof

of

the

if

direction

of

-LRB-

-RRB-

is

also

a

proof

of

-LRB-

-RRB-

To

prove

-LRB-

-RRB-

suppose

that

j

hilog

OE

holds

We

show

that

j

cpc

OE

holds

as

well

Given

a

free

semantic

structure

MP

U

IF

IP

for

LP

we

construct

a

semantic

structure

MH

U

Utrue

I

F

of

LH

as

follows

ffl

The

domain

U

is

the

same

as

in

MP

ffl

I

-LRB-

s

-RRB-

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

for

every

symbol

s

of

S

ffl

for

every

u

U

and

every

k

if

u

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

for

some

s

S

then

u

-LRB-

k

-RRB-

F

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

otherwise

define

u

-LRB-

k

-RRB-

F

-LRB-

uk

-RRB-

d

for

some

fixed

d

U

ffl

u

Utrue

if

and

only

if

one

of

the

following

conditions

holds

-LCB-

u

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

for

some

s

S

such

that

I

-LRB-

-RRB-

P

-LRB-

s

-RRB-

is

a

nonempty

-LRB-

equivalently

if

MP

j

s

-RRB-

or

-LCB-

u

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

-LRB-

uk

-RRB-

for

some

s

S

and

ui

U

-LRB-

i

k

-RRB-

such

that

uk

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

The

semantic

structure

MH

is

well-defined

since

MP

is

free

It

can

be

shown

by

induction

that

for

any

formula

OE

of

LP

and

any

variable

assignment

MP

j

OE

if

and

only

if

MH

j

OE

Therefore

if

j

hilog

OE

then

OE

is

satisfied

in

every

free

semantic

structure

for

LP

Since

OE

is

freely-interpretable

it

is

satisfied

in

every

semantic

structure

for

LP

that

is

j

cpc

OE

holds

To

prove

the

other

direction

of

-LRB-

-RRB-

let

us

assume

that

j

cpc

OE

holds

We

need

to

show

that

j

hilog

OE

holds

as

well

Given

a

semantic

structure

MH

U

Utrue

IH

F

for

LH

we

construct

a

semantic

structure

MP

U

IF

IP

for

LP

as

follows

ffl

The

domain

U

is

the

same

as

in

MH

ffl

for

every

symbol

s

of

LH

-LCB-

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

IH

-LRB-

s

-RRB-

-LCB-

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

-LRB-

IH

-LRB-

s

-RRB-

-RRB-

-LRB-

k

-RRB-

F

for

every

k

-LCB-

I

-LRB-

-RRB-

P

-LRB-

s

-RRB-

is

a

non-empty

relation

-LRB-

equivalently

MP

j

s

-RRB-

if

and

only

if

IH

-LRB-

s

-RRB-

Utrue

-LCB-

uk

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

k

if

and

only

if

-LRB-

IH

-LRB-

s

-RRB-

-RRB-

-LRB-

k

-RRB-

F

-LRB-

uk

-RRB-

Utrue

that

the

nonempty

relation

interprets

true

propositions

while

the

empty

relation

interprets

false

propositions

Again

it

can

be

shown

by

induction

that

for

any

formula

OE

of

LP

and

any

variable

assignment

MP

j

OE

if

and

only

if

MH

j

OE

Therefore

if

there

exists

some

MH

such

that

MH

OE

a

semantic

structure

MP

of

LP

can

be

constructed

such

that

MP

OE

contrary

to

the

assumption

Thus

j

hilog

OE

holds

Although

the

condition

in

Theorem

is

not

syntactic

it

encompasses

important

classes

of

formulas

The

following

lemma

shows

that

all

equality-free

formulas

of

predicate

calculus

are

freely-interpretable

The

other

interesting

class

that

is

particularly

important

for

logic

programming

consists

of

sets

of

definite

clauses

with

equality

but

such

that

the

equality

is

restricted

to

clause

bodies

If

G

is

a

query

and

is

a

negative

clause

and

P

is

a

definite

logic

program

-LRB-

possibly

with

equality

in

clause

bodies

-RRB-

then

evaluating

the

query

amounts

to

showing

that

the

set

S

G

-LSB-

P

is

unsatisfiable

Since

Theorem

concerns

validity

-LRB-

which

is

a

contrapositive

of

unsatisfiability

-RRB-

the

class

of

formulas

to

consider

in

this

theorem

is

f

S

j

S

is

a

conjunction

of

Horn

clauses

free

of

equality

in

the

headg

Lemma

The

following

classes

of

contextual

PC

formulas

are

freely-interpretable

Sets

of

equality-free

sentences

Formulas

of

the

form

S

where

S

is

a

conjunction

of

Horn

clauses

free

of

in

clause-heads

Proof

Consider

a

language

L

of

contextual

PC

with

a

set

of

parameters

S.

Let

OE

be

a

formula

in

L

that

has

one

of

the

forms

-LRB-

-RRB-

or

-LRB-

-RRB-

above

Assume

that

for

some

semantic

structure

M

U

IF

IP

for

L

M

OE

We

show

that

there

exists

a

free

semantic

structure

U

I

F

I

P

such

that

OE

The

domain

U

of

is

a

free

algebra

built

out

of

the

elements

of

U

and

parameter

symbols

of

L

In

other

words

it

is

a

minimal

set

satisfying

the

following

conditions

ffl

U

-LSB-

S

U

ffl

if

dk

are

in

U

and

s

S

then

the

abstract

symbol

s

-LRB-

dk

-RRB-

is

in

U

for

every

k

For

every

s

S

define

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

s

and

for

each

k

define

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

-LRB-

dk

-RRB-

s

-LRB-

dk

-RRB-

for

all

dk

in

U

There

is

a

natural

mapping

U

U

defined

thus

For

every

element

u

in

U

the

corresponding

element

u

in

U

is

such

that

ffl

u

u

if

u

U

ffl

s

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

if

s

S

and

ffl

-LRB-

s

-LRB-

uk

-RRB-

-RRB-

I

-LRB-

k

-RRB-

F

-LRB-

s

-RRB-

-LRB-

u

u?k

-RRB-

Next

define

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

as

follows

uk

I

-LRB-

k

-RRB-

P

-LRB-

s

-RRB-

if

and

only

if

u

u?k

I

-LRB-

k

-RRB-

P

-LRB-

p

-RRB-

By

the

definition

is

a

free

semantic

structure

and

the

mapping

U

U

is

a

homomorphism

of

onto

M

-LSB-

-RSB-

By

the

Homomorphism

Theorem

-LSB-

-RSB-

the

following

properties

hold

-LRB-

i

-RRB-

If

V

U

is

a

variable

assignment

with

respect

to

then

there

is

a

variable

assignment

V

U

with

respect

to

M

defined

as

follows

for

each

variable

X

of

L

-LRB-

X

-RRB-

-LRB-

-LRB-

X

-RRB-

-RRB-

-LSB-

-RSB-

Homomorphism

Theorem

was

stated

for

PC

Its

validity

for

CPC

is

immediate

from

Lemma

-LRB-

ii

-RRB-

For

any

term

t

of

L

-LRB-

t

-RRB-

-LRB-

-LRB-

t

-RRB-

-RRB-

where

-LRB-

t

-RRB-

is

evaluated

with

respect

to

M

while

-LRB-

t

-RRB-

is

evaluated

with

respect

to

-LRB-

iii

-RRB-

The

mapping

is

an

epimorphism

of

variable

assignments

i.e.

for

every

variable

assignment

for

M

there

is

an

assignment

for

M

such

that

-LRB-

iv

-RRB-

For

every

equality-free

formula

OE

j

OE

if

and

only

if

M

j

OE

Obviously

-LRB-

-RRB-

follows

from

-LRB-

iii

-RRB-

and

-LRB-

iv

-RRB-

To

show

-LRB-

-RRB-

let

S

be

a

conjunction

of

Horn

clauses

free

of

equality

in

clause

heads

To

show

that

S

is

freely-interpretable

we

prove

that

M

S

implies

S

The

latter

is

the

same

as

saying

that

M

j

S

implies

j

S

and

since

S

is

a

conjunction

of

clauses

we

only

need

to

establish

this

fact

for

the

case

of

a

single

clause

r

that

is

to

show

that

M

j

r

implies

j

r.

Let

r

be

a

clause

of

the

form

Ln

Assume

that

M

j

r

Then

there

exists

some

literal

Li

such

that

M

j

Li

If

Li

is

not

an

equality

literal

then

j

Li

by

-LRB-

iii

-RRB-

and

thus

j

r

If

Li

is

an

equality

literal

then

Li

must

be

of

the

form

-LRB-

-RRB-

by

the

assumption

It

follows

from

the

definition

of

the

mapping

that

if

-LRB-

-RRB-

-LRB-

-RRB-

then

also

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

but

the

opposite

may

not

be

true

-RRB-

Hence

M

j

Li

implies

j

Li

and

also

j

r.

It

is

interesting

to

note

that

although

formulas

of

the

form

S

in

the

above

lemma

are

freelyinterpretable

S

itself

may

not

be

freely-interpretable

A

simple

example

is

the

formula

c

a

b

that

is

true

in

every

free

interpretation

but

is

not

a

valid

formula

in

general

Validity

in

Pure

Predicate

Calculus

and

HiLog

Since

formulas

in

pure

PC

are

also

formulas

in

contextual

PC

the

results

of

the

previous

subsection

hold

for

PC

formulas

as

well

However

since

the

language

of

PC

is

a

subset

of

contextual

PC

we

can

obtain

a

stronger

result

than

the

specialization

of

Theorem

to

PC

Definition

Let

P

be

a

set

of

formulas

in

a

PC

or

a

contextual

PC

language

L.

Let

denote

the

cardinality

of

the

set

of

parameters

of

L

We

say

that

P

is

cardinal

with

respect

to

L

if

the

following

property

holds

ffl

If

P

is

true

in

every

semantic

structure

M

such

that

the

cardinality

of

the

domain

of

M

is

at

least

then

P

is

true

in

every

semantic

structure

of

L.

Lemma

Every

freely-interpretable

formula

in

contextual

PC

is

cardinal

In

particular

the

formulas

of

the

form

described

in

Lemma

are

cardinal

Proof

For

simplicity

we

will

prove

the

lemma

for

languages

with

finite

sets

of

parameters

It

suffices

to

show

that

every

free

semantic

structure

for

a

language

L

of

contextual

PC

has

an

infinite

domain

Then

if

OE

is

freely-interpretable

suppose

that

it

is

true

in

every

semantic

structure

of

cardinality

at

least

Then

it

holds

in

every

infinite

and

in

particular

every

free

semantic

structure

Hence

since

OE

is

freely-interpretable

it

holds

in

every

semantic

structure

Let

M

U

IF

P

be

a

semantic

structure

for

L

and

let

s

be

a

parameter

in

L

Such

an

s

always

exists

since

any

language

of

CPC

contains

at

least

one

parameter

symbol

-LRB-

or

else

no

well-formed

here

is

the

assumption

that

whenever

P

is

viewed

as

a

PC

formula

then

M

is

a

PC

structure

and

when

P

is

viewed

as

a

CPC

formula

then

M

is

a

CPC

structure

formulas

can

be

constructed

in

this

language

-RRB-

Let

I

-LRB-

s

-RRB-

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

-LRB-

-RRB-

I

-LRB-

-RRB-

F

-LRB-

s

-RRB-

-LRB-

-RRB-

and

so

on

Then

by

the

definition

of

free

structures

and

so

on

are

all

distinct

elements

of

U

It

is

easy

to

see

that

the

class

of

cardinal

formulas

strictly

contains

the

class

of

freely-interpretable

formulas

Lemma

provides

for

the

inclusion

To

show

that

this

inclusion

is

strict

note

that

every

propositional

Horn

rule

-LRB-

in

PC

or

CPC

-RRB-

with

a

nontrivial

equality

in

the

body

-LRB-

e.g.

p

-LRB-

a

b

-RRB-

-RRB-

is

cardinal

but

not

freely-interpretable

Theorem

Let

OE

be

a

set

of

formulas

in

PC

-LRB-

and

hence

in

HiLog

-RRB-

Then

ffl

If

OE

is

valid

in

PC

then

it

is

valid

in

HiLog

ffl

If

OE

is

cardinal

then

it

is

valid

in

HiLog

if

and

only

if

it

is

valid

in

PC

Before

presenting

the

proof

we

show

that

the

second

part

of

this

theorem

may

not

hold

if

OE

is

not

cardinal

or

is

a

CPC

but

not

a

PC

formula

Consider

the

following

formula

-LRB-

q

-LRB-

a

-RRB-

r

-LRB-

a

-RRB-

-RRB-

-LRB-

X

Y

-RRB-

Clearly

this

is

a

well-formed

formula

both

in

predicate

calculus

and

in

HiLog

It

is

also

a

valid

HiLog

formula

because

whenever

the

right

side

of

the

formula

is

true

in

a

semantic

structure

M

U

Utrue

I

F

the

domain

of

this

structure

must

be

a

singleton

element

So

in

M

q

and

r

are

mapped

to

the

same

element

of

U

Therefore

I

-LRB-

q

-LRB-

a

-RRB-

-RRB-

I

-LRB-

r

-LRB-

a

-RRB-

-RRB-

and

the

left

hand

of

the

formula

holds

true

However

this

formula

is

not

valid

in

predicate

calculus

since

it

is

falsified

by

every

semantic

structure

that

has

a

one-element

domain

and

interprets

q

by

an

empty

relation

while

r

by

a

nonempty

one

One

reason

for

this

discrepancy

between

HiLog

and

predicate

calculus

is

that

the

domains

of

quantification

are

different

in

HiLog

this

domain

contains

r

and

q

while

in

predicate

calculus

it

does

not

Therefore

predicate

calculus

has

in

a

sense

more

interpretations

than

HiLog

Another

reason

is

that

truth

of

atomic

formulas

is

defined

via

intensions

of

these

formulas

in

the

domain

of

interpretation

rather

than

via

relations

associated

with

predicate

symbols

The

second

part

of

Theorem

hinges

in

an

essential

way

on

the

assumption

that

OE

is

a

well-formed

formula

in

predicate

calculus

It

is

not

true

for

example

for

formulas

in

contextual

predicate

calculus

Consider

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

-RRB-

-RRB-

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

-RRB-

-RRB-

-LRB-

-RRB-

This

formula

is

not

well-formed

in

PC

-LRB-

s

and

r

play

multiple

roles

here

-RRB-

but

is

well-formed

in

contextual

PC

It

is

also

a

cardinal

formula

It

is

easy

to

see

that

-LRB-

-RRB-

is

valid

in

HiLog

but

not

in

contextual

PC

-LRB-

the

latter

is

because

semantic

structures

in

contextual

PC

can

assign

different

truth

values

to

the

atoms

s

-LRB-

a

-RRB-

and

r

-LRB-

b

-RRB-

even

if

the

terms

s

-LRB-

a

-RRB-

and

r

-LRB-

b

-RRB-

have

the

same

intension

-RRB-

Another

observation

is

that

-LRB-

-RRB-

is

cardinal

but

not

freely-interpretable

-LRB-

it

holds

in

every

free

structure

because

the

premise

is

always

false

however

as

noted

above

this

formula

is

not

valid

in

contextual

PC

-RRB-

Since

the

class

of

cardinal

formulas

in

PC

is

strictly

larger

than

the

class

of

freely-interpretable

formulas

Theorem

strengthens

the

result

of

Theorem

for

the

class

of

PC

formulas

In

fact

since

cardinal

PC

formulas

that

are

valid

in

HiLog

are

also

valid

in

PC

-LRB-

Theorem

-RRB-

it

follows

that

they

are

also

freely

interpretable

-LRB-

as

are

all

valid

formulas

-RRB-

Thus

Theorems

and

together

imply

that

all

cardinal

yet

non-freely-interpretable

PC

formulas

are

not

valid

in

HiLog

and

in

PC

-LRB-

This

means

that

these

theorems

identify

the

same

class

of

valid

PC

formulas

that

are

also

valid

in

HiLog

However

Theorem

identifies

a

strictly

larger

class

of

non-valid

PC

formulas

that

are

also

non-valid

in

HiLog

-RRB-

Proof

of

Theorem

Let

LP

be

a

language

of

PC

with

a

set

of

parameters

S

and

a

set

of

variables

V

Let

LH

be

a

language

of

HiLog

with

the

same

sets

of

parameters

and

variables

We

define

a

pair

of

mappings

ffl

HtoP

LH

Structures

LP

Structures

ffl

PtoH

LP

Structures

LH

Structures

such

that

for

any

predicate

calculus

formula

over

LP

the

following

holds

where

j

pc

and

j

hilog

denote

logical

entailment

in

predicate

calculus

and

HiLog

respectively

If

MH

is

a

semantic

structure

for

LH

and

HtoP

-LRB-

MH

-RRB-

j

pc

OE

then

MH

j

hilog

OE

If

MP

is

a

semantic

structure

for

LP

such

that

the

cardinality

of

the

domain

of

M

is

at

least

that

of

S

and

PtoH

-LRB-

MP

-RRB-

j

hilog

OE

then

MP

j

pc

OE

The

theorem

immediately

follows

from

the

existence

of

the

mappings

with

these

two

properties

To

construct

HtoP

let

MH

U

Utrue

IH

F

be

a

semantic

structure

for

LH

Define

the

corresponding

structure

for

LP

as

follows

HtoP

-LRB-

MH

-RRB-

U

IP

has

the

same

domain

U

as

MH

and

IP

is

defined

below

ffl

IP

-LRB-

c

-RRB-

IH

-LRB-

c

-RRB-

if

c

is

a

constant

of

LP

ffl

IP

-LRB-

f

-RRB-

-LRB-

IH

-LRB-

f

-RRB-

-RRB-

-LRB-

k

-RRB-

F

if

f

is

a

k-ary

function

symbol

of

LP

and

ffl

IP

-LRB-

p

-RRB-

f

-LRB-

um

-RRB-

j

-LRB-

IH

-LRB-

p

-RRB-

-RRB-

-LRB-

m

-RRB-

F

-LRB-

um

-RRB-

Utrueg

Now

follows

straightforwardly

by

induction

on

the

structure

of

OE

Note

that

here

we

did

not

impose

any

restrictions

on

semantic

structures

To

prove

we

define

PtoH

as

follows

Let

MP

U

IP

be

a

semantic

structure

for

LP

where

the

cardinality

of

U

is

at

least

as

high

as

that

of

S.

Because

of

the

cardinality

assumption

there

is

a

mapping

IH

from

S

to

U

such

that

ffl

IH

-LRB-

c

-RRB-

IP

-LRB-

c

-RRB-

for

every

symbol

c

in

S

that

corresponds

to

a

constant

symbol

c

of

LP

and

ffl

IH

-LRB-

f

-RRB-

IH

-LRB-

g

-RRB-

for

every

pair

of

distinct

symbols

f

and

g

in

S

that

correspond

to

function

symbols

-LRB-

of

arity

-RRB-

or

predicate

symbols

of

LP

We

can

now

define

PtoH

-LRB-

MP

-RRB-

MH

U

Utrue

IH

F

where

ffl

the

universe

U

of

MH

is

the

same

as

that

of

MP

ffl

the

mapping

IH

from

the

parameters

S

of

LH

to

U

is

the

one

defined

in

the

previous

paragraph

and

ffl

F

is

defined

thus

-LCB-

If

f

S

corresponds

to

a

k-ary

function

symbol

of

LP

where

k

then

-LRB-

IH

-LRB-

f

-RRB-

-RRB-

-LRB-

k

-RRB-

F

-LRB-

uk

-RRB-

IP

-LRB-

f

-RRB-

-LRB-

uk

-RRB-

for

other

arities

r

-LRB-

r

k

-RRB-

-LRB-

IH

-LRB-

f

-RRB-

-RRB-

-LRB-

r

-RRB-

F

is

defined

arbitrarily

is

important

for

the

following

construction

that

the

HiLog

interpreted

parameters

such

as

true

and

false

are

never

used

as

function

symbols

in

the

PC

language

LP

-LCB-

If

p

S

is

an

m-ary

predicate

symbol

where

m

then

-LRB-

IH

-LRB-

p

-RRB-

-RRB-

-LRB-

m

-RRB-

F

-LRB-

um

-RRB-

is

in

Utrue

if

and

only

if

-LRB-

um

-RRB-

IP

-LRB-

p

-RRB-

there

are

no

other

requirements

to

the

definition

of

-LRB-

IH

-LRB-

p

-RRB-

-RRB-

-LRB-

m

-RRB-

F

Neither

are

there

any

requirements

to

-LRB-

IH

-LRB-

p

-RRB-

-RRB-

-LRB-

s

-RRB-

F

for

other

arities

s

where

s

m.

-LCB-

On

other

elements

of

U

F

is

defined

in

an

arbitrary

way

Since

IH

maps

distinct

function

and

predicate

symbols

of

S

into

different

elements

of

U

the

mappings

-LRB-

IH

-LRB-

f

-RRB-

-RRB-

-LRB-

k

-RRB-

F

and

-LRB-

IH

-LRB-

p

-RRB-

-RRB-

-LRB-

m

-RRB-

F

are

well-defined

Let

be

a

variable

assignment

Since

LH

and

LP

share

the

same

set

of

variables

and

PtoH

-LRB-

MP

-RRB-

shares

the

domain

U

with

MP

is

a

variable

assignment

for

both

PtoH

-LRB-

MP

-RRB-

and

MP

Let

H

and

P

denote

the

extensions

of

to

the

set

of

all

terms

in

LH

and

LP

respectively

The

following

properties

can

be

proved

by

induction

ffl

for

any

term

t

of

LP

in

PC

-LRB-

which

is

also

a

term

in

LH

-RRB-

H

-LRB-

t

-RRB-

P

-LRB-

t

-RRB-

ffl

for

any

formula

OE

of

LP

in

PC

-LRB-

which

is

also

a

formula

in

LH

-RRB-

PtoH

-LRB-

MP

-RRB-

j

hilog

OE

if

and

only

if

MP

j

pc

OE

Therefore

if

OE

is

valid

in

HiLog

OE

is

valid

in

all

semantic

structures

MP

such

that

the

cardinality

of

the

domain

of

MP

is

at

least

that

of

S

If

OE

is

also

cardinal

this

implies

that

OE

is

true

in

all

semantic

structures

of

predicate

calculus

Encoding

HiLog

in

Predicate

Calculus

Since

HiLog

syntax

is

richer

than

that

of

predicate

calculus

it

may

seem

that

HiLog

is

a

more

expressive

logic

It

turns

out

however

that

every

HiLog

formula

can

be

encoded

in

predicate

calculus

and

therefore

these

two

logics

are

equally

expressive

It

should

be

borne

in

mind

though

that

our

objective

is

not

to

devise

a

more

expressive

logic

but

a

logic

whose

syntax

is

more

suitable

for

logic

programming

In

this

respect

one

can

compare

programming

in

HiLog

vs.

Prolog

to

programming

in

Prolog

vs.

Horn

logic

It

is

well-known

that

Horn

logic

has

the

computational

power

of

a

Turing

machine

and

therefore

is

sufficient

for

all

computational

needs

However

programmer

's

convenience

and

the

need

to

simplify

problem

specification

calls

for

a

richer

syntax

-LRB-

negation

etc.

-RRB-

and

this

is

why

Prolog

has

the

additional

constructs

it

is

notorious

for

More

discussion

of

this

issue

appears

in

Section

The

following

encoding

of

HiLog

in

predicate

calculus

was

suggested

by

James

Wu

-LSB-

-RSB-

Given

a

HiLog

language

LH

with

a

set

of

variables

V

and

parameters

S

we

define

Lencode

P

to

be

a

language

of

predicate

calculus

with

the

set

of

variables

V

constant

symbols

S

a

unique

predicate

symbol

call

and

for

each

n

an

-LRB-

n

-RRB-

ary

function

symbol

applyn

Given

a

HiLog

formula

OE

its

encoding

in

predicate

calculus

OE

is

determined

by

the

following

recursive

transformation

rules

In

these

rules

encodea

is

a

transformation

that

encodes

HiLog

terms

that

appear

in

contexts

where

they

are

interpreted

as

atomic

formulas

and

encodet

encodes

these

terms

in

all

other

contexts

ffl

encodet

-LRB-

X

-RRB-

X

for

each

variable

X

V

ffl

encodet

-LRB-

s

-RRB-

s

for

each

logic

symbol

s

S

ffl

encodet

-LRB-

t

-LRB-

tn

-RRB-

-RRB-

applyn

-LRB-

encodet

-LRB-

t

-RRB-

encodet

-LRB-

-RRB-

encodet

-LRB-

tn

-RRB-

-RRB-

ffl

encodea

-LRB-

A

-RRB-

call

-LRB-

encodet

-LRB-

A

-RRB-

-RRB-

where

A

is

a

HiLog

atomic

formula

ffl

encodea

-LRB-

A

B

-RRB-

encodea

-LRB-

A

-RRB-

encodea

-LRB-

B

-RRB-

ffl

encodea

-LRB-

A

B

-RRB-

encodea

-LRB-

A

-RRB-

encodea

-LRB-

B

-RRB-

ffl

encodea

-LRB-

A

-RRB-

encodea

-LRB-

A

-RRB-

ffl

encodea

-LRB-

-LRB-

QX

-RRB-

A

-RRB-

-LRB-

QX

-RRB-

encodea

-LRB-

A

-RRB-

where

Q

is

either

or

Given

a

HiLog

semantic

structure

M

U

Utrue

IH

F

the

corresponding

predicate

calculus

structure

encode

-LRB-

M

-RRB-

U

IP

is

defined

as

follows

ffl

IP

-LRB-

c

-RRB-

IH

-LRB-

c

-RRB-

for

each

c

S

ffl

IP

-LRB-

applyn

-RRB-

-LRB-

u

un

-RRB-

-LRB-

u

-RRB-

-LRB-

n

-RRB-

F

-LRB-

un

-RRB-

ffl

IP

-LRB-

call

-RRB-

Utrue

ffl

The

equality

predicate

has

the

standard

interpretation

in

encode

-LRB-

M

-RRB-

-LRB-

i.e.

IP

-LRB-

=-RRB-

def

f

u

u

j

u

Ug

-RRB-

The

following

result

and

its

proof

is

due

to

James

Wu

-LSB-

-RSB-

The

reason

for

the

special

treatment

of

in

the

above

definitions

will

become

apparent

in

Section

Theorem

-LRB-

Encoding

Theorem

-RRB-

Let

OE

be

a

HiLog

formula

and

M

a

semantic

structure

Let

be

a

variable

assignment

for

the

free

variables

in

OE

Then

M

j

OE

if

and

only

if

encode

-LRB-

M

-RRB-

j

encodea

-LRB-

OE

-RRB-

Proof

By

structural

induction

-LRB-

t

-RRB-

-LRB-

encodet

-LRB-

t

-RRB-

-RRB-

for

every

HiLog

term

t.

Consider

now

a

HiLog

atomic

formula

A

other

than

an

equation

By

the

definition

encodea

-LRB-

A

-RRB-

call

-LRB-

encodet

-LRB-

A

-RRB-

-RRB-

Therefore

M

j

A

if

and

only

if

-LRB-

A

-RRB-

Utrue

if

and

only

if

-LRB-

encodet

-LRB-

A

-RRB-

-RRB-

IP

-LRB-

call

-RRB-

if

and

only

if

encode

-LRB-

M

-RRB-

j

call

-LRB-

encodet

-LRB-

A

-RRB-

-RRB-

if

and

only

if

encode

-LRB-

M

-RRB-

j

encodea

-LRB-

A

-RRB-

The

above

derivation

holds

for

the

equality

predicate

as

well

because

of

the

special

interpretation

assigned

to

in

Section

We

have

thus

proved

the

claim

for

atomic

formulas

The

rest

of

the

proof

is

an

easy

induction

on

the

structure

of

HiLog

formulas

Let

denote

the

following

sentence

-LRB-

Y

-RRB-

call

-LRB-

-LRB-

X

Y

-RRB-

-RRB-

X

Y

Then

we

have

the

following

corollary

that

relates

validity

of

a

formula

in

HiLog

and

of

its

encoding

in

PC

Corollary

Let

OE

be

a

HiLog

formula

Then

OE

is

valid

if

and

only

if

oe

encodea

-LRB-

OE

-RRB-

is

valid

in

predicate

calculus

Proof

Let

LH

be

a

HiLog

language

It

is

easy

to

see

that

the

function

encode

is

a

and

onto

mapping

from

HiLog

semantic

structures

of

LH

to

PC

semantic

structures

of

Lencode

P

that

satisfy

the

aforesaid

formula

-LRB-

the

language

Lencode

P

was

defined

earlier

before

the

definition

of

the

encoding

of

HiLog

in

PC

-RRB-

Indeed

we

could

use

equations

for

encode

in

reverse

to

define

a

function

decode

such

that

decode

-LRB-

encode

-LRB-

M

-RRB-

-RRB-

M

The

claim

now

follows

from

Theorem

We

conclude

this

section

with

a

few

remarks

that

shed

some

light

on

the

relationship

between

HiLog

and

the

second-order

predicate

calculus

under

the

standard

semantics

-LSB-

-RSB-

Clearly

one

should

expect

certain

similarities

because

for

example

quantification

over

predicates

and

function

symbols

is

allowed

in

both

logics

On

the

other

hand

the

first-order

nature

of

HiLog

semantics

suggests

that

there

must

be

very

significant

differences

For

a

similarity

it

is

easy

to

see

that

the

language

of

HiLog

is

rich

enough

to

express

so

called

extensionality

axioms

For

instance

for

arity

we

can

write

-LRB-

-LRB-

P

Q

-RRB-

-LRB-

P

-LRB-

X

Y

-RRB-

Q

-LRB-

X

Y

-RRB-

-RRB-

-RRB-

-LRB-

-RRB-

According

to

-LRB-

-RRB-

-LRB-

P

Q

-RRB-

is

true

if

and

only

if

P

and

Q

are

the

same

when

viewed

as

binary

predicates

This

formula

is

identical

to

the

extensionality

axiom

for

binary

predicates

in

second-order

logic

with

the

standard

higher-order

semantics

Thus

HiLog

syntax

appears

to

be

rich

enough

to

capture

both

the

intensional

and

extensional

aspects

of

functions

and

predicates

However

a

critical

difference

between

the

semantics

of

HiLog

and

the

standard

semantics

for

secondorder

logic

is

the

domain

of

variables

In

HiLog

variables

range

over

a

nonempty

set

of

intensions

So

in

-LRB-

-RRB-

P

and

Q

range

only

over

the

intensions

of

binary

relations

but

there

also

may

be

relations

without

the

corresponding

intensions

-LRB-

the

latter

do

not

affect

the

meaning

of

-LRB-

-RRB-

in

HiLog

-RRB-

In

contrast

in

the

standard

second-order

semantics

the

domain

of

predicate

variables

P

and

Q

is

the

set

of

all

binary

relations

over

the

individual

domain

Therefore

the

extensionality

axiom

of

standard

secondorder

logic

talks

about

all

possible

relations

Although

this

distinction

does

not

appear

to

have

impact

on

the

meaning

of

-LRB-

-RRB-

in

HiLog

vs.

second-order

PC

it

does

make

a

difference

for

the

so

called

relation

comprehension

formulas

-LSB-

-RSB-

-LRB-

P

-LRB-

Xn

-RRB-

OE

-RRB-

-LRB-

-RRB-

where

OE

is

some

formula

in

which

P

does

not

occur

free

and

the

only

free

variables

are

Xn

It

is

well-known

that

these

formulas

are

valid

in

the

standard

second-order

predicate

calculus

It

turns

out

however

that

they

are

not

valid

in

HiLog

For

instance

the

formula

-LRB-

P

-LRB-

X

Y

-RRB-

:p

-LRB-

X

Y

-RRB-

-RRB-

-LRB-

-RRB-

is

not

valid

in

HiLog

One

HiLog

semantic

structure

which

falsifies

it

is

fdg

fdg

I

F

where

I

-LRB-

p

-RRB-

d

and

d

-LRB-

k

-RRB-

F

-LRB-

d

d

-RRB-

d

for

all

k

-LRB-

k

-RRB-

Intuitively

this

happens

because

domains

of

HiLog

interpretations

do

not

necessarily

have

intensions

for

complements

of

relations

associated

with

predicate

names

Whether

this

effect

is

desirable

or

not

depends

on

the

intended

meaning

of

quantification

In

HiLog

the

quantification

is

over

intensions

and

since

there

is

no

name

for

:p

in

T

-LRB-

-RRB-

is

not

valid

Applications

of

HiLog

As

explained

earlier

although

the

semantics

of

HiLog

is

first-order

a

term

can

be

viewed

as

an

individual

a

function

or

a

predicate

depending

on

the

context

in

which

it

appears

When

functions

or

predicates

are

treated

as

objects

they

are

manipulated

as

terms

through

their

intensions

when

applied

to

arguments

they

are

evaluated

as

functions

or

relations

through

their

extensions

By

distinguishing

between

intensional

and

extensional

aspects

of

functions

and

predicates

HiLog

preserves

the

advantages

of

higher-order

logic

and

avoids

the

computational

difficulties

with

extensions

introduced

by

higher-order

semantics

In

this

section

we

review

a

subset

of

HiLog

that

is

suitable

for

logic

programming

and

then

show

its

uses

in

higher-order

logic

programming

definite

clause

grammars

in

natural

language

processing

and

other

areas

Logic

Programming

in

HiLog

For

practical

applications

we

consider

logic

programming

instead

of

general

theorem

proving

with

HiLog

By

a

logic

program

we

mean

a

finite

set

of

formulas

of

the

form

Xn

-LRB-

A

Lm

-RRB-

where

m

A

is

an

atomic

formula

Lm

are

literals

and

Xn

are

all

the

variables

occurring

in

A

Lm

-LSB-

-RSB-

Each

universal

formula

in

a

program

can

be

written

as

a

general

clause

However

in

logic

programming

such

clauses

are

often

written

as

A

Lm

If

Lm

are

atomic

formulas

such

clauses

are

called

definite

Horn

clauses

and

a

logic

program

consisting

of

only

definite

clauses

is

called

a

definite

logic

program

For

definite

logic

programs

standard

logic

programming

techniques

-LSB-

-RSB-

can

be

used

to

define

the

declarative

and

procedural

semantics

The

only

difference

is

the

form

of

atomic

formulas

and

unification

-LRB-

unification

is

discussed

in

Section

-RRB-

For

instance

for

definite

HiLog

programs

the

model

intersection

property

holds

and

therefore

each

such

program

has

a

unique

minimal

-LRB-

with

respect

to

set

inclusion

-RRB-

Herbrand

model

The

TP

operator

is

also

defined

as

usual

If

H

is

a

Herbrand

interpretation

and

P

is

a

definite

program

TP

-LRB-

H

-RRB-

is

the

set

of

all

literals

that

are

heads

of

ground

clauses

of

P

whose

body

is

satisfied

in

H

The

standard

results

about

fixpoint

also

hold

These

facts

are

easy

to

verify

directly

or

with

the

use

of

Theorem

For

logic

programs

with

negation

semantics

is

defined

by

choosing

one

or

several

of

the

minimal

Herbrand

models

For

instance

the

definitions

of

well

founded

semantics

-LSB-

-RSB-

and

stable

model

semantics

-LSB-

-RSB-

are

independent

of

the

notions

of

atomic

formulas

and

Herbrand

bases

and

thus

the

same

definitions

can

be

applied

to

HiLog

Some

results

on

negation

in

HiLog

can

be

found

in

-LSB-

-RSB-

Higher-Order

and

Modular

Logic

Programming

Higher-order

constructs

have

been

found

very

useful

in

programming

practice

An

example

is

the

maplist

of

Lisp

It

can

be

defined

in

HiLog

either

as

a

higher-order

predicate

maplist

-LRB-

F

-LSB-

-RSB-

-LSB-

-RSB-

-RRB-

maplist

-LRB-

F

-LSB-

XjR

-RSB-

-LSB-

YjZ

-RSB-

-RRB-

F

-LRB-

X

Y

-RRB-

maplist

-LRB-

F

R

Z

-RRB-

or

as

a

generic

predicate

maplist

-LRB-

F

-RRB-

-LRB-

-LSB-

-RSB-

-LSB-

-RSB-

-RRB-

maplist

-LRB-

F

-RRB-

-LRB-

-LSB-

XjR

-RSB-

-LSB-

YjZ

-RSB-

-RRB-

F

-LRB-

X

Y

-RRB-

maplist

-LRB-

F

-RRB-

-LRB-

R

Z

-RRB-

The

latter

is

possible

since

HiLog

allows

complex

terms

such

as

maplist

-LRB-

F

-RRB-

to

appear

as

predicates

The

example

in

Section

shows

the

usefulness

of

generic

view

definitions

such

as

closure

in

databases

Generic

transitive

closure

can

also

be

defined

in

Prolog

closure

-LRB-

R

X

Y

-RRB-

C

-LSB-

R

X

Y

-RSB-

call

-LRB-

C

-RRB-

closure

-LRB-

R

X

Y

-RRB-

C

-LSB-

R

X

Z

-RSB-

call

-LRB-

C

-RRB-

closure

-LRB-

R

Z

Y

-RRB-

However

this

is

obviously

inelegant

compared

to

HiLog

-LRB-

see

Section

-RRB-

since

this

involves

both

constructing

a

term

out

of

a

list

and

reflecting

this

term

into

an

atomic

formula

using

call

The

point

of

this

example

is

that

the

lack

of

theoretical

foundations

for

higher-order

constructs

in

Prolog

resulted

in

an

obscure

syntax

which

partially

explains

why

Prolog

programs

involving

those

constructs

are

notoriously

hard

to

understand

It

turns

out

that

since

variables

may

be

instantiated

to

HiLog

terms

which

in

turn

have

propositional

meaning

there

is

no

need

for

the

infamous

call

predicate

that

is

built

into

Prolog

The

latter

is

naturally

defined

in

HiLog

as

call

-LRB-

X

-RRB-

X.

which

has

the

intended

semantics

Higher-order

constructs

have

been

also

used

in

database

languages

such

as

COL

-LSB-

-RSB-

and

LDL

-LSB-

-RSB-

for

modeling

complex

objects

containing

sets

The

original

semantics

of

these

languages

as

described

in

-LSB-

-RSB-

is

higher-order

which

leads

to

certain

semantic

and

computational

difficulties

In

Section

we

propose

an

alternative

semantics

for

COL

and

LDL

using

HiLog

and

argue

that

the

latter

is

computationally

more

tractable

and

practically

more

convenient

Modular

logic

programming

is

another

application

where

higher-order

logic

can

be

employed

In

-LSB-

-RSB-

a

theory

of

modules

is

developed

based

upon

standard

second-order

logic

The

semantics

of

a

module

is

a

second-order

relation

over

first-order

predicates

interpreted

as

first-order

relations

The

relational

view

of

modules

is

a

natural

extension

of

logic

programming

However

standard

second-order

logic

is

not

recursively

axiomatizable

and

practical

usage

of

modules

does

not

need

the

full

power

of

second-order

predicate

calculus

HiLog

can

be

used

to

provide

a

simple

alternative

semantics

for

modular

logic

programming

which

unlike

-LSB-

-RSB-

has

a

sound

and

complete

proof

theory

Consider

the

following

program

fragment

-LRB-

which

is

well-formed

both

in

predicate

calculus

and

in

HiLog

-RRB-

trans

-LRB-

X

Y

-RRB-

edge

-LRB-

X

Y

-RRB-

trans

-LRB-

X

Y

-RRB-

edge

-LRB-

X

Z

-RRB-

trans

-LRB-

Z

Y

-RRB-

To

turn

it

into

a

module

definition

we

need

to

determine

its

interface

with

other

modules

This

program

fragment

contains

a

definition

for

trans

in

terms

of

edge

Suppose

that

predicate

trans

is

exported

and

predicate

edge

is

a

parameter

which

can

be

instantiated

to

any

binary

predicate

of

the

user

's

choice

To

obtain

a

module

definition

we

replace

each

non-global

predicate

symbol

by

a

predicate

variable

of

the

same

arity

where

different

predicate

names

are

replaced

by

distinct

variables

This

is

done

to

ensure

the

local

scope

of

those

symbols

since

only

variables

have

local

scopes

in

logic

In

the

concrete

syntax

of

-LSB-

-RSB-

the

module

definition

for

transitive

closure

may

look

like

this

mod

trans

-LRB-

In

Out

-RRB-

f

Out

-LRB-

X

Y

-RRB-

In

-LRB-

X

Y

-RRB-

Out

-LRB-

X

Y

-RRB-

In

-LRB-

X

Z

-RRB-

Out

-LRB-

Z

Y

-RRB-

g

The

head

of

a

module

definition

defines

module

interface

It

consists

of

exported

predicate

parameters

-LRB-

like

Out

-RRB-

and

input

predicate

parameters

-LRB-

like

In

-RRB-

the

body

of

a

module

definition

is

the

implementation

of

the

module

Individual

variables

are

still

universally

quantified

with

respect

to

each

clause

in

the

body

-LRB-

unless

they

are

also

module

interface

parameters

which

is

discussed

in

-LSB-

-RSB-

-RRB-

Non-interface

predicate

variables

in

the

body

if

any

represent

private

predicates

that

are

not

to

be

seen

outside

the

module

The

quantification

of

predicate

variables

is

such

that

all

input

predicate

parameters

are

universally

quantified

and

all

other

predicates

-LRB-

private

and

exported

ones

-RRB-

are

existentially

quantified

inside

the

scope

of

the

universal

quantification

of

the

input

predicate

variables

It

is

precisely

due

to

this

existential

quantification

of

predicate

variables

why

the

local

data

in

the

module

is

shielded

from

outside

The

above

module

definition

not

only

defines

first-order

predicates

in

the

body

of

the

module

but

also

the

second-order

predicate

corresponding

to

the

module

name

namely

mod

trans

The

above

module

definition

can

be

given

meaning

via

the

following

formula

-LRB-

mod

trans

-LRB-

In

Out

-RRB-

-LRB-

Out

-LRB-

X

Y

-RRB-

In

-LRB-

X

Y

-RRB-

-RRB-

-LRB-

Out

-LRB-

X

Y

-RRB-

In

-LRB-

X

Z

-RRB-

Out

-LRB-

Z

Y

-RRB-

-RRB-

-RRB-

Under

the

second-order

semantics

of

-LSB-

-RSB-

mod

trans

is

treated

as

a

second-order

predicate

symbol

Instead

of

interpreting

the

above

formula

under

the

standard

second-order

logic

we

can

interpret

it

as

a

formula

in

HiLog

getting

a

more

tractable

semantics

for

modules

Under

the

HiLog

interpretation

mod

trans

is

simply

a

first-order

parameter

symbol

just

like

link

In

an

implementation

existential

variables

can

be

eliminated

by

Skolemization

which

preserves

unsatisfiability

in

refutational

theorem

proving

-LRB-

e.g.

SLD-resolution

-RRB-

After

a

module

is

defined

it

can

be

used

just

as

any

other

predicate

except

that

it

may

also

take

predicates

as

arguments

Consider

the

query

link

-LRB-

a

b

-RRB-

link

-LRB-

b

d

-RRB-

link

-LRB-

d

e

-RRB-

link

-LRB-

a

c

-RRB-

mod

trans

-LRB-

link

Closure

-RRB-

Closure

-LRB-

a

X

-RRB-

where

Closure

is

a

predicate

variable

and

X

is

an

individual

variable

Under

the

second-order

semantics

Closure

will

be

bound

to

a

relation

corresponding

to

the

transitive

closure

of

the

link

predicate

Therefore

X

can

be

bound

to

any

node

reachable

from

a

and

the

answer

to

this

query

will

be

the

set

of

all

such

nodes

Under

the

HiLog

semantics

Closure

will

be

bound

to

an

intension

c

in

the

domain

of

quantification

rather

than

to

a

relation

Nevertheless

the

binary

relation

associated

to

c

by

HiLog

semantics

-LRB-

that

is

-LRB-

c

-LRB-

-RRB-

F

-RRB-

-LRB-

Utrue

-RRB-

-RRB-

will

be

the

same

as

under

the

second-order

semantics

the

transitive

closure

of

link

Therefore

once

again

X

can

be

bound

to

any

node

reachable

from

a

and

the

set

of

answers

to

the

above

query

will

be

the

same

as

before

The

HiLog

semantics

for

modules

yields

the

same

result

as

-LSB-

-RSB-

in

most

cases

but

disagrees

with

-LSB-

-RSB-

in

marginal

situations

when

the

inherent

difference

between

the

intensional

treatment

of

predicates

in

HiLog

and

the

extensional

treatment

in

-LSB-

-RSB-

becomes

essential

For

instance

when

two

different

predicates

p

and

q

that

are

extensionally

equivalent

are

to

be

unified

they

are

unifiable

in

the

standard

second-order

semantics

but

not

in

HiLog

Another

difference

is

that

HiLog

modules

have

features

not

found

in

-LSB-

-RSB-

For

instance

modules

in

-LSB-

-RSB-

being

second-order

predicates

can

not

be

imported

into

other

modules

since

second-order

predicates

can

not

be

arguments

to

other

second-order

predicates

Therefore

manipulating

modules

requires

more

than

just

a

second-order

PC

In

contrast

there

are

no

such

difficulties

in

HiLog

and

module

names

being

merely

first-order

terms

in

HiLog

can

be

passed

to

other

modules

as

parameters

Definite

Clause

Grammars

in

HiLog

Definite

clause

grammars

-LRB-

DCGs

-RRB-

developed

for

processing

natural

language

-LSB-

-RSB-

extend

the

contextfree

grammars

by

adding

arguments

for

checking

the

agreement

among

linguistic

structures

and

by

allowing

arbitrary

computation

in

the

body

of

a

rule

They

can

be

translated

into

Prolog

by

adding

an

additional

pair

of

arguments

for

representing

the

string

of

words

being

parsed

As

an

example

consider

the

following

DCG

rules

s

-LRB-

sent

-LRB-

Subj

Verb

-RRB-

-RRB-

np

-LRB-

Subj

Num

-RRB-

vp

-LRB-

Verb

Num

-RRB-

np

-LRB-

Word

Num

-RRB-

-LSB-

Word

-RSB-

fisproper

name

-LRB-

Word

Num

-RRB-

g.

vp

-LRB-

Word

Num

-RRB-

-LSB-

Word

-RSB-

fisverb

-LRB-

Word

Num

-RRB-

g

The

standard

transformation

yields

the

following

Prolog

program

s

-LRB-

sent

-LRB-

Subj

Verb

-RRB-

L

-RRB-

np

-LRB-

Subj

Num

-RRB-

vp

-LRB-

Verb

Num

L

-RRB-

np

-LRB-

Word

Num

L

-RRB-

connect

-LRB-

Word

L

-RRB-

isproper

name

-LRB-

Word

Num

-RRB-

vp

-LRB-

Word

Num

L

-RRB-

connect

-LRB-

Word

L

-RRB-

isverb

-LRB-

Word

Num

-RRB-

connect

-LRB-

Word

-LSB-

WordjL

-RSB-

L

-RRB-

Suppose

we

have

the

following

facts

isproper

name

-LRB-

john

singular

-RRB-

isverb

-LRB-

walks

singular

-RRB-

Then

parsing

a

natural

language

sentence

such

as

john

walks

will

be

reduced

to

evaluating

a

logical

query

s

-LRB-

X

-LSB-

john

walks

-RSB-

-LSB-

-RSB-

-RRB-

Although

Prolog

is

adequate

for

many

languages

defined

by

DCG

grammars

there

are

cases

in

which

generic

grammatical

rules

become

necessary

Optionality

of

a

nonterminal

symbol

and

the

occurrence

of

an

arbitrary

symbol

zero

or

more

times

are

some

of

the

examples

-LSB-

-RSB-

Such

rules

can

be

specified

as

follows

-LRB-

adapted

from

-LSB-

-RSB-

-RRB-

option

-LRB-

X

-RRB-

X.

option

-LRB-

X

-RRB-

-LSB-

-RSB-

seq

-LRB-

X

-RRB-

X

seq

-LRB-

X

-RRB-

seq

-LRB-

X

-RRB-

-LSB-

-RSB-

nonempty

seq

-LRB-

X

-RRB-

X

seq

-LRB-

X

-RRB-

Unfortunately

the

above

translation

into

Prolog

no

longer

works

since

Prolog

does

not

allow

variable

predicates

Indeed

blindly

following

this

recipe

we

would

get

nonempty

seq

-LRB-

X

-RRB-

-LRB-

L

-RRB-

X

-LRB-

-RRB-

seq

-LRB-

X

-RRB-

-LRB-

L

-RRB-

which

is

a

HiLog

but

not

a

Prolog

rule

To

overcome

this

problem

we

could

try

to

turn

X

-LRB-

L

-RRB-

into

something

like

NewX

-LSB-

X

L

-RSB-

call

-LRB-

NewX

-RRB-

However

even

this

patch

does

not

work

all

the

time

Because

of

the

syntactic

limitations

of

Prolog

special

mechanisms

for

translating

such

grammars

into

Prolog

are

needed

and

papers

have

been

written

on

that

subject

-LRB-

e.g.

-LSB-

-RSB-

-RRB-

In

contrast

as

we

have

just

seen

translation

of

generic

grammars

into

HiLog

is

immediate

and

does

not

require

any

special

machinery

we

simply

go

on

-LRB-

as

suggested

by

the

standard

algorithm

-RRB-

and

replace

each

nonterminal

N

by

a

HiLog

atom

N

-LRB-

-RRB-

Regardless

of

whether

N

is

a

predicate

symbol

a

function

symbol

a

variable

or

a

term

HiLog

accommodates

them

all

due

to

the

richness

of

its

syntax

As

a

matter

of

fact

even

the

original

DCG-to-Prolog

translation

could

be

made

more

natural

in

HiLog

DCG

nonterminals

with

parameters

are

readily

transformed

into

parameterized

predicates

in

HiLog

For

example

the

first

DCG

rule

above

s

-LRB-

sent

-LRB-

Subj

Verb

L

-RRB-

-RRB-

np

-LRB-

Subj

Num

-RRB-

vp

-LRB-

Verb

Num

L

-RRB-

would

become

s

-LRB-

sent

-LRB-

Subj

Verb

-RRB-

-RRB-

-LRB-

L

-RRB-

np

-LRB-

Subj

Num

-RRB-

-LRB-

-RRB-

vp

-LRB-

Verb

Num

-RRB-

-LRB-

L

-RRB-

Query

Evaluator

Consider

relational

expressions

composed

from

say

binary

relations

connected

by

the

relational

operators

minus

union

and

the

like

Suppose

that

the

parser

has

already

produced

a

parse

tree

-LRB-

parsing

is

easy

using

Horn

clauses

-RRB-

of

the

expression

in

the

form

of

a

term

say

minus

-LRB-

union

-LRB-

p

q

-RRB-

inter

-LRB-

q

r

-RRB-

-RRB-

or

similar

As

the

next

step

we

would

like

to

write

an

evaluator

for

such

expressions

which

in

HiLog

looks

as

follows

minus

-LRB-

P

Q

-RRB-

-LRB-

X

Y

-RRB-

P

-LRB-

X

Y

-RRB-

Q

-LRB-

X

Y

-RRB-

union

-LRB-

P

Q

-RRB-

-LRB-

X

Y

-RRB-

P

-LRB-

X

Y

-RRB-

union

-LRB-

P

Q

-RRB-

-LRB-

X

Y

-RRB-

Q

-LRB-

X

Y

-RRB-

For

comparison

we

present

an

analogue

of

the

above

program

in

Prolog

The

simplest

approach

to

this

problem

seems

to

be

to

define

a

translation

predicate

tr

that

converts

parse

trees

into

Prolog

goals

and

then

use

call

The

rules

for

tr

are

as

follows

tr

-LRB-

minus

-LRB-

P

Q

-RRB-

X

Y

-LRB-

not

-LRB-

-RRB-

-RRB-

-RRB-

tr

-LRB-

P

X

Y

-RRB-

tr

-LRB-

Q

X

Y

-RRB-

tr

-LRB-

union

-LRB-

P

Q

-RRB-

X

Y

-LRB-

-RRB-

-RRB-

tr

-LRB-

P

X

Y

-RRB-

tr

-LRB-

Q

X

Y

-RRB-

tr

-LRB-

P

X

Y

Atom

-RRB-

Atom

-LSB-

P

X

Y

-RSB-

The

first

observation

about

this

Prolog

program

is

that

it

is

clumsy

compared

to

its

HiLog

counterpart

-LRB-

notice

that

the

arguments

X

Y

in

tr

are

essential

for

the

program

to

run

correctly

-RRB-

Second

the

last

rule

is

intended

to

capture

the

situation

where

P

is

instantiated

to

a

predicate

symbol

However

this

restriction

is

only

implicit

in

the

built-in

predicate

which

will

give

an

error

if

P

is

not

a

predicate

symbol

One

way

to

get

around

this

is

to

list

all

the

facts

such

as

tr

-LRB-

p

X

Y

p

-LRB-

X

Y

-RRB-

-RRB-

-LRB-

for

each

predicate

symbol

-RRB-

in

advance

However

this

is

particularly

inconvenient

in

the

database

environment

when

the

user

may

create

or

delete

new

relations

since

the

above

program

would

have

to

be

updated

each

time

The

ease

of

writing

the

above

program

in

HiLog

stems

from

the

ability

to

represent

intermediate

results

of

query

evaluation

in

a

natural

way

For

instance

minus

-LRB-

p

q

-RRB-

can

be

viewed

as

the

name

of

an

intermediate

relation

for

the

result

of

subtracting

Q

from

P

However

it

should

be

clear

that

in

order

to

take

full

advantage

of

HiLog

arities

of

all

relations

must

be

known

at

compile

time

since

we

must

know

how

many

variables

should

appear

in

various

places

in

rules

Therefore

rules

for

the

relational

operators

that

do

not

change

the

arities

of

relations

-LRB-

like

the

ones

above

-RRB-

look

particularly

attractive

in

HiLog

On

the

other

hand

operators

such

as

join

or

Cartesian

product

require

a

heavier

machinery

such

as

functor

and

arg

Still

this

program

would

be

much

more

elegant

in

HiLog

than

in

Prolog

Type

Checking

Recently

ThomFruehwirth

has

pointed

out

to

us

that

the

monomorphic

type

checking

system

of

-LSB-

-RSB-

can

be

naturally

extended

to

a

polymorphic

type

checking

system

for

HiLog

-LSB-

-RSB-

while

expressing

general

polymorphism

in

predicate

calculus

is

usually

quite

cumbersome

The

use

of

HiLog

as

a

language

for

type

specification

is

further

explored

in

-LSB-

-RSB-

HiLog

as

a

Database

Programming

Language

In

this

section

we

show

that

HiLog

provides

an

alternative

-LRB-

first-order

-RRB-

semantics

to

some

of

the

wellknown

database

languages

with

higher-order

semantics

thereby

eliminating

some

of

their

problems

Specifically

we

will

focus

on

COL

-LSB-

-RSB-

and

LDL

-LSB-

-RSB-

After

that

we

will

discuss

various

applications

of

HiLog

to

object-oriented

databases

COL

-LSB-

-RSB-

is

a

logic-based

language

for

complex

objects

One

notable

feature

of

COL

is

that

in

addition

to

finite

set

construction

it

also

provides

so

called

data

functions

These

functions

may

take

sets

and

individuals

as

arguments

and

return

sets

as

results

Data

functions

can

be

defined

by

either

facts

or

rules

For

example

some

of

the

operations

over

sets

can

be

defined

as

data

functions

as

follows

-LSB-

-RSB-

X

intersection

-LRB-

-RRB-

X

X

X

union

-LRB-

-RRB-

X

X

union

-LRB-

-RRB-

X

X

difference

-LRB-

-RRB-

X

not

-LRB-

X

-RRB-

Notice

that

variables

range

over

a

domain

of

sets

and

thus

according

to

our

classification

the

semantics

of

COL

is

higher-order

This

higher-orderness

presents

certain

semantic

problems

for

logic

programs

in

COL.

Consider

the

following

example

adapted

from

-LSB-

-RSB-

person

-LRB-

peter

fbridgeg

-RRB-

person

-LRB-

thom

fchess

tennisg

-RRB-

person

-LRB-

thom

hobby

-LRB-

peter

-RRB-

-RRB-

Y

hobby

-LRB-

X

-RRB-

person

-LRB-

X

Z

-RRB-

Y

Z

This

program

is

unstratified

in

COL

since

hobby

and

person

mutually

depend

on

each

other

and

therefore

the

following

perfectly

legal

queries

that

request

all

Tom

's

hobbies

and

inquire

whether

Tom

plays

bridge

will

be

rejected

X

hobby

-LRB-

thom

-RRB-

person

-LRB-

thom

f

chess

tennis

g

-RRB-

To

cope

with

this

problem

-LSB-

-RSB-

proposes

to

use

an

analogue

of

the

notion

of

local

stratification

adapted

from

logic

programming

-LSB-

-RSB-

For

simplicity

we

restrict

our

attention

to

COL

programs

without

tuple

constructs

and

such

that

their

finite

set-constructs

have

no

variables

Thus

the

forms

such

as

f

a

b

g

are

allowed

but

f

a

b

X

g

are

not

Later

we

will

show

how

to

extend

our

results

to

the

general

case

Now

the

restricted

COL

programs

can

be

transformed

into

HiLog

programs

as

follows

Replace

every

finite

set

construction

ang

that

appears

in

the

COL

program

by

a

new

HiLog

logical

symbol

sym

and

add

the

following

facts

to

the

program

sym

-LRB-

-RRB-

sym

-LRB-

an

-RRB-

Identical

finite

set

constructions

must

be

consistently

replaced

by

the

same

symbol

For

instance

person

-LRB-

thom

fchess

tennisg

-RRB-

will

be

replaced

by

person

-LRB-

thom

hobby

thom

-RRB-

and

the

following

pair

of

facts

hobby

thom

-LRB-

chess

-RRB-

hobby

thom

-LRB-

tennis

-RRB-

Replace

COL-formulas

of

the

form

X

f

-LRB-

:-RRB-

by

HiLog

formulas

f

-LRB-

-RRB-

-LRB-

X

-RRB-

Then

the

above

program

is

transformed

into

the

following

well-formed

HiLog

program

person

-LRB-

peter

hobby

peter

-RRB-

person

-LRB-

thom

hobby

thom

-RRB-

person

-LRB-

thom

hobby

-LRB-

peter

-RRB-

-RRB-

hobby

peter

-LRB-

bridge

-RRB-

hobby

thom

-LRB-

chess

-RRB-

hobby

thom

-LRB-

tennis

-RRB-

hobby

-LRB-

X

-RRB-

-LRB-

Y

-RRB-

person

-LRB-

X

Z

-RRB-

Z

-LRB-

Y

-RRB-

and

the

corresponding

queries

become

hobby

-LRB-

thom

-RRB-

-LRB-

X

-RRB-

person

-LRB-

thom

hobby

thom

-RRB-

These

queries

yield

the

same

results

as

their

counterparts

in

COL

-LRB-

provided

that

the

above

unstratified

COL

program

is

given

the

intended

semantics

-RRB-

For

another

example

consider

the

COL

query

person

-LRB-

thom

fchessg

-RRB-

to

the

above

database

-LRB-

with

the

last

rule

deleted

to

ensure

stratification

-RRB-

This

query

fails

because

fchessg

and

fchess

tennisg

are

two

different

sets

The

corresponding

HiLog

query

is

person

-LRB-

thom

another

hobby

thom

-RRB-

another

hobby

thom

-LRB-

chess

-RRB-

-LRB-

and

the

database

must

contain

another

hobby

thom

-LRB-

chess

-RRB-

-RRB-

This

query

also

fails

since

similarly

to

COL

another

hobby

thom

represents

a

different

set

of

hobbies

than

hobby

thom

However

the

query

person

-LRB-

thom

hobby

thom

-RRB-

hobby

thom

-LRB-

chess

-RRB-

succeeds

since

it

is

asking

whether

Thom

plays

chess

while

the

previous

query

inquired

whether

f

chess

g

is

one

of

Thom

's

hobby

sets

Notice

that

the

semantics

of

COL

treats

Thom

as

if

he

had

different

sets

of

hobbies

in

different

frames

of

mind

and

we

have

been

able

to

capture

this

aspect

of

COL

pretty

adequately

In

contrast

in

COL

there

is

no

easy

way

-LRB-

without

introducing

additional

rules

-RRB-

to

ask

whether

Thom

plays

chess

which

demonstrates

greater

flexibility

of

HiLog

compared

to

COL.

There

is

however

a

significant

difference

between

the

semantics

of

COL

and

that

of

HiLog

For

instance

suppose

that

instead

of

the

previous

clause

for

hobby

the

hobby-function

is

defined

as

follows

chess

hobby

-LRB-

peter

-RRB-

bridge

hobby

-LRB-

peter

-RRB-

Then

the

query

person

-LRB-

thom

fbridge

chessg

-RRB-

returns

the

answer

true

in

COL

while

the

corresponding

query

person

-LRB-

thom

yet

another

hobby

thom

-RRB-

in

HiLog

returns

false

This

difference

stems

from

the

fact

that

in

COL

the

domain

of

set

variables

consists

of

sets

-LRB-

extensions

-RRB-

while

the

domain

of

variables

in

HiLog

is

a

set

of

objects

-LRB-

intensions

-RRB-

Thus

in

COL

person

-LRB-

thom

hobby

-LRB-

peter

-RRB-

-RRB-

is

evaluated

to

person

-LRB-

thom

fbridge

chess

g

-RRB-

which

allows

the

above

COL

query

to

succeed

Our

contention

is

however

that

the

separation

of

intensional

and

extensional

aspects

in

HiLog

makes

it

more

flexible

The

extensional

semantics

of

COL

can

be

captured

in

HiLog

rather

easily

by

defining

extensional

equality

of

intensions

For

instance

the

following

formula

-LRB-

-LRB-

P

Q

-RRB-

X

-LRB-

P

-LRB-

X

-RRB-

Q

-LRB-

X

-RRB-

-RRB-

-RRB-

says

that

P

and

Q

always

represent

the

same

unary

relations

extensionally

P

and

Q

may

be

intensionally

different

though

and

nothing

is

said

about

say

binary

relations

represented

by

P

and

Q.

However

the

above

axiom

does

not

quite

capture

our

intentions

What

we

really

need

is

the

extensional

equality

of

predicates

with

respect

to

the

intended

semantics

of

logic

programs

For

the

purposes

of

this

section

we

adopt

the

perfect

model

semantics

of

locally

stratified

programs

which

can

be

defined

for

HiLog

along

the

lines

of

-LSB-

-RSB-

The

intended

extensional

equality

can

now

be

captured

via

the

following

rules

with

negation

-LRB-

P

Q

-RRB-

subset

-LRB-

P

Q

-RRB-

subset

-LRB-

Q

P

-RRB-

subset

-LRB-

P

Q

-RRB-

not

not

subset

-LRB-

P

Q

-RRB-

not

subset

-LRB-

P

Q

-RRB-

P

-LRB-

X

-RRB-

not

Q

-LRB-

X

-RRB-

Now

if

desirable

HiLog

can

simulate

the

extensional

semantics

of

COL

for

the

above

query

as

follows

person

-LRB-

thom

X

-RRB-

-LRB-

X

yet

another

hobby

thom

-RRB-

Recall

that

according

to

the

first

transformation

rule

the

database

would

contain

the

facts

yet

another

hobby

thom

-LRB-

bridge

-RRB-

yet

another

hobby

thom

-LRB-

chess

-RRB-

-LSB-

-RSB-

defines

a

well-founded

semantics

of

HiLog

which

is

analogous

to

-LSB-

-RSB-

Since

person

-LRB-

thom

hobby

-LRB-

peter

-RRB-

-RRB-

is

one

of

the

original

facts

in

the

database

the

above

HiLog

query

succeeds

with

X

hobby

-LRB-

peter

-RRB-

So

to

simulate

the

semantics

of

COL

more

closely

-LRB-

but

still

not

exactly

-RRB-

we

must

add

one

more

transformation

rule

which

must

be

applied

after

the

first

two

Replace

every

literal

p

-LRB-

t

:-RRB-

in

the

body

of

a

rule

-LRB-

including

the

queries

-RRB-

where

t

is

either

a

term

involving

a

data

function

or

a

constant

that

replaces

a

finite

set

construction

-LRB-

introduced

by

the

first

transformation

rule

-RRB-

by

the

following

conjunction

p

-LRB-

X

:-RRB-

-LRB-

X

t

-RRB-

For

instance

in

the

above

the

query

person

-LRB-

thom

yet

another

hobby

thom

-RRB-

was

replaced

by

person

-LRB-

thom

X

-RRB-

-LRB-

X

yet

another

hobby

thom

-RRB-

We

complete

our

discussion

of

COL

by

showing

how

to

extend

the

translation

described

above

to

the

general

case

Capturing

the

tuple

construct

is

easy

We

just

reserve

a

parameter

symbol

say

tuple

for

the

specific

purpose

of

representing

COL

tuples

e.g.

-LSB-

a

b

-RSB-

and

-LSB-

c

d

e

-RSB-

become

tuple

-LRB-

a

b

-RRB-

and

tuple

-LRB-

c

d

e

-RRB-

respectively

For

the

set

construct

we

reserve

a

special

symbol

setc

Now

every

finite

set

construct

e.g.

f

a

b

X

d

g

should

be

replaced

by

a

HiLog

term

setc

-LRB-

a

b

X

d

-RRB-

and

the

appropriate

facts

must

be

added

to

the

database

In

our

example

these

would

be

setc

-LRB-

a

b

X

d

-RRB-

-LRB-

a

-RRB-

setc

-LRB-

a

b

X

d

-RRB-

-LRB-

b

-RRB-

setc

-LRB-

a

b

X

d

-RRB-

-LRB-

X

-RRB-

setc

-LRB-

a

b

X

d

-RRB-

-LRB-

d

-RRB-

The

transformation

rule

requires

no

change

in

rule

we

only

need

to

replace

the

phrase

constant

replacing

a

finite

set

construct

by

the

phrase

set

term

replacing

finite

set

construct

LDL

-LSB-

-RSB-

is

another

influential

logic

database

language

with

a

higher-order

semantics

In

addition

to

finite

set

construction

it

provides

the

so

called

grouping

construct

which

is

even

more

general

than

data

functions

of

COL.

Again

LDL

programs

can

be

translated

into

HiLog

with

an

alternative

first-order

semantics

Similarly

to

COL

certain

programs

that

are

not

well-formed

in

LDL

can

be

given

satisfactory

semantics

by

such

a

translation

Finite

set

constructs

of

LDL

are

translated

into

HiLog

the

same

way

as

in

the

case

of

COL.

For

the

grouping

construct

-LRB-

which

in

LDL

can

occur

only

in

rule

heads

-RRB-

we

can

do

the

following

Replace

every

LDL

rule

of

the

form

p

-LRB-

X

Y

-RRB-

body

where

X

Y

are

vectors

of

variables

by

the

pair

of

HiLog

rules

p

-LRB-

X

sym

-LRB-

X

-RRB-

-RRB-

body

sym

-LRB-

X

-RRB-

-LRB-

Y

-RRB-

body

where

sym

is

a

new

HiLog

symbol

Consider

the

following

LDL

program

p

-LRB-

X

-RRB-

p

-LRB-

<X>

-RRB-

p

-LRB-

X

-RRB-

Intuitively

this

says

that

p

is

true

of

all

elements

of

the

domain

and

also

of

some

other

element

of

the

domain

that

in

some

sense

is

the

set

of

all

domain

elements

However

in

LDL

sets

are

members

of

the

domain

on

a

par

with

individuals

As

a

result

the

above

program

becomes

tantamount

to

the

famous

set

theoretic

paradox

since

p

has

to

contain

the

set

of

all

sets

as

an

element

The

corresponding

HiLog

program

is

p

-LRB-

X

-RRB-

p

-LRB-

a

-RRB-

p

-LRB-

X

-RRB-

a

-LRB-

X

-RRB-

p

-LRB-

X

-RRB-

It

defines

a

predicate

which

is

true

of

every

element

in

the

domain

It

also

defines

a

as

a

symbol

that

represents

the

entire

domain

whenever

this

symbol

appears

as

a

constant

within

an

atomic

formula

This

corresponds

to

the

aforementioned

intuitive

meaning

of

the

above

LDL

program

which

favors

the

HiLog

semantics

over

LDL

This

also

shows

that

in

general

the

translation

of

LDL

into

HiLog

does

not

capture

all

the

power

of

the

grouping

However

in

most

normal

cases

of

grouping

in

LDL

the

corresponding

HiLog

program

gives

the

same

result

For

instance

consider

the

set-intersection

example

from

-LSB-

-RSB-

intersect

-LRB-

S

T

<X>

-RRB-

member

-LRB-

X

S

-RRB-

member

-LRB-

X

T

-RRB-

The

corresponding

HiLog

program

is

intersect

-LRB-

S

T

inter

-LRB-

S

T

-RRB-

-RRB-

member

-LRB-

X

S

-RRB-

member

-LRB-

X

T

-RRB-

inter

-LRB-

S

T

-RRB-

-LRB-

X

-RRB-

member

-LRB-

X

S

-RRB-

member

-LRB-

X

T

-RRB-

which

gives

the

same

result

Note

however

that

in

HiLog

set

intersection

has

a

more

concise

and

elegant

representation

inter

-LRB-

S

T

-RRB-

-LRB-

X

-RRB-

S

-LRB-

X

-RRB-

T

-LRB-

X

-RRB-

We

thus

see

that

HiLog

provides

an

alternative

-LRB-

we

believe

computationally

more

attractive

-RRB-

semantics

to

LDL

Unlike

COL

where

it

seems

that

HiLog

can

closely

mimic

the

semantics

there

is

a

more

dramatic

difference

between

HiLog

and

LDL

because

the

latter

is

so

expressive

that

even

logical

paradoxes

can

be

represented

without

much

difficulty

Such

paradoxes

are

not

representable

in

HiLog

since

the

latter

has

a

first-order

semantics

and

the

translation

of

paradoxical

LDL

rules

yields

rather

benign

HiLog

programs

To

conclude

this

comparison

we

mention

that

the

alternative

semantics

for

sets

in

LDL

and

COL

described

above

is

in

the

same

spirit

as

the

semantics

described

in

C-logic

-LSB-

-RSB-

and

O-logic

-LSB-

-RSB-

although

the

latter

are

first-order

-LRB-

object-oriented

-RRB-

languages

It

appears

thus

that

higher-orderness

of

the

syntax

of

HiLog

is

inessential

in

order

to

simulate

sets

However

it

is

essential

for

other

applications

described

earlier

It

seems

like

an

interesting

observation

therefore

that

changing

the

philosophy

behind

logical

languages

can

in

some

cases

eliminate

the

need

for

higher-orderness

either

in

semantics

or

in

syntax

or

in

both

Another

promising

application

of

HiLog

in

the

database

field

is

its

use

as

an

implementation

vehicle

for

object-oriented

languages

recently

proposed

in

-LSB-

-RSB-

C-logic

-LSB-

-RSB-

is

the

simplest

of

the

three

it

supports

complex

objects

object

ids

sets

and

classes

For

instance

the

hobby

example

discussed

earlier

can

be

represented

in

C-logic

as

follows

our

opinion

the

above

discussion

suggests

that

capturing

the

semantics

of

grouping

construct

exactly

is

not

necessary

and

even

harmful

person

peter

-LSB-

hobby

fbridgeg

-RSB-

person

thom

-LSB-

hobby

fchess

tennisg

-RSB-

thom

-LSB-

hobby

fXg

-RSB-

peter

-LSB-

hobby

fXg

-RSB-

yielding

the

same

results

as

those

produced

by

the

corresponding

HiLog

representation

C-logic

admits

a

natural

translation

into

predicate

calculus

by

viewing

each

class

symbol

-LRB-

e.g.

person

-RRB-

as

a

unary

predicate

and

each

set-valued

attribute

-LRB-

e.g.

hobby

-RRB-

as

a

binary

predicate

-LSB-

-RSB-

O

logic

-LSB-

-RSB-

extends

C-logic

by

allowing

single-valued

attributes

and

by

introducing

a

lattice

structure

over

object

ids

which

helps

to

localize

the

effect

of

data

inconsistency

Translation

of

O-logic

into

predicate

calculus

is

just

a

shade

more

complex

it

additionally

requires

axiomatization

of

functional

attributes

and

data

inconsistency

F-logic

-LSB-

-RSB-

takes

object-oriented

logics

to

a

new

dimension

by

introducing

higher-orderness

with

a

first-order

semantics

in

the

same

spirit

as

HiLog

Although

it

can

be

encoded

in

predicate

calculus

this

encoding

is

neither

natural

nor

suggestive

of

an

efficient

implementation

However

an

extension

of

the

algorithm

from

-LSB-

-RSB-

would

translate

F-logic

into

HiLog

quite

naturally

This

opens

up

a

possibility

of

using

HiLog

for

fast

prototyping

of

object-oriented

logic

languages

Compared

to

the

direct

implementation

of

object-oriented

databases

the

advantage

of

HiLog

as

an

implementation

platform

is

that

it

can

be

relatively

easily

implemented

using

one

of

the

already

available

technologies

developed

for

Prolog

-LSB-

-RSB-

or

LDL

Proof

Theory

of

HiLog

Because

of

the

encoding

in

Section

one

can

use

a

proof

theory

for

predicate

calculus

in

order

to

prove

theorems

for

HiLog

However

a

proof

theory

stated

in

terms

of

this

encoding

is

neither

intuitive

nor

suggestive

of

a

possible

efficient

implementation

Furthermore

extensions

of

HiLog

will

be

developed

in

order

to

support

more

features

such

as

lambda

abstractions

and

dynamic

updates

and

these

extensions

may

not

have

a

direct

translation

into

predicate

calculus

A

direct

proof

theory

of

HiLog

is

therefore

important

in

its

own

right

and

may

provide

additional

insights

for

further

investigations

of

HiLog

extensions

In

this

section

we

present

a

resolution-based

proof

theory

given

directly

in

terms

of

HiLog

The

following

issues

are

examined

Skolem

and

Herbrand

theorem

unification

and

resolution

The

discussion

follows

the

development

of

resolution-based

proof

theory

for

predicate

calculus

-LSB-

-RSB-

Skolemization

Given

a

sentence

OE

in

HiLog

it

can

be

transformed

into

an

equivalent

formula

in

prenex

normal

form

QnXn

where

Qi

-LRB-

i

n

-RRB-

is

either

or

is

a

quantifier-free

formula

in

conjunctive

normal

form

and

Xi

-LRB-

i

n

-RRB-

are

all

variables

occurring

in

The

rules

for

this

transformation

are

identical

to

those

for

the

ordinary

predicate

calculus

since

the

usual

De

Morgan

's

laws

apply

due

to

the

fact

that

the

definition

of

logical

entailment

relation

j

in

Section

is

identical

to

that

in

predicate

calculus

-LRB-

except

for

the

notion

of

atomic

formulas

-RRB-

Because

of

the

similarities

between

HiLog

and

predicate

calculus

one

might

think

that

by

eliminating

all

existential

quantifiers

in

using

the

usual

Skolemization

process

in

predicate

calculus

we

will

obtain

a

Skolem

standard

form

OE

of

OE

which

is

unsatisfiable

if

and

only

if

so

is

OE

However

unsatisfiability

of

OE

does

not

entail

unsatisfiability

of

OE

To

see

this

consider

OE

-LRB-

X

Y

-RRB-

:p

-LRB-

Z

F

-LRB-

Z

-RRB-

-RRB-

Converting

OE

into

prenex

normal

form

and

then

Skolemizing

X

and

Y

in

the

ordinary

manner

-LRB-

using

the

new

function

symbols

g

and

h

-RRB-

yields

OE

-LRB-

p

-LRB-

X

g

-LRB-

X

-RRB-

-RRB-

:p

-LRB-

h

-LRB-

F

-RRB-

F

-LRB-

h

-LRB-

F

-RRB-

-RRB-

-RRB-

-RRB-

It

is

easy

to

see

that

OE

is

satisfiable

in

HiLog

-LRB-

but

not

in

the

second-order

predicate

calculus

-RRB-

which

can

be

verified

directly

by

constructing

a

semantic

structure

M

U

Utrue

I

F

in

which

for

every

u

U

the

function

u

-LRB-

-RRB-

F

is

different

from

all

the

functions

U

U

defined

by

the

expression

-LRB-

X

Y

-RRB-

In

contrast

OE

is

unsatisfiable

since

p

-LRB-

h

-LRB-

g

-RRB-

g

-LRB-

h

-LRB-

g

-RRB-

-RRB-

-RRB-

:p

-LRB-

h

-LRB-

g

-RRB-

g

-LRB-

h

-LRB-

g

-RRB-

-RRB-

-RRB-

is

an

instance

of

OE

Intuitively

the

reason

why

the

usual

Skolemization

process

misbehaves

is

that

in

HiLog

it

is

not

enough

to

choose

a

new

symbol

to

represent

a

new

Skolem

function

such

a

symbol

also

needs

to

be

assigned

a

new

intension

Indeed

we

have

to

assign

an

appropriate

Skolem

function

as

an

extension

of

the

symbol

introduced

by

Skolemization

In

predicate

calculus

extensions

are

assigned

directly

to

function

symbols

and

therefore

by

choosing

a

new

function

symbol

we

can

construct

a

semantic

structure

for

any

desired

Skolem

function

In

contrast

HiLog

assigns

extensions

to

intensions

of

function

symbols

and

simply

choosing

a

new

symbol

is

no

longer

enough

we

should

be

able

to

assign

a

new

intension

to

such

a

symbol

which

as

the

above

example

shows

is

not

always

possible

In

fact

as

we

shall

see

choosing

a

new

symbol

is

not

that

crucial

for

Skolemization

in

HiLog

One

way

to

overcome

this

problem

is

to

modify

Skolemization

so

as

to

avoid

the

need

to

assign

new

intensions

to

Skolem

functions

Instead

of

introducing

a

new

Skolem

symbol

we

will

use

an

unused

arity

of

one

of

the

old

symbols

patching

the

extra

argument

positions

For

the

formula

OE

above

we

could

use

say

symbol

p

with

the

arity

for

Y

and

with

the

arity

for

Z

obtaining

the

following

Skolemized

form

p

-LRB-

X

p

-LRB-

X

p

p

-RRB-

-RRB-

:p

-LRB-

p

-LRB-

F

p

p

p

-RRB-

F

-LRB-

p

-LRB-

F

p

p

p

-RRB-

-RRB-

-RRB-

Notice

how

the

symbol

p

was

used

to

fill

in

the

argument

positions

of

the

terms

p

-LRB-

X

p

p

-RRB-

and

p

-LRB-

F

p

p

p

-RRB-

Let

L

be

a

language

of

HiLog

that

contains

at

least

one

parameter

symbol

Given

a

formula

of

L

in

prenex

normal

form

QnXn

where

Qi

-LRB-

i

n

-RRB-

is

either

or

is

a

quantifier-free

formula

in

conjunctive

normal

form

and

Xi

-LRB-

i

n

-RRB-

are

all

variables

occurring

in

Suppose

that

Qi

is

the

leftmost

existential

quantifier

in

OE

Let

k

be

the

maximum

arity

that

has

been

used

in

OE

which

exists

since

OE

is

finite

We

obtain

a

new

formula

by

eliminating

the

leftmost

existential

quantifier

Qi

in

OE

and

replacing

every

occurrence

of

Xi

in

with

p

-LRB-

Xi

p

p

-RRB-

which

has

max

-LRB-

k

i

-RRB-

arguments

Assume

that

there

are

m

existential

quantifiers

in

We

repeat

this

process

for

every

OEj

-LRB-

j

m

-RRB-

and

finally

derive

a

formula

OEm

without

any

existential

quantifiers

The

formula

OEm

is

called

the

Skolem

standard

form

of

Lemma

A

sentence

OE

is

unsatisfiable

if

and

only

if

its

Skolem

standard

form

OE

is

unsatisfiable

are

grateful

to

one

of

the

referees

for

suggesting

this

example

and

pointing

out

a

mistake

in

an

earlier

draft

of

this

paper

Proof

Without

loss

of

generality

we

assume

that

OE

is

already

in

prenex

normal

form

Let

be

OE

and

m

be

the

number

of

existential

quantifiers

in

OE

Then

OE

is

OEm

where

each

OEj

-LRB-

j

m

-RRB-

is

obtained

from

OEj

by

the

above

Skolemization

process

We

show

that

OEj

is

unsatisfiable

if

and

only

if

OEj

is

unsatisfiable

Let

OEj

be

in

a

prenex

normal

form

Xi

Xi

QnXn

-LSB-

Xn

-RSB-

where

Xi

is

the

leftmost

existential

variable

-LSB-

Xn

-RSB-

is

a

formula

in

conjunctive

form

and

Xn

are

all

the

variables

occurring

in

it

Suppose

that

k

is

the

maximum

arity

that

has

been

used

in

OEj

and

f

is

the

parameter

symbol

used

in

the

Skolemization

of

Xi

Then

OEj

is

of

the

form

Xi

Xi

QnXn

-LSB-

Xi

f

-LRB-

Xi

f

f

-RRB-

Xi

Xn

-RSB-

where

f

-LRB-

Xi

f

f

-RRB-

has

max

-LRB-

k

i

-RRB-

arguments

Suppose

that

OEj

is

true

in

a

semantic

structure

M

U

Utrue

I

F

but

OEj

is

unsatisfiable

Then

for

every

xi

U

there

exists

xi

U

such

that

M

j

Qi

Xi

QnXn

-LSB-

Xn

-RSB-

-LRB-

-RRB-

for

every

variable

assignment

that

maps

Xi

to

xi

respectively

We

construct

a

new

semantic

structure

U

Utrue

I

F

where

F

is

exactly

the

same

as

F

except

that

for

every

xi

U

I

-LRB-

f

-RRB-

k

F

-LRB-

xi

I

-LRB-

f

-RRB-

I

-LRB-

f

-RRB-

-RRB-

xi

where

xi

is

chosen

as

explained

in

-LRB-

-RRB-

above

Since

the

arity

k

is

not

used

in

OEj

the

function

I

-LRB-

f

-RRB-

k

F

is

not

used

to

determine

whether

-LRB-

-RRB-

holds

This

together

with

the

fact

that

the

domains

of

M

and

M

coincide

yields

j

OEj

Since

was

chosen

arbitrarily

for

Xi

and

Xi

does

not

occur

in

OEj

it

follows

that

j

OEj

contrary

to

the

assumption

that

OEj

is

unsatisfiable

Therefore

OEj

must

be

unsatisfiable

For

the

reverse

direction

assume

-LRB-

in

the

above

notation

-RRB-

that

OEj

is

true

in

a

semantic

structure

M

but

OEj

is

unsatisfiable

Following

the

definition

it

can

be

verified

that

OEj

is

true

in

M

a

contradiction

Thus

OEj

must

be

unsatisfiable

Note

that

Skolemization

in

HiLog

as

presented

above

works

for

finite

sets

of

formulas

only

A

solution

that

also

works

for

infinite

sets

is

proposed

in

-LSB-

-RSB-

The

idea

is

to

introduce

sorted

symbols

into

HiLog

and

then

use

classical

Skolemization

which

does

not

rely

on

the

existence

of

unused

arities

This

however

requires

an

extension

to

HiLog

and

will

not

be

discussed

here

-LRB-

see

-LSB-

-RSB-

-RRB-

Herbrand

's

Theorem

Once

Skolemized

we

can

restrict

our

attention

to

universal

formulas

i.e.

to

formulas

in

prenex

normal

form

whose

prefix

contains

universal

quantification

only

Furthermore

transforming

such

formulas

into

conjunctive

normal

form

yields

HiLog

formulas

in

the

clausal

form

As

usual

we

can

then

drop

quantification

altogether

with

the

understanding

that

clauses

are

implicitly

universally

quantified

Variable-free

formulas

are

called

ground

The

rest

of

the

formulas

are

nonground

Herbrand

interpretations

for

HiLog

were

defined

in

Section

Recall

that

given

a

HiLog

language

L

its

Herbrand

universe

HU

-LRB-

L

-RRB-

coincides

with

its

Herbrand

base

and

is

defined

as

the

set

of

all

ground

-LRB-

i.e.

variable-free

-RRB-

HiLog

terms

However

when

the

equality

predicate

is

taken

into

account

the

definition

of

Herbrand

interpretations

needs

adjustment

Definition

Let

L

be

a

HiLog

language

and

H

be

a

subset

of

its

Herbrand

base

Then

H

is

called

a

Herbrand

interpretation

if

it

is

closed

under

the

congruence

two

formulas

in

the

middle

follow

from

the

other

two

ffl

-LRB-

-RRB-

H

ffl

if

-LRB-

-RRB-

H

then

-LRB-

-RRB-

H

ffl

if

-LRB-

-RRB-

-LRB-

-RRB-

H

then

-LRB-

-RRB-

H

ffl

if

L

-LRB-

-RRB-

H

and

is

the

result

of

replacing

of

an

occurrence

of

in

L

by

then

H.

Given

a

Herbrand

interpretation

H

we

can

define

satisfaction

of

formulas

in

H

similarly

to

the

classic

case

ffl

If

a

is

a

ground

HiLog

atomic

formula

then

H

j

a

if

and

only

if

a

H.

ffl

If

OE

and

are

ground

HiLog

formulas

then

-LCB-

H

j

-LRB-

OE

-RRB-

if

and

only

if

H

j

OE

or

H

j

-LCB-

H

j

-LRB-

OE

-RRB-

if

and

only

if

H

j

OE

and

H

j

-LCB-

H

j

OE

if

and

only

if

it

is

not

the

case

that

H

j

OE

ffl

If

OE

is

a

universal

formula

then

H

j

OE

if

and

only

if

H

j

for

every

ground

instance

of

OE

To

avoid

possible

misunderstanding

recall

that

in

the

presence

of

equality

we

only

consider

those

semantic

structures

that

assign

the

intended

meaning

to

the

equality

predicate

-LRB-

see

Section

-RRB-

To

emphasize

this

fact

we

will

call

such

semantic

structures

E-structures

We

can

then

talk

about

E

unsatisfiable

and

E-valid

formulas

i.e.

formulas

that

are

false

-LRB-

resp

true

-RRB-

in

all

E-structures

Lemma

Let

L

be

a

HiLog

language

For

every

E-structure

M

there

is

a

Herbrand

interpretation

HM

such

that

for

every

universal

formula

OE

M

j

OE

if

and

only

if

HM

j

OE

Likewise

for

every

Herbrand

interpretation

H

there

is

an

E-structure

MH

such

that

H

j

OE

if

and

only

if

MH

j

OE

for

every

universal

formula

OE

Proof

If

M

is

an

E-structure

then

the

corresponding

Herbrand

interpretation

HM

is

simply

the

set

of

all

ground

atomic

formulas

of

L

satisfied

by

M.

Conversely

let

H

be

a

Herbrand

interpretation

The

corresponding

E-structure

MH

U

Utrue

I

F

is

defined

thus

U

def

HU

-LRB-

L

-RRB-

the

factor-space

of

the

Herbrand

universe

HU

-LRB-

L

-RRB-

with

respect

to

the

equivalence

relation

induced

by

the

equality

atoms

in

H

If

s

HU

-LRB-

L

-RRB-

its

corresponding

element

in

U

will

be

denoted

by

-LSB-

s

-RSB-

Utrue

def

H

-LRB-

L

-RRB-

the

factor-space

of

H

with

respect

to

the

aforesaid

equivalence

relation

I

S

U

is

obtained

from

the

identity

embedding

Id

S

HU

-LRB-

L

-RRB-

by

composing

Id

with

the

natural

epimorphism

HU

-LRB-

L

-RRB-

U

i.e.

for

each

s

S

I

-LRB-

s

-RRB-

-LSB-

s

-RSB-

F

is

defined

thus

For

every

-LSB-

s

-RSB-

U

and

k

-LSB-

s

-RSB-

-LRB-

k

-RRB-

F

-LRB-

-LSB-

-RSB-

-LSB-

tk

-RSB-

-RRB-

-LSB-

s

-LRB-

tk

-RRB-

-RSB-

It

is

left

to

the

reader

to

verify

that

M

and

HM

-LRB-

resp.

H

and

MH

-RRB-

stand

in

the

desired

relationship

to

each

other

The

proof

is

carried

out

by

structural

induction

on

HiLog

formulas

similarly

to

the

classic

case

As

a

consequence

of

the

above

lemma

a

universal

formula

is

E-unsatisfiable

if

and

only

if

it

has

no

Herbrand

model

Corollary

A

set

S

of

HiLog

clauses

is

E-unsatisfiable

if

and

only

if

S

is

false

under

all

Herbrand

interpretations

of

S.

Theorem

-LRB-

cf.

Herbrand

's

Theorem

-RRB-

A

set

S

of

HiLog

clauses

is

E-unsatisfiable

if

and

only

if

there

is

a

finite

E-unsatisfiable

set

of

ground

instances

of

clauses

of

S.

Proof

It

is

easy

to

verify

that

for

any

set

of

HiLog

clauses

S

the

encoding

of

Section

establishes

a

correspondence

between

Herbrand

interpretations

of

S

and

those

of

encodea

-LRB-

S

-RRB-

The

only

subtlety

here

is

that

in

HiLog

the

Herbrand

universe

and

the

Herbrand

base

coincide

while

in

predicate

calculus

they

are

distinct

For

this

reason

the

Herbrand

universe

of

encodea

-LRB-

S

-RRB-

is

obtained

by

applying

encodet

to

the

Herbrand

universe

of

S

while

the

Herbrand

base

of

encodea

-LRB-

S

-RRB-

is

obtained

from

that

of

S

via

encodea

Herbrand

's

theorem

for

HiLog

now

directly

follows

from

Theorem

and

the

analogous

result

in

predicate

calculus

-LSB-

-RSB-

Unification

Although

HiLog

allows

arbitrary

terms

to

appear

in

places

where

only

predicates

and

functions

are

usually

allowed

in

predicate

calculus

unification

in

HiLog

is

a

very

simple

extension

of

unification

in

predicate

calculus

and

is

decidable

This

is

mainly

because

HiLog

separates

intensions

from

extensions

and

does

not

have

any

non-trivial

built-in

equality

theory

over

intensions

Except

for

the

different

notion

of

terms

in

HiLog

the

definitions

of

substitutions

applications

of

substitutions

to

terms

and

substitution

composition

in

HiLog

are

the

same

as

those

in

predicate

calculus

-LSB-

-RSB-

Definition

A

substitution

is

a

finite

set

of

the

form

tn

Xng

where

Xn

are

distinct

variables

and

every

term

ti

is

different

from

Xi

where

i

n.

Definition

A

unifier

for

a

set

of

HiLog

terms

ekg

is

a

substitution

such

that

ek

A

set

ekg

is

unifiable

if

it

has

a

unifier

Definition

A

unifier

oe

for

a

set

ekg

of

expressions

is

most

general

if

and

only

if

for

each

unifier

for

this

set

there

is

a

substitution

such

that

oe

Following

-LSB-

-RSB-

we

can

derive

an

efficient

unification

algorithm

by

solving

equations

An

equation

is

of

the

form

where

are

terms

An

equation

set

-LRB-

possibly

empty

-RRB-

is

solved

if

it

has

the

form

Xn

tng

and

the

Xi

's

are

distinct

variables

which

do

not

occur

in

any

tj

-LRB-

j

n

-RRB-

Notice

that

a

finite

equation

set

in

solved

form

can

be

naturally

viewed

as

a

substitution

A

solution

of

the

equation

set

tn

sng

is

a

substitution

such

that

ti

si

-LRB-

i

n

-RRB-

An

equation

set

is

solvable

if

it

has

a

solution

A

solution

oe

for

an

equation

set

E

is

most

general

if

and

only

if

for

each

solution

of

E

there

is

a

substitution

such

that

oe

Given

a

finite

equation

set

the

unification

algorithm

non-deterministically

chooses

an

equation

from

the

equation

set

to

which

it

applies

one

of

the

following

transformations

according

to

the

form

of

the

selected

equation

For

t

-LRB-

tn

-RRB-

s

-LRB-

sm

-RRB-

where

n

m

halt

with

failure

For

t

-LRB-

tn

-RRB-

s

-LRB-

sn

-RRB-

replace

the

equation

by

t

s

tn

sn

For

f

g

delete

the

equation

if

f

and

g

are

identical

parameter

symbols

in

S

otherwise

halt

with

failure

For

X

X

where

X

is

a

variable

delete

the

equation

For

t

X

where

t

is

not

a

variable

and

X

is

a

variable

replace

the

equation

by

X

t.

For

X

t

where

X

is

a

variable

and

t

is

a

term

different

from

X

if

X

appears

in

t

then

halt

with

failure

otherwise

replace

X

by

t

wherever

it

occurs

in

the

equations

The

algorithm

terminates

when

no

further

transformation

can

be

applied

or

when

failure

is

reported

Theorem

-LRB-

Unification

Theorem

-RRB-

The

unification

algorithm

applied

to

a

finite

set

of

equations

E

returns

a

finite

set

E

of

equations

in

solved

form

if

and

only

if

E

is

solvable

It

returns

failure

otherwise

The

returned

equation

set

E

viewed

as

a

substitution

is

a

most

general

solution

of

E

if

E

is

solvable

Proof

It

is

easy

to

see

that

for

any

pair

of

HiLog

terms

s

and

r

they

are

unifiable

if

and

only

if

so

are

encodet

-LRB-

s

-RRB-

and

encodet

-LRB-

r

-RRB-

if

and

only

if

encodea

-LRB-

s

-RRB-

and

encodea

-LRB-

r

-RRB-

are

unifiable

It

is

also

easy

to

see

that

the

encoding

of

HiLog

in

PC

transforms

the

above

unification

algorithm

for

HiLog

into

the

corresponding

algorithm

for

PC

described

in

-LSB-

-RSB-

The

theorem

now

follows

from

these

two

facts

A

direct

proof

can

be

also

obtained

as

a

simple

adaptation

of

the

proof

in

-LSB-

-RSB-

According

to

the

above

theorem

HiLog

unification

is

decidable

The

reader

may

wonder

about

the

result

reported

in

-LSB-

-RSB-

where

it

is

shown

that

unification

becomes

undecidable

once

variables

are

allowed

in

places

where

normally

only

function

symbols

are

permitted

to

appear

There

is

no

contradiction

however

with

our

result

for

the

following

reasons

Informally

for

a

sufficiently

rich

logic

with

a

higherorder

syntax

to

have

a

decidable

unification

problem

two

conditions

are

sufficient

First

the

semantics

of

the

logic

should

be

first-order

That

is

predicate

and

function

variables

should

not

range

over

relations

or

functions

Instead

they

must

range

over

intensions

or

names

of

predicates

and

functions

Second

the

logic

should

not

have

an

undecidable

built-in

equality

theory

over

names

of

predicates

and

functions

HiLog

satisfies

both

conditions

by

separating

intensions

from

extensions

-LRB-

thereby

avoiding

extensional

unification

-RRB-

and

by

embodying

only

a

trivial

equality

theory

of

intensions

In

contrast

Goldfarb

-LSB-

-RSB-

essentially

works

with

second-order

terms

that

embody

an

undecidable

equality

theory

and

this

is

what

makes

unification

undecidable

in

this

case

Refutation

Definition

If

two

or

more

literals

of

the

same

polarity

-LRB-

i.e.

both

positive

or

both

negative

-RRB-

in

a

clause

C

have

a

most

general

unifier

oe

then

Coe

is

called

a

factor

of

C.

Definition

Let

L

-LSB-

t

-RSB-

and

-LRB-

r

s

-RRB-

be

two

clauses

with

no

variables

in

common

where

L

-LSB-

t

-RSB-

is

a

literal

with

an

occurrence

of

the

term

t

-LRB-

including

the

case

when

L

-LSB-

t

-RSB-

t

-RRB-

If

t

and

r

have

a

most

general

unifier

oe

then

Loe

-LSB-

soe

-RSB-

is

a

binary

paramodulant

of

and

In

this

paramodulant

Loe

-LSB-

soe

-RSB-

denotes

the

result

of

replacing

one

single

occurrence

of

toe

in

Loe

by

soe

It

is

important

to

realize

that

since

L

-LSB-

t

-RSB-

in

the

above

definition

may

be

the

same

as

t

in

HiLog

one

needs

to

paramodulate

not

only

on

the

terms

occurring

strictly

inside

atomic

formulas

as

is

the

case

in

predicate

calculus

but

also

on

atomic

formulas

themselves

This

is

an

interesting

distinction

with

respect

to

PC

which

stems

from

the

fact

that

HiLog

is

a

higher-order

language

in

which

atomic

formulas

are

not

distinguished

from

terms

An

example

when

atomic

formulas

must

be

paramodulated

upon

is

presented

below

Definition

Let

and

be

a

pair

of

clauses

with

no

variables

in

common

If

and

have

a

most

general

unifier

oe

then

the

clause

is

called

a

binary

resolvent

of

and

A

deduction

of

a

clause

C

from

a

set

of

clauses

S

is

a

finite

sequence

of

clauses

Dn

such

that

Dn

C

and

for

k

n

each

Dk

is

either

a

member

of

S

a

factor

of

Di

-LRB-

i

k

-RRB-

a

paramodulant

of

some

Di

and

Dj

-LRB-

i

j

k

-RRB-

or

a

binary

resolvent

of

Di

and

Dj

-LRB-

i

j

k

-RRB-

A

deduction

ending

with

the

empty

clause

is

called

a

refutation

If

C

is

deducible

from

S

we

write

S

C

One

way

to

prove

the

completeness

theorem

is

to

adapt

the

corresponding

proof

for

PC

-LSB-

-RSB-

A

shorter

proof

however

results

from

the

use

of

Theorem

Theorem

-LRB-

Soundness

and

Completeness

of

Resolution

-RRB-

A

set

S

of

clauses

is

E-unsatisfiable

if

and

only

if

there

exists

a

refutation

of

S

-LSB-

fX

Xg

Proof

Under

the

encoding

of

Section

given

a

set

of

HiLog

clauses

S

any

application

of

the

factorization

paramodulation

or

the

resolution

rules

to

clauses

in

S

corresponds

to

an

application

of

the

respective

rule

to

encode

-LRB-

S

-RRB-

and

vice

versa

Thus

it

follows

from

the

analogous

result

in

predicate

calculus

-LSB-

-RSB-

that

the

combination

of

resolution

factorization

and

paramodulation

is

a

complete

set

of

inference

rules

for

refuting

E-unsatisfiable

sets

of

HiLog

clauses

Note

that

unlike

-LSB-

-RSB-

we

do

not

include

functional

reflexivity

axioms

f

-LRB-

xn

-RRB-

f

-LRB-

xn

-RRB-

in

the

formulation

of

Theorem

This

is

possible

due

to

a

result

in

-LSB-

-RSB-

that

shows

that

these

axioms

are

not

needed

for

completeness

of

paramodulation

We

also

note

that

if

S

contains

no

equality

atoms

then

E-unsatisfiability

can

be

replaced

by

unsatisfiability

and

the

axiom

X

X

would

not

be

needed

Consider

an

example

Recall

from

Section

that

the

formula

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-RRB-

oe

-LRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-RRB-

is

valid

in

HiLog

Therefore

its

negation

should

be

E-unsatisfiable

The

negation

of

the

above

formula

can

be

transformed

into

the

following

three

clauses

-LRB-

-RRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-LRB-

-RRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

-LRB-

-RRB-

s

-LRB-

a

-RRB-

r

-LRB-

b

c

-RRB-

is

noted

that

the

special

treatment

of

in

the

definition

of

encode

in

Section

was

essential

to

ensure

the

above

correspondence

in

case

of

the

paramodulation

rule

result

was

pointed

out

to

us

by

Leo

Bachmair

By

paramodulation

we

can

derive

from

-LRB-

-RRB-

and

-LRB-

-RRB-

-LRB-

-RRB-

r

-LRB-

b

c

-RRB-

and

from

-LRB-

-RRB-

and

-LRB-

-RRB-

-LRB-

-RRB-

r

-LRB-

b

c

-RRB-

Then

by

resolution

we

can

derive

the

empty

clause

from

-LRB-

-RRB-

and

-LRB-

-RRB-

which

completes

the

refutation

HiLog

Implementation

Issues

A

straightforward

implementation

of

a

Horn

clause

logic

programming

language

based

on

HiLog

is

possible

using

the

encoding

of

HiLog

into

PC

described

in

Section

Since

this

encoding

preserves

Horn

clauses

we

could

simply

use

a

standard

Prolog

compiler

to

execute

the

result

of

such

encoding

While

this

is

theoretically

sound

and

may

even

be

practical

for

prototype

programs

for

large

programs

there

are

some

efficiency

issues

that

deserve

further

consideration

These

have

to

do

with

fast

access

to

the

appropriate

clauses

at

predicate

invocation

and

efficient

representation

of

data

structures

Also

built-in

nonlogical

predicates

dynamic

changes

to

the

database

and

control

constructs

such

as

the

cut

lead

to

new

issues

in

the

HiLog

framework

Consider

a

simple

HiLog

Horn

clause

p

-LRB-

X

Y

-RRB-

q

-LRB-

X

Z

-RRB-

p

-LRB-

Z

Y

-RRB-

This

clause

also

happens

to

be

a

predicate

logic

Horn

clause

Its

encoding

in

predicate

logic

is

call

-LRB-

apply

-LRB-

p

X

Y

-RRB-

-RRB-

call

-LRB-

apply

-LRB-

q

X

Z

-RRB-

-RRB-

call

-LRB-

apply

-LRB-

p

Z

Y

-RRB-

-RRB-

With

every

clause

encoded

in

this

way

each

HiLog

program

no

matter

how

large

defines

exactly

one

Prolog

predicate

For

Prolog-like

efficiency

each

predicate

invocation

must

locate

quickly

the

clauses

whose

heads

might

possibly

unify

In

Prolog

systems

this

is

achieved

first

by

branching

directly

to

clauses

with

the

same

predicate

and

then

using

indexing

normally

on

the

main

functor

symbol

of

the

first

argument

to

further

refine

the

search

Notice

that

for

the

encoding

of

a

HiLog

program

these

two

ways

of

refining

the

search

are

not

very

effective

Prolog

sees

only

one

predicate

and

the

main

functors

of

all

those

heads

are

apply/n

Thus

the

only

filtering

would

come

from

the

arity

of

apply

One

approach

would

be

to

use

partial

evaluation

techniques

to

optimize

the

direct

translation

-LSB-

-RSB-

A

problem

with

this

approach

is

how

to

treat

nonlogical

constructs

such

as

assert

Another

way

to

improve

clause

access

would

be

to

improve

the

indexing

strategy

used

by

the

underlying

Prolog

system

perhaps

as

proposed

in

-LSB-

-RSB-

An

alternative

is

to

constrain

the

HiLog

programs

in

such

a

way

as

to

allow

simple

compile-time

optimizations

One

way

we

are

exploring

is

to

restrict

the

clauses

to

those

whose

heads

have

a

nonvariable

symbol

in

the

leftmost

position

that

is

clauses

whose

heads

are

rigid

terms

In

this

case

all

rigid

calls

in

the

bodies

of

clauses

can

be

compiled

to

branch

directly

to

the

appropriate

clauses

Another

issue

is

the

representation

of

HiLog

terms

In

Prolog

complex

terms

are

normally

represented

as

linked

record

structures

An

n-ary

term

is

represented

using

n

consecutive

words

the

first

word

indicates

the

functor

symbol

and

the

arity

n

and

the

following

n

words

represent

the

n

arguments

To

represent

a

HiLog

term

another

arity

is

required

The

most

natural

way

uses

n

words

one

for

the

arity

one

for

-LRB-

a

pointer

to

-RRB-

the

functor

term

and

n

for

the

argument

terms

While

this

might

seem

somewhat

wasteful

of

space

using

an

entire

word

for

a

relatively

small

arity

we

suspect

that

this

will

turn

out

to

be

the

most

efficient

representation

It

is

actually

a

regularization

of

Prolog

's

representation

and

will

make

for

slightly

simpler

traversal

algorithms

A

realistic

logic

programming

system

must

support

built-ins

which

have

nonlogical

behavior

A

decision

must

be

made

as

to

whether

these

built-ins

can

be

accessed

by

a

most

general

call

For

example

should

the

query

X

-LRB-

Y

-RRB-

be

able

to

call

the

predicate

The

most

reasonable

choice

seems

to

be

to

exclude

this

possibility

A

desired

separation

of

built-in

predicates

from

the

rest

can

be

achieved

by

introducing

sorts

into

HiLog

-LSB-

-RSB-

that

is

by

splitting

S

and

V

into

disjoint

subsets

and

then

proceeding

to

define

HiLog

terms

of

different

sorts

In

this

way

normal

variables

will

not

be

instantiatable

by

the

symbols

that

represent

built-in

predicates

If

the

user

wishes

to

manipulate

such

symbols

he

would

have

to

use

variables

of

an

appropriate

sort

explicitly

The

issue

of

the

cut

is

also

complicated

In

Prolog

a

cut

eliminates

the

alternative

clauses

remaining

for

the

current

predicate

Since

in

HiLog

different

calls

can

access

various

subsets

of

clauses

the

notion

of

predicate

is

not

so

well-defined

These

and

other

issues

are

explored

in

more

detail

in

-LSB-

-RSB-

Conclusion

Do

We

Need

Yet

Another

Logic

Whenever

a

new

logic

is

proposed

the

question

is

-LRB-

and

should

be

-RRB-

raised

as

to

whether

yet

another

logic

is

needed

Why

not

just

stay

with

the

logics

we

know

and

understand

This

is

an

especially

cogent

point

when

the

new

logic

has

a

simple

and

reasonably

direct

translation

into

the

grand-daddy

of

all

logics

first-order

predicate

calculus

as

in

our

case

HiLog

does

We

believe

however

that

in

the

case

of

HiLog

there

are

at

least

three

reasons

why

we

should

seriously

entertain

the

idea

of

this

new

logic

as

a

basis

for

logic

programming

Firstly

programming

in

HiLog

makes

more

logic

programs

logical

We

all

admonish

Prolog

programmers

to

make

their

programs

as

pure

as

possible

and

to

eschew

the

evils

of

Prolog

's

nonlogical

constructs

In

Prolog

the

intermixing

of

predicate

and

function

symbols

in

particular

in

the

predicate

is

nonlogical

whereas

in

HiLog

it

is

completely

logical

and

is

a

first-class

citizen

So

in

HiLog

programmers

need

not

avoid

using

and

so

have

more

flexibility

in

their

task

of

writing

pure

logic

programs

Secondly

even

though

one

might

say

that

HiLog

is

simply

a

syntactic

variant

of

Prolog

syntax

is

important

when

one

is

doing

meta-programming

Since

in

meta-programming

the

syntax

determines

the

data

structures

to

be

manipulated

a

simpler

syntax

means

that

meta-programs

can

be

much

simpler

We

saw

this

in

the

example

of

translating

DCGs

to

HiLog

to

the

extent

that

a

meta-program

already

written

-LRB-

the

DCG

translator

-RRB-

would

automatically

work

in

a

more

complicated

situation

and

so

did

not

need

to

be

changed

at

all

Thirdly

and

perhaps

most

importantly

a

different

logic

encourages

in

the

programmer

a

different

way

of

thinking

Certainly

the

translation

of

any

HiLog

program

could

be

programmed

directly

in

Prolog

but

would

it

be

The

DCG

example

we

believe

shows

not

Not

only

is

there

an

issue

of

efficiency

in

that

the

translation

might

not

execute

as

efficiently

as

the

programmer

desires

but

also

that

the

programmer

would

not

even

think

of

that

Prolog

program

HiLog

encourages

the

programmer

to

think

about

and

use

parameterized

predicates

Prolog

does

not

HiLog

programmers

would

be

more

likely

than

Prolog

programmers

to

modularize

their

programs

along

the

lines

suggested

in

Section

above

The

language

influences

the

way

programmers

think

and

the

programs

they

write

Finally

we

would

like

to

point

out

that

HiLog

is

not

the

only

logic

which

can

be

encoded

in

predicate

calculus

The

classic

first-order

modal

logics

provide

a

rich

source

of

examples

when

a

different

syntax

-LRB-

motivated

by

a

different

philosophy

of

logic

-RRB-

inspired

important

and

useful

studies

both

in

Logic

and

Artificial

Intelligence

In

summary

we

believe

that

HiLog

offers

significant

advantages

over

Prolog

and

deserves

serious

consideration

as

the

basis

for

a

new

logic

programming

language

Acknowledgments

We

are

grateful

to

Leo

Bachmair

Thom

Fruehwirth

Sanjay

Manchanda

Shuky

Sagiv

Rodney

Topor

and

James

Wu

for

their

comments

on

the

contents

of

this

paper

Especially

we

thank

James

Wu

for

suggesting

the

encoding

described

in

Section

Suggestions

of

the

referees

are

also

appreciated

References

-LSB-

-RSB-

Abiteboul

S.

and

Grumbach

S.

-LSB-

-RSB-

COL

A

Logic-Based

Language

for

Complex

Objects

in

Proc

Workshop

on

Database

Programming

Languages

Roscoff

France

September

pp.

-LCB-

-LSB-

-RSB-

Abramson

H.

-LSB-

-RSB-

Metarules

and

an

Approach

to

Conjunction

in

Definite

Clause

Translation

Grammars

Some

Aspects

of

Grammatical

Metaprogramming

in

Proceedings

of

the

Fifth

International

Conference

and

Symposium

on

Logic

Programming

R.A.

Kowalski

and

K.A.

Bowen

eds

Seattle

Washington

August

pp.

-LCB-

-LSB-

-RSB-

Apt

K.R.

Blair

H.

and

Walker

A.

-LSB-

-RSB-

Towards

a

Theory

of

Declarative

Knowledge

in

Foundations

of

Deductive

Databases

and

Logic

Programming

-LRB-

J.

Minker

Ed

-RRB-

Morgan

Kaufmann

Publishers

Los

Altos

CA

-LCB-

-LSB-

-RSB-

Apt

K.R.

and

Van

Emden

M.H.

-LSB-

-RSB-

Contributions

to

the

Theory

of

Logic

Programming

in

JACM

-LCB-

-LSB-

-RSB-

Beeri

C.

Naqvi

S.

Shmueli

O.

and

Tsur

S.

-LSB-

-RSB-

Sets

and

Negations

in

a

Logic

Database

Language

-LRB-

LDL

-RRB-

MCC

Technical

Report

-LSB-

-RSB-

Chang

C.L.

and

Lee

R.C.T.

-LSB-

-RSB-

Symbolic

Logic

and

Mechanical

Theorem

Proving

Academic

Press

New

York

-LSB-

-RSB-

Chen

W.

-LSB-

-RSB-

A

Theory

of

Modules

Based

on

Second-Order

Logic

in

Proceedings

of

IEEE

Symposium

on

Logic

Programming

San

Francisco

September

pp.

-LCB-

-LSB-

-RSB-

Chen

W.

-LSB-

-RSB-

Modules

for

Logic

Programming

Research

Report

Department

of

Computer

Science

SUNY

at

Stony

Brook

-LSB-

-RSB-

Chen

W.

and

M.

Kifer

-LSB-

-RSB-

Sorts

Types

and

Polymorphism

in

Higher-Order

Logic

Programming

Technical

Report

Department

of

Computer

Science

and

Engineering

Southern

Methodist

University

March

-LSB-

-RSB-

Chen

W.

Kifer

M.

and

Warren

D.S.

-LSB-

-RSB-

HiLog

as

a

Platform

for

Database

Language

-LRB-

or

why

predicate

calculus

is

not

enough

-RRB-

Intl.

Workshop

on

Database

Programming

Languages

Oregon

Coast

OR

June

pp.

-LCB-

-LSB-

-RSB-

Chen

W.

Kifer

M.

and

Warren

D.S.

-LSB-

-RSB-

HiLog

A

First-Order

Semantics

of

Higher-Order

Logic

Programming

Constructs

in

Proceedings

of

North

American

Conf

on

Logic

Programming

-LCB-

-LSB-

-RSB-

Chen

W.

and

Warren

D.S.

-LSB-

-RSB-

C-logic

for

Complex

Objects

in

Proceedings

of

the

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

March

pp.

-LCB-

-LSB-

-RSB-

Church

A.

-LSB-

-RSB-

A

Formulation

of

the

Simple

Theory

of

Types

Journal

of

Symbolic

Logic

pp.

-LCB-

-LSB-

-RSB-

Clocksin

W.F.

and

Mellish

C.S.

-LSB-

-RSB-

Programming

in

Prolog

Springer

Verlag

-LSB-

-RSB-

Dershowitz

N.

and

Manna

Z.

-LSB-

-RSB-

Proving

Termination

with

Multiset

Orderings

in

CACM

Vol

No.

-LSB-

-RSB-

Enderton

H.B.

-LSB-

-RSB-

A

Mathematical

Introduction

to

Logic

Academic

Press

Inc.

-LSB-

-RSB-

Fruehwirth

T.

-LSB-

-RSB-

Type

Inference

by

Program

Transformation

and

Partial

Evaluation

IEEE

Intl.

Conf

on

Computer

Languages

Miami

Beach

FL

pp.

-LCB-

-LSB-

-RSB-

Fruehwirth

T.

-LSB-

-RSB-

Polymorphic

Type

Checking

for

Prolog

in

HiLog

Israel

Conference

on

Artificial

Intelligence

and

Computer

Vision

Tel

Aviv

December

-LSB-

-RSB-

Fruehwirth

T.

and

Warren

D.S.

-LSB-

-RSB-

Putting

HiLog

to

Work

manuscript

SUNY

Stony

Brook

-LSB-

-RSB-

Gelfond

M.

Lifschitz

V.

-LSB-

-RSB-

The

Stable

Model

Semantics

for

Logic

Programming

Logic

Programming

Proceedings

of

the

Fifth

Conference

and

Symposium

MIT

Press

pp.

-LCB-

-LSB-

-RSB-

Goldfarb

W.D.

-LSB-

-RSB-

The

Undecidability

of

the

Second-Order

Unification

Problem

Theoretical

Computer

Science

pp.

-LCB-

-LSB-

-RSB-

Smith

D.A.

Hickey

T.

-LSB-

-RSB-

private

communication

-LSB-

-RSB-

Henkin

L.

-LSB-

-RSB-

Completeness

in

the

Theory

of

Types

Journal

of

Symbolic

Logic

-LSB-

-RSB-

Kifer

M.

and

Lausen

G.

-LSB-

-RSB-

F-Logic

A

Higher-Order

Language

for

Reasoning

about

Objects

Inheritance

and

Scheme

ACM

SIGMOD

Conf

on

Management

of

Data

May

pp.

-LCB-

-LSB-

-RSB-

Kifer

M.

Lausen

G.

and

Wu

J.

-LSB-

-RSB-

Logical

Foundations

of

Object-Oriented

and

FrameBased

Languages

Technical

Report

Department

of

Computer

Science

SUNY

at

Stony

Brook

July

to

appear

in

J.

of

ACM

-LSB-

-RSB-

Kifer

M.

and

Lozinskii

E.L.

-LSB-

-RSB-

A

Logic

for

Reasoning

with

Inconsistency

Journal

of

Automated

Reasoning

to

appear

-LSB-

-RSB-

Kifer

M.

and

Subrahmanian

V.S.

-LSB-

-RSB-

Theory

of

Generalized

Annotated

Logic

Programming

and

its

Applications

Journal

of

Logic

Programming

vol

number

April

pp.

-LCB-

-LSB-

-RSB-

Kifer

M.

and

Wu

J.

A

Logic

for

Object-Oriented

Logic

Programming

-LRB-

Maier

's

O-logic

Revisited

-RRB-

in

Proceedings

of

the

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

March

-LCB-

To

appear

in

JCSS

-LSB-

-RSB-

Krishnamurthy

R.

and

Naqvi

S.

Towards

a

Real

Horn

Clause

Language

MCC

Report

ACA

Austin

TX

-LSB-

-RSB-

Kuper

G.

Logic

Programming

with

Sets

in

Proc

ACM

Conf

on

PODS

San

Diego

pp.

-LCB-

-LSB-

-RSB-

Kuper

G.

An

Extension

of

LPS

to

Arbitrary

Sets

IBM

Research

Report

-LSB-

-RSB-

Kuper

G.

Vardi

M.Y.

A

New

Approach

to

Database

Logic

PODS

-LSB-

-RSB-

Lassez

J.-L.

Maher

M.J.

and

Marriott

K.

-LSB-

-RSB-

Unification

Revisited

in

Foundations

of

Deductive

Databases

and

Logic

Programming

-LRB-

J.

Minker

Ed

-RRB-

Morgan

Kaufmann

Publishers

Los

Altos

CA

pp

-LCB-

-LSB-

-RSB-

Lifschitz

V.

-LSB-

-RSB-

On

the

Declarative

Semantics

of

Logic

Programs

with

Negation

in

Foundations

of

Deductive

Databases

and

Logic

Programming

-LRB-

J.

Minker

Ed

-RRB-

Morgan

Kaufmann

Publishers

Los

Altos

CA

-LCB-

-LSB-

-RSB-

Lloyd

J.W.

-LSB-

-RSB-

Foundations

of

Logic

Programming

-LRB-

Second

Edition

-RRB-

Springer

Verlag

-LSB-

-RSB-

Maida

A.

and

Shapiro

S.

-LSB-

-RSB-

Intensional

Concepts

in

Propositional

Semantic

Networks

Cognitive

Science

-LRB-

-RRB-

pp

-LCB-

-LSB-

-RSB-

Maida

A.

-LSB-

-RSB-

Knowing

Intensional

Individuals

and

Reasoning

about

Knowing

Intensional

Individuals

in

Proc

IJCAI

West

Germany

pp.

-LCB-

-LSB-

-RSB-

Maier

D.

-LSB-

-RSB-

A

Logic

for

Objects

in

Preprints

of

Workshop

on

Foundations

of

Deductive

Database

and

Logic

Programming

ed

Jack

Minker

Washington

DC

August

-LSB-

-RSB-

Martelli

A.

and

Montanari

U.

-LSB-

-RSB-

An

Efficient

Unification

Algorithm

in

ACM

Trans

on

Progr

Lang

and

Systems

-LRB-

-RRB-

pp

-LCB-

-LSB-

-RSB-

Meyer

A.R.

-LSB-

-RSB-

What

Is

a

Model

of

the

Lambda

Calculus

Information

and

Control

-LRB-

-RRB-

pp.

-LCB-

-LSB-

-RSB-

Motro

A.

-LSB-

-RSB-

BAROQUE

A

Browser

for

Relational

Databases

ACM

Trans

on

Office

Information

Systems

-LRB-

-RRB-

pp.

-LCB-

-LSB-

-RSB-

Miller

D.A.

and

Nadathur

G.

-LSB-

-RSB-

Higher-Order

Logic

Programming

in

Proceedings

of

the

Third

International

Conference

on

Logic

Programming

London

United

Kingdom

July

pp.

-LCB-

-LSB-

-RSB-

Maier

D.

Warren

D.S.

-LSB-

-RSB-

Computing

with

Logic

Benjamin/Cummings

Publ.

-LSB-

-RSB-

Montague

R.

-LSB-

-RSB-

The

Proper

Treatment

of

Quantification

in

English

in

Approaches

to

Natural

Languages

K.J.J.

Hintikka

et

al.

-LRB-

ed

-RRB-

Dordrecht

-LCB-

-LSB-

-RSB-

Nadathur

G.

-LSB-

-RSB-

A

Higher-Order

Logic

as

the

Basis

for

Logic

Programming

Ph.D.

Dissertation

University

of

Pennsylvania

June

-LSB-

-RSB-

Naqvi

S.

Tsur

S.

-LSB-

-RSB-

A

Logical

Language

for

Data

and

Knowledge

Bases

Computer

Science

Press

Rockville

MD

-LSB-

-RSB-

Pereira

F.C.N.

and

Warren

D.H.D.

-LSB-

-RSB-

Definite

Clause

Grammars

for

Language

Analysis

A

Survey

of

the

Formalism

and

a

Comparison

with

Augmented

Transition

Networks

Artificial

Intelligence

pp.

-LSB-

-RSB-

Peterson

G.E.

-LSB-

-RSB-

A

Technique

for

Establishing

Completeness

Results

in

Theorem

Proving

with

Equality

SIAM

Journal

of

Computing

pp.

-LCB-

February

-LSB-

-RSB-

Przymusinski

T.C.

-LSB-

-RSB-

On

the

Semantics

of

Stratified

Deductive

Databases

in

Foundations

of

Deductive

Databases

and

Logic

Programming

-LRB-

J.

Minker

Ed

-RRB-

Morgan

Kaufmann

Publishers

Los

Altos

CA

-LCB-

-LSB-

-RSB-

Przymusinski

T.C.

-LSB-

-RSB-

Every

Logic

Program

has

a

Natural

Stratification

and

an

Iterated

Least

Fixed

Point

Model

in

Proc

ACM

PODS

-LSB-

-RSB-

Ramesh

R.

Ramakrishnan

I.V.

and

D.S.

Warren

-LSB-

-RSB-

Automata-Driven

Indexing

of

Prolog

Clauses

Proceedings

of

POPL

January

-LSB-

-RSB-

Ross

A.

-LSB-

-RSB-

A

Procedural

Semantics

for

Well

Founded

Negation

in

Logic

Programs

in

Proc

ACM

PODS

-LSB-

-RSB-

Ross

A.

-LSB-

-RSB-

On

Negation

in

HiLog

in

Proc

ACM

PODS

Denver

CO

May

pp.

-LCB-

-LSB-

-RSB-

Van

Emden

M.H.

and

Kowalski

R.A.

-LSB-

-RSB-

The

Semantics

of

Predicate

Logic

as

a

Programming

Language

in

JACM

-LCB-

-LSB-

-RSB-

Van

Gelder

A.

-LSB-

-RSB-

The

Alternating

Fixpoint

of

Logic

Programs

with

Negation

in

Proc

ACM

PODS

pp.

-LCB-

-LSB-

-RSB-

Van

Gelder

A.

and

Ross

K.

and

Schlipf

J.S.

-LSB-

-RSB-

Unfounded

Sets

and

Well-Founded

Semantics

for

General

Logic

Programs

in

Proc

ACM

PODS

pp.

-LCB-

-LSB-

-RSB-

Warren

D.H.D.

-LSB-

-RSB-

Higher-Order

Extensions

to

Prolog

Are

They

Needed

Machine

Intelligence

-LCB-

-LSB-

-RSB-

Warren

D.H.D.

-LSB-

-RSB-

An

Abstract

Prolog

Instruction

Set

Report

AI

Center

SRI

International

Menlo

Park

CA

October

-LSB-

-RSB-

Wu

J.

-LSB-

-RSB-

private

communication

contextual predicate calculus
database languages
dcg grammars
logic programming

first-order semantics
higher-order logic
modular programming
object-oriented databases
resolution theorem proving