Temporal

Deductive

Databases

Marianne

Baudinet

Universit?e

Libre

de

Bruxellesy

Jan

Chomicki

Kansas

State

Universityz

Pierre

Wolper

Universit?e

de

Li?egex

October

CR

Classification

F.

F.

H.

I.

Abstract

We

survey

a

number

of

approaches

to

the

problem

of

finite

representation

of

infinite

temporal

extensions

Two

of

them

and

Templog

are

syntactical

extensions

of

Datalog

the

third

is

based

on

repetition

and

arithmetic

constraints

We

provide

precise

characterizations

of

the

expressiveness

and

the

computational

complexity

of

these

languages

We

also

describe

query

evaluation

methods

Introduction

In

a

historical

database

the

information

that

is

stored

includes

temporal

attributes

These

attributes

indicate

when

-LRB-

at

what

time

-RRB-

the

information

is

valid

Within

this

context

many

options

are

available

The

temporal

information

can

be

attached

to

small

or

large

chunks

of

data

the

underlying

time

model

can

be

discrete

or

continuous

and

the

time

model

can

be

based

on

time

points

or

on

time

intervals

However

whichever

of

these

options

are

selected

the

choice

of

a

representation

for

the

extension

of

the

temporal

attributes

remains

a

fundamental

issue

To

appear

in

A.

Tansel

J.

Clifford

S.

Gadia

S.

Jajodia

A.

Segev

and

R.

Snodgrass

editors

Temporal

Databases

-LRB-

Benjamin/Cummings

-RRB-

yAddress

Informatique

Avenue

F.D.

Roosevelt

C.P.

Brussels

Belgium

Email

mb@montefiore.ulg.ac.be

zAddress

Department

of

Computing

and

Information

Sciences

Nichols

Hall

Manhattan

KS

Email

chomicki@cis.ksu.edu

xAddress

Institut

Montefiore

Li?ege

Sart-Tilman

Belgium

Email

pw@montefiore.ulg.ac.be

In

the

classical

database

approach

extensions

are

represented

explicitly

that

is

by

the

set

of

values

that

correspond

to

them

For

instance

if

some

fact

is

true

every

day

at

a.m.

its

extension

includes

as

many

time

points

as

there

are

days

on

which

the

fact

is

true

Thus

this

representation

is

only

usable

if

the

number

of

days

is

finite

and

in

practice

if

it

is

not

too

large

An

alternative

is

to

use

an

implicit

representation

from

which

the

extension

can

be

computed

This

chapter

describes

such

implicit

representations

and

their

use

in

historical

databases

We

consider

two

different

implicit

representations

of

temporal

extensions

one

based

on

deductive

rules

and

one

based

on

repetition

and

constraints

To

express

deductively

that

some

information

is

true

every

day

at

a.m.

one

can

say

that

it

is

true

at

some

time

corresponding

to

the

first

occurrence

of

a.m.

at

which

the

information

holds

and

then

specify

that

if

the

information

is

true

at

some

time

t

it

is

true

at

time

t

hours

This

form

of

representation

has

been

studied

since

-LSB-

-RSB-

and

-LSB-

-RSB-

and

is

the

subject

of

Section

An

alternative

representation

of

the

fact

that

some

information

is

true

every

day

at

a.m.

is

to

write

that

it

is

true

at

every

time

point

of

the

form

n

where

corresponds

to

the

first

occurrence

of

a.m.

at

which

the

information

holds

and

n

is

a

variable

ranging

over

the

integers

Furthermore

one

can

limit

the

range

of

the

variable

n

by

introducing

constraints

For

instance

one

can

specify

that

the

temporal

extension

being

considered

consists

of

all

time

points

x

such

that

x

is

of

the

form

and

such

that

x

Section

is

devoted

to

this

representation

which

was

introduced

in

-LSB-

-RSB-

and

further

studied

in

-LSB-

-RSB-

Related

ideas

about

the

use

of

constraints

in

databases

were

presented

in

-LSB-

-RSB-

and

-LSB-

-RSB-

The

main

advantage

of

implicit

representations

is

expressiveness

They

make

the

representation

of

infinite

extensions

possible

and

often

allow

a

more

compact

representation

of

finite

extensions

Expressiveness

is

thus

one

of

our

main

concerns

when

surveying

the

formalisms

we

have

just

outlined

Actually

we

are

concerned

with

two

distinct

notions

of

expressiveness

The

first

concerns

the

extensions

that

can

indeed

be

represented

Following

-LSB-

-RSB-

we

call

it

data

expressiveness

Note

that

data

expressiveness

is

not

an

issue

when

dealing

with

finite

extensions

since

all

finite

extensions

can

be

represented

explicitly

However

infinite

extensions

form

an

uncountable

set

thus

not

all

sets

of

infinite

extensions

are

finitely

representable

Each

particular

formalism

is

able

to

represent

a

specific

set

of

infinite

extensions

This

set

constitutes

the

data

expressiveness

of

the

formalism

The

second

notion

of

expressiveness

we

consider

is

more

akin

to

the

notion

of

expressiveness

usually

considered

in

deductive

databases

it

is

the

expressiveness

of

the

query

language

We

refer

to

this

notion

as

query

expressiveness

-LSB-

-RSB-

Section

gives

precise

definitions

of

these

concepts

Expressiveness

is

not

the

only

issue

Representing

information

is

only

useful

if

it

can

be

queried

with

reasonable

efficiency

Therefore

our

second

concern

when

reviewing

representation

formalisms

for

infinite

temporal

extensions

is

the

complexity

of

evaluating

queries

We

consider

various

query

evaluation

methods

and

we

mostly

focus

on

data

complexity

-LSB-

-RSB-

which

appears

to

be

the

most

important

notion

in

database

problems

Finally

whenever

possible

we

discuss

work

that

is

related

to

our

main

subject

of

concern

either

by

its

goals

or

by

the

techniques

it

uses

Basic

Model

and

Expressiveness

Basic

Model

In

what

follows

we

consider

a

temporal

domain

T

that

is

either

isomorphic

to

the

set

of

natural

numbers

N

-LRB-

Section

-RRB-

or

to

the

set

of

integers

Z

-LRB-

Section

-RRB-

We

then

consider

relations

that

have

any

number

of

non-temporal

data

attributes

and

either

one

-LRB-

Section

-RRB-

or

one

or

more

-LRB-

Section

-RRB-

temporal

attributes

ranging

over

the

temporal

domain

T

A

temporal

database

is

a

finite

collection

of

such

relations

The

extension

of

the

non-temporal

attributes

is

assumed

to

be

represented

explicitly

Our

concern

is

the

representation

of

the

possibly

infinite

extensions

of

the

temporal

attributes

Example

Consider

the

relation

train

schedule

-LRB-

departure

time

arrival

time

-RRB-

that

represents

a

train

schedule

Assuming

a

time

granularity

of

one

minute

an

explicit

representation

of

part

of

its

extension

could

be

as

follows

train

schedule

Expressiveness

definitions

Any

finite

temporal

extension

can

be

represented

as

in

Example

However

if

we

also

consider

the

possibility

of

infinite

extensions

then

the

situation

is

entirely

different

Indeed

it

is

possible

to

devise

formalisms

that

can

represent

infinite

temporal

extensions

but

it

is

not

possible

to

finitely

represent

all

infinite

temporal

extensions

For

instance

let

us

consider

a

relation

with

exactly

one

temporal

argument

and

let

us

assume

that

the

temporal

domain

T

is

the

natural

numbers

Then

the

extension

of

such

a

relation

consists

of

an

sequence

-LRB-

infinite

sequence

whose

members

are

indexed

by

natural

numbers

:-RRB-

of

finite

relations

Therefore

the

number

of

possible

temporal

relations

is

uncountable

and

no

language

with

finite

expressions

can

represent

all

temporal

relations

It

is

then

useful

to

capture

the

expressive

power

of

any

particular

formalism

used

for

representing

temporal

data

We

call

this

the

data

expressiveness

of

the

formalism

We

now

give

precise

definitions

The

number

of

temporal

attributes

is

called

the

temporal

arity

of

a

relation

and

the

number

of

non-temporal

attributes

is

called

the

data

arity

of

a

relation

For

the

sake

of

clarity

and

simplicity

we

consider

databases

consisting

of

a

finite

set

-RCB-

of

predicates

that

we

take

to

be

all

of

temporal

arity

and

of

data

arity

All

the

definitions

given

below

extend

directly

to

more

general

cases

A

temporal

relation

of

temporal

arity

is

a

subset

of

T

namely

the

set

of

time

instants

at

which

the

relation

holds

Definition

A

temporal

database

is

a

function

mapping

every

predicate

in

-RCB-

to

a

subset

of

T

-LRB-

the

set

of

time

instants

at

which

the

predicate

holds

-RRB-

It

is

thus

a

function

in

B

-LRB-

-RCB-

-RRB-

Alternatively

it

can

be

viewed

as

a

function

in

-LRB-

T

-RCB-

-RRB-

which

associates

with

each

time

instant

the

predicates

that

are

true

at

that

time

instant

Notice

that

even

with

just

one

temporal

predicate

-LRB-

-RCB-

being

a

singleton

set

-RRB-

there

are

temporal

databases

all

of

which

can

not

be

finitely

represented

We

thus

introduce

the

following

notion

Definition

The

data

expressiveness

of

a

temporal

database

formalism

is

the

set

of

temporal

databases

-LRB-

functions

in

B

-LRB-

-RCB-

-RRB-

-RRB-

that

can

be

defined

in

this

formalism

As

we

will

see

in

the

following

sections

the

data

expressiveness

of

the

formalisms

we

will

consider

is

in

several

cases

characterized

in

terms

of

ultimately

periodic

sets

Although

in

classical

databases

the

data

expressiveness

is

not

an

issue

-LRB-

because

all

extensions

are

finite

-RRB-

the

expressiveness

of

the

language

for

extracting

data

from

a

database

-LCB-

the

query

language

-LCB-

is

a

very

crucial

feature

-LSB-

-RSB-

For

a

temporal

database

formalism

the

situation

is

identical

and

we

call

this

expressiveness

the

query

expressiveness

to

avoid

any

possible

confusion

with

the

data

expressiveness

A

temporal

-LRB-

yes/no

-RRB-

query

is

a

filter

on

temporal

databases

It

can

be

viewed

as

defining

the

set

of

databases

for

which

it

is

true

Thus

each

set

of

temporal

databases

corresponds

to

a

query

and

since

there

are

databases

there

are

possible

yes/no

queries

All

these

queries

can

not

be

finitely

represented

which

leads

to

the

notion

of

query

expressiveness

Definition

The

query

expressiveness

of

a

temporal

query

language

is

the

class

of

sets

of

temporal

databases

that

can

be

defined

using

expressions

of

this

language

i.e.

those

sets

of

databases

for

which

queries

in

this

language

are

true

When

viewed

as

a

function

in

-LRB-

T

-RCB-

-RRB-

a

temporal

database

is

isomorphic

to

an

infinite

sequence

of

sets

of

predicates

or

equivalently

to

an

infinite

word

on

the

alphabet

-RCB-

In

what

follows

we

will

thus

use

languages

of

infinite

words

to

characterize

the

query

expressiveness

of

various

temporal

query

languages

Deductive

Formalisms

Horn

clauses

with

no

function

symbols

are

a

purely

deductive

framework

in

which

relations

can

be

defined

and

queried

This

Horn-clause

based

language

is

a

restriction

of

logic

programming

that

is

usually

referred

to

as

Datalog

-LSB-

-RSB-

In

this

section

we

discuss

two

approaches

to

representing

temporal

phenomena

using

two

different

syntactic

extensions

of

Datalog

The

first

approach

that

we

consider

is

-LRB-

Datalog

with

one

successor

previously

called

temporal

deductive

databases

-RRB-

-LSB-

-RSB-

a

temporal

language

that

extends

Datalog

by

allowing

every

predicate

to

have

-LRB-

at

most

-RRB-

one

temporal

parameter

in

addition

to

the

usual

data

parameters

The

temporal

parameter

can

be

constructed

using

a

specific

unary

function

symbol

denoting

the

successor

function

and

can

be

viewed

as

being

interpreted

over

the

natural

numbers

The

second

temporal

extension

of

Datalog

that

we

consider

is

the

language

Templog

-LSB-

-RSB-

Templog

is

an

extension

of

logic

programming

to

temporal

logic

It

thus

extends

Datalog

by

allowing

a

restricted

use

of

modal

temporal

operators

in

Horn

clauses

It

has

been

shown

that

and

Templog

although

syntactically

different

and

based

on

different

logics

are

in

fact

equivalent

-LRB-

in

the

sense

that

one

is

a

syntactical

variant

of

the

other

see

subsection

-RRB-

Therefore

we

begin

by

introducing

both

languages

but

present

expressiveness

query

evaluation

and

complexity

results

only

in

the

context

of

even

though

some

of

these

results

were

first

proved

for

Templog

Syntax

For

the

sake

of

completeness

let

us

begin

by

recalling

some

standard

definitions

and

terminology

used

in

logic

programming

and

Datalog

For

further

detail

the

reader

is

referred

to

-LSB-

-RSB-

An

atom

is

a

formula

p

-LRB-

tn

-RRB-

where

p

is

a

predicate

symbol

and

each

ti

is

a

term

-LRB-

in

the

usual

first-order

logic

sense

-RRB-

A

term

or

an

atom

is

said

to

be

ground

if

it

is

variable

free

A

fact

is

a

ground

atom

A

database

is

a

finite

set

of

facts

A

rule

is

a

formula

written

as

A

Bm

-LRB-

in

clausal

form

A

Bm

-RRB-

where

A

Bm

are

atoms

A

is

called

the

head

and

Bm

the

body

of

the

rule

A

logic

program

is

a

finite

set

of

rules

together

with

a

database

A

goal

is

a

formula

written

as

Bm

-LRB-

in

clausal

form

Bm

-RRB-

A

query

is

a

finite

set

of

rules

together

with

a

goal

All

variables

in

rules

and

goals

are

implicitly

universally

quantified

We

distinguish

extensional

database

-LRB-

EDB

-RRB-

and

intensional

database

-LRB-

IDB

-RRB-

predicates

The

EDB

predicates

correspond

to

the

relations

provided

in

the

database

whereas

the

IDB

predicates

correspond

to

the

derived

relations

that

is

those

that

are

defined

by

rules

EDB

predicates

may

thus

appear

in

database

facts

in

bodies

of

rules

and

in

goals

whereas

IDB

predicates

can

only

appear

in

rules

and

goals

and

not

in

database

facts

Datalog

is

the

language

of

function-free

logic

programs

that

is

logic

programs

in

which

the

only

terms

are

constants

or

variables

-LRB-

such

terms

are

called

data

terms

-RRB-

is

an

extension

of

Datalog

in

which

predicates

may

have

a

single

distinguished

parameter

-LRB-

argument

-RRB-

which

is

said

to

be

temporal

in

addition

to

the

usual

data

parameters

Temporal

parameters

are

temporal

terms

which

are

built

from

a

distinguished

constant

variables

and

the

unary

function

symbol

-LRB-

written

in

postfix

-RRB-

For

instance

if

T

is

a

variable

then

T

T

are

temporal

terms

For

the

sake

of

clarity

we

will

write

n

instead

of

-LRB-

-LRB-

-LRB-

-RRB-

-RRB-

-RRB-

-LCB-

z

-RCB-

n

times

and

T

n

instead

of

-LRB-

-LRB-

-LRB-

T

-RRB-

-RRB-

-RRB-

-LCB-

z

-RCB-

n

times

The

set

of

variables

used

to

build

temporal

terms

must

be

disjoint

from

the

set

of

data

variables

Furthermore

temporal

terms

can

not

appear

as

data

parameters

of

predicates

Predicates

having

a

temporal

parameter

are

said

to

be

temporal

Semantics

In

the

general

case

of

logic

programs

the

semantics

of

a

program

P

can

be

characterized

by

its

least

Herbrand

model

MP

which

is

the

intersection

of

all

its

Herbrand

models

-LSB-

-RSB-

MP

contains

all

the

ground

atoms

that

are

logical

consequences

of

P

and

is

usually

infinite

when

the

program

contains

temporal

terms

MP

can

also

be

obtained

by

the

-LRB-

possibly

infinite

-RRB-

iteration

of

the

mapping

TP

defined

as

follows

Let

I

denote

a

Herbrand

interpretation

TP

-LRB-

I

-RRB-

fA

j

A

is

a

fact

in

P

or

A

Ak

is

a

ground

instance

of

a

rule

in

P

and

I

I

Ak

Ig

The

mapping

TP

corresponds

to

one

step

of

ground

inference

from

I

The

successive

iterations

of

TP

are

defined

as

follows

T

P

T

k

P

TP

-LRB-

T

kP

-RRB-

T!P

-LSB-

k

T

kP

T!P

is

the

least

fixpoint

of

TP

which

we

denote

lfp

-LRB-

TP

-RRB-

It

coincides

with

the

least

Herbrand

model

of

P

that

is

lfp

-LRB-

TP

-RRB-

MP

-LSB-

-RSB-

For

Datalog

the

same

semantics

apply

However

since

Datalog

does

not

allow

function

symbols

in

programs

every

Herbrand

model

of

a

program

is

finite

and

hence

MP

is

finite

The

successive

iterations

of

TP

thus

also

constitute

an

effective

method

for

computing

MP

This

method

is

known

as

bottom-up

evaluation

For

the

situation

is

similar

except

for

the

presence

of

temporal

terms

Since

the

set

of

ground

temporal

terms

is

isomorphic

to

the

integers

the

least

model

MP

is

often

infinite

Hence

bottom-up

evaluation

is

not

guaranteed

to

terminate

for

Example

The

following

rules

schedule

the

meetings

of

a

professor

with

his

students

meets

-LRB-

T

X

-RRB-

meets

first

-LRB-

T

X

-RRB-

meets

-LRB-

T

Y

-RRB-

follows

-LRB-

X

Y

-RRB-

meets

-LRB-

T

X

-RRB-

Let

us

consider

a

database

containing

the

following

facts

meets

first

-LRB-

emma

-RRB-

follows

-LRB-

emma

kathy

-RRB-

follows

-LRB-

kathy

emma

-RRB-

The

rules

can

be

used

to

derive

the

following

infinitely

many

facts

from

the

database

meets

-LRB-

emma

-RRB-

meets

-LRB-

kathy

-RRB-

meets

-LRB-

emma

-RRB-

meets

-LRB-

kathy

-RRB-

Notice

that

these

facts

form

a

periodic

set

when

viewed

as

a

function

of

the

integers

but

that

their

period

depends

on

the

contents

of

the

database

Example

Consider

the

following

rules

governing

the

schedule

of

backups

in

a

distributed

system

backup

-LRB-

T

X

-RRB-

backup

-LRB-

T

X

-RRB-

backup

-LRB-

T

Y

-RRB-

dependent

-LRB-

X

Y

-RRB-

backup

-LRB-

T

X

-RRB-

The

first

rule

states

that

a

backup

on

a

machine

should

be

taken

every

hours

The

second

rule

requires

that

the

backups

should

be

taken

simultaneously

on

all

dependent

machines

-LRB-

e.g.

sharing

files

-RRB-

Notice

that

whatever

database

these

rules

are

applied

to

the

derived

facts

will

again

be

periodic

but

this

time

the

period

will

not

depend

on

the

contents

of

the

database

Templog

Syntax

Templog

is

a

syntactic

extension

of

logic

programming

based

on

temporal

logic

It

is

built

from

a

version

of

temporal

logic

that

views

time

as

isomorphic

to

the

natural

numbers

-LSB-

-RSB-

In

this

language

predicates

can

vary

with

time

but

the

time

point

they

refer

to

is

defined

implicitly

by

temporal

operators

rather

than

by

an

explicit

temporal

argument

The

three

temporal

operators

used

in

Templog

are

-LRB-

next

-RRB-

which

refers

to

the

next

time

instant

-LRB-

always

-RRB-

which

refers

to

the

present

and

all

the

future

time

instants

and

-LRB-

eventually

-RRB-

the

dual

of

which

refers

to

the

present

or

to

some

future

time

instant

In

Templog

is

allowed

both

in

the

head

and

in

the

body

of

clauses

is

allowed

only

in

the

head

of

clauses

or

outside

entire

clauses

and

is

allowed

only

in

the

body

of

clauses

-LRB-

possibly

nested

with

conjunction

-RRB-

The

abstract

syntax

of

Templog

clauses

can

be

provided

formally

as

follows

In

these

syntax

rules

A

stands

for

an

atom

N

for

a

next-atom

that

is

an

atom

preceded

by

a

finite

number

of

's

denotes

an

empty

formula

and

the

symbols

and

j

belong

to

the

metalanguage

Body

B

j

A

j

j

B

j

Initial

clause

IC

N

B

j

B

Permanent

clause

PC

-LRB-

N

B

-RRB-

Program

clause

C

IC

j

PC

Goal

clause

G

B

Notice

that

there

are

two

types

of

clauses

in

Templog

initial

clauses

which

express

a

statement

that

holds

at

the

initial

time

and

permanent

clauses

which

express

a

statement

that

holds

at

any

time

instant

The

semantics

of

a

temporal

logic

formula

is

provided

with

respect

to

a

temporal

interpretation

D

that

is

an

infinite

sequence

Di

of

classical

first-order

interpretations

-LRB-

one

classical

interpretation

for

each

time

instant

-RRB-

In

Templog

only

predicate

symbols

have

time-varying

meanings

constants

-LRB-

and

function

symbols

-RRB-

are

assumed

to

be

independent

of

time

The

semantics

of

the

temporal

logic

operators

used

in

Templog

is

the

following

-LRB-

j

Di

F

means

F

is

true

in

Di

-RRB-

j

Di

F

iff

j

Di

F

j

Di

iff

for

every

j

N

j

Di

j

F

j

Di

iff

for

some

j

N

j

Di

j

F

Example

The

program

of

Example

is

formulated

in

Templog

as

follows

-LRB-

meets

-LRB-

X

-RRB-

meets

first

-LRB-

X

-RRB-

-RRB-

-LRB-

meets

-LRB-

Y

-RRB-

follows

-LRB-

X

Y

-RRB-

meets

-LRB-

X

-RRB-

-RRB-

The

facts

are

written

as

follows

in

Templog

meets

first

-LRB-

emma

-RRB-

follows

-LRB-

emma

kathy

-RRB-

follows

-LRB-

kathy

emma

-RRB-

They

are

initial

clauses

thus

expressing

statements

that

hold

at

the

initial

time

Therefore

we

need

an

additional

rule

to

express

the

fact

that

the

predicate

follows

does

not

vary

with

time

-LRB-

so

what

is

true

at

the

initial

time

instant

remains

true

forever

-RRB-

follows

-LRB-

X

Y

-RRB-

follows

-LRB-

X

Y

-RRB-

Just

like

classical

logic

programs

Templog

programs

have

semantics

that

can

be

expressed

in

terms

of

a

least

-LRB-

temporal

-RRB-

Herbrand

model

and

in

terms

of

the

least-fixpoint

of

a

mapping

similar

to

TP

-LSB-

-RSB-

and

Templog

related

The

fragment

of

Templog

that

disallows

the

use

of

in

the

body

of

clauses

and

the

use

of

initial

clauses

with

in

the

head

can

easily

be

seen

to

be

a

syntactic

variant

of

-LRB-

The

role

played

in

this

fragment

of

Templog

by

the

temporal

operators

is

played

in

by

the

temporal

parameters

-RRB-

It

has

also

been

shown

that

any

Templog

program

can

be

transformed

into

an

equivalent

program

-LSB-

-RSB-

The

reverse

translation

that

is

from

to

Templog

is

also

straightforward

-LSB-

-RSB-

The

only

interesting

point

of

this

translation

concerns

time-independent

predicates

in

which

each

require

a

specific

Templog

clause

stating

this

time-independence

as

illustrated

in

Example

above

by

the

predicate

follows

In

what

follows

we

will

only

consider

and

all

results

that

we

will

provide

also

hold

for

Templog

-LRB-

or

were

actually

initially

established

for

Templog

-RRB-

Expressiveness

As

described

in

Section

there

are

two

distinct

aspects

to

the

expressiveness

of

a

database

formalism

data

expressiveness

which

captures

the

class

of

temporal

relations

definable

in

the

formalism

and

query

expressiveness

which

captures

the

class

of

definable

queries

Let

us

recall

from

Section

that

when

discussing

expressiveness

we

limit

our

attention

to

databases

consisting

of

a

finite

set

-RCB-

of

predicates

of

temporal

arity

and

data

arity

We

call

Monadic

the

fragment

of

in

which

all

predicates

satisfy

these

conditions

that

is

are

monadic

and

temporal

Notice

that

for

Templog

this

condition

corresponds

to

predicates

having

no

parameter

at

all

Such

temporal

predicates

are

also

called

temporal

propositions

and

the

corresponding

fragment

of

Templog

is

called

propositional

Templog

This

restriction

to

parameters

of

temporal

arity

and

data

arity

is

not

a

real

limitation

because

every

program

can

be

reformulated

in

this

way

by

instantiating

its

data

parameters

in

all

possible

ways

with

the

data

constants

appearing

in

the

program

The

size

of

the

resulting

program

is

at

most

polynomial

in

the

number

of

such

constants

but

exponential

in

the

arity

of

its

atoms

Data

expressiveness

The

temporal

database

represented

by

a

Monadic

program

P

corresponds

exactly

to

the

least

Herbrand

model

MP

of

the

program

As

stated

below

it

turns

out

that

every

such

model

is

ultimately

periodic

Definition

A

function

f

defined

on

N

is

ultimately

periodic

with

period

-LRB-

k

l

-RRB-

where

k

and

l

if

for

all

i

k

we

have

f

-LRB-

i

l

-RRB-

f

-LRB-

i

-RRB-

The

least

Herbrand

model

MP

of

a

Monadic

program

can

be

seen

as

a

function

that

maps

every

time

instant

i

to

the

set

of

predicates

that

are

true

at

time

i.

Theorem

-LSB-

-RSB-

The

least

Herbrand

model

MP

of

a

Monadic

program

P

is

ultimately

periodic

with

period

-LRB-

c

k

l

-RRB-

such

that

k

l

-RCB-

j

and

c

is

the

maximum

depth

of

a

ground

temporal

term

in

P

Since

the

converse

is

straightforward

namely

every

periodic

function

in

-LRB-

N

-RCB-

-RRB-

can

be

represented

as

a

program

the

ultimately

periodic

sets

characterize

exactly

the

data

expressiveness

of

This

result

can

be

used

to

determine

whether

an

infinite

set

of

natural

numbers

can

be

represented

as

a

program

For

example

the

set

j

i

N

g

is

aperiodic

and

thus

can

not

be

represented

in

Query

expressiveness

At

first

thought

it

might

seem

that

since

and

Templog

are

languages

whose

programs

and

goals

are

formulas

of

a

logic

their

expressivenes

is

simply

the

expressiveness

of

their

underlying

logic

This

is

not

so

The

intuitive

reason

for

this

is

that

the

deduction

hidden

in

the

rules

intervenes

to

add

to

the

expressiveness

of

the

underlying

logics

Such

a

phenomenon

has

been

observed

for

standard

logic

programming

-LRB-

Remember

that

even

though

a

logic

program

is

a

logic

formula

formulating

its

semantics

requires

a

minimization

operation

-LCB-

the

least

fixpoint

-RRB-

Indeed

it

has

been

shown

that

for

instance

one

could

express

in

Datalog

queries

that

are

not

expressible

in

first-order

logic

for

instance

queries

about

the

transitive

closure

of

a

given

relation

-LSB-

-RSB-

On

the

other

hand

not

all

queries

expressible

in

first-order

logic

can

be

expressed

in

Datalog

Chandra

and

Harel

have

shown

in

-LSB-

-RSB-

that

the

query

expressiveness

of

standard

Datalog

corresponds

to

the

expressiveness

of

a

positive

fragment

of

fixpoint

logic

on

finite

structures

namely

the

fragment

in

which

a

formula

consists

of

a

least

fixpoint

operator

applied

to

a

positive

existential

formula

The

query

expressiveness

of

-LRB-

propositional

-RRB-

Templog

was

first

studied

in

-LSB-

-RSB-

using

an

approach

similar

to

Chandra

and

Harel

's

In

a

way

the

results

for

Templog

parallel

those

for

Datalog

However

they

relate

Templog

queries

to

fixpoint

extensions

of

temporal

logic

and

to

finite

automata

on

infinite

words

For

the

sake

of

uniformity

we

present

these

results

using

Monadic

rather

than

propositional

Templog

The

query

expressiveness

of

a

language

has

been

defined

in

Section

to

be

the

class

of

sets

of

temporal

databases

that

can

be

defined

by

queries

in

that

language

Let

us

see

what

it

means

for

a

query

to

define

a

set

of

databases

We

consider

a

query

Q

consisting

of

rules

and

of

the

ground

goal

u

-LRB-

i

-RRB-

where

u

is

a

distinguished

IDB

predicate

and

i

a

natural

number

-LRB-

denoting

a

time

instant

-RRB-

Assuming

that

-RCB-

png

is

the

set

of

EDB

predicates

occurring

in

Q

we

can

look

at

Q

as

being

parameterized

by

-RCB-

Indeed

the

query

Q

characterizes

the

set

of

temporal

interpretations

of

-RCB-

that

make

u

-LRB-

i

-RRB-

true

Notice

that

we

consider

here

infinite

databases

Example

The

query

consisting

of

the

rules

u

-LRB-

T

-RRB-

p

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

together

with

the

goal

u

-LRB-

-RRB-

is

parameterized

by

the

set

fpg

One

can

show

that

for

any

ground

i

u

-LRB-

i

-RRB-

will

hold

exactly

when

the

database

contains

a

fact

expressing

that

p

holds

at

time

i

or

at

some

time

instant

later

than

i

or

equivalently

when

holds

at

time

i

The

predicate

u

can

thus

be

seen

as

defining

the

temporal

operator

eventually.This

simulation

of

eventually

is

actually

used

in

the

proof

that

Templog

is

equivalent

to

its

fragment

-LRB-

c.f.

Section

-RRB-

Example

Let

us

consider

the

query

consisting

of

the

rules

u

-LRB-

T

-RRB-

q

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

p

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

together

with

the

goal

u

-LRB-

i

-RRB-

for

some

ground

i

One

can

show

that

this

query

will

hold

exactly

when

the

database

is

such

that

p

holds

from

time

i

and

on

until

q

holds

This

corresponds

to

the

temporal

logic

formula

p

U

q

holding

at

time

i.

-LRB-

U

denotes

the

operator

until

whose

semantics

is

defined

as

follows

j

Di

F

U

G

iff

for

some

j

i

j

Dj

G

and

for

all

k

such

that

i

k

j

j

Dk

F

-RRB-

One

can

thus

view

the

above

query

as

defining

the

temporal

operator

until

As

Example

illustrates

-LRB-

or

Templog

-RRB-

is

able

to

express

a

temporal

logic

operator

until

which

is

known

to

be

inexpressible

in

temporal

logic

with

and

-LSB-

-RSB-

This

is

analogous

to

the

observation

that

Datalog

is

able

to

express

non

firstorder

concepts

such

as

the

transitive

closure

Example

-LSB-

-RSB-

The

predicate

u

defined

by

the

rules

below

holds

exactly

when

p

holds

an

even

number

of

time

instants

later

u

-LRB-

T

-RRB-

p

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

One

can

show

that

the

predicate

u

can

be

seen

as

the

result

of

applying

to

p

a

temporal

operator

that

is

the

dual

of

the

operator

even

which

was

shown

by

Wolper

to

be

inexpressible

in

temporal

logic

-LSB-

-RSB-

It

is

expressible

however

in

extensions

of

temporal

logic

with

either

fixpoint

quantifiers

or

finite-automaton

operators

The

expressiveness

of

Monadic

queries

is

related

by

the

following

result

to

the

expressiveness

of

temporal

logic

with

fixpoint

quantifiers

named

TL

and

defined

by

Vardi

in

-LSB-

-RSB-

Theorem

-LSB-

-RSB-

The

query

expressiveness

of

Monadic

is

equivalent

to

the

expressiveness

of

the

fragment

of

the

temporal

fixpoint

calculus

TL

that

contains

only

positive

formulas

and

least-fixpoint

operators

This

result

means

that

there

are

formulas

of

temporal

logic

that

are

not

expressible

in

Expressing

all

of

temporal

logic

in

TL

can

require

the

use

of

greatest

fixpoints

or

the

alternation

of

a

greatest

and

a

least

fixpoint

-LSB-

-RSB-

Example

-LSB-

-RSB-

A

consequence

of

this

theorem

is

that

the

operator

-LRB-

always

-RRB-

can

not

be

defined

in

Monadic

because

corresponds

in

TL

to

a

greatest-fixpoint

formula

It

is

thus

impossible

to

write

a

query

that

will

hold

exactly

when

p

holds

In

particular

the

obvious

candidate

p

-LRB-

T

-RRB-

q

-LRB-

T

-RRB-

p

-LRB-

T

-RRB-

does

not

do

the

job

because

it

makes

q

true

whenever

p

is

true

and

p

always

true

Moreover

no

query

can

assert

a

fact

about

an

EDB

predicate

as

the

above

query

does

Notice

however

that

the

dual

of

namely

which

corresponds

in

TL

to

a

positive

least-fixpoint

formula

is

expressible

in

Monadic

c.f.

Example

Because

temporal

logic

is

particularly

suitable

for

defining

infinite

sequences

it

is

customary

to

relate

its

expressiveness

to

languages

of

infinite

words

or

to

finite

automata

on

infinite

words

-LRB-

for

comprehensive

recent

reviews

of

those

see

-LSB-

-RSB-

-RRB-

Such

a

relation

has

also

been

established

for

propositional

Templog

or

equivalently

Monadic

Let

us

recall

that

a

temporal

database

specifies

for

each

time

instant

which

predicates

hold

It

can

thus

be

seen

as

a

function

from

N

-LRB-

or

-RRB-

to

-RCB-

or

equivalently

as

an

infinite

word

an

word

over

the

alphabet

-RCB-

The

languages

of

interest

here

are

the

regular

languages

defined

as

follows

Definition

An

language

L

is

finitely

regular

if

there

is

a

regular

language

such

that

L

can

be

obtained

by

extending

the

words

of

to

infinite

words

in

all

possible

ways

Theorem

-LSB-

-RSB-

Monadic

queries

correspond

to

the

class

of

finitely

regular

languages

The

correspondence

described

in

Theorem

is

only

completely

accurate

when

programs

allow

EDB

predicates

to

appear

negated

in

the

body

of

rules

-LRB-

but

this

is

a

technicality

-RRB-

Propositional

temporal

logic

with

the

operators

and

also

U

is

known

to

have

the

same

expressiveness

as

the

class

of

star-free

regular

languages

-LSB-

-RSB-

The

classes

of

finitely

regular

languages

and

of

star-free

languages

are

incomparable

Therefore

Monadic

is

in

some

respects

more

powerful

and

in

some

respects

less

powerful

than

propositional

temporal

logic

-LRB-

with

and

U

-RRB-

Query

evaluation

We

discuss

here

various

theoretical

and

practical

issues

involved

in

the

evaluation

of

queries

We

consider

here

only

finite

programs

in

particular

the

set

of

facts

is

finite

We

start

by

defining

two

distinct

modes

of

query

evaluation

recognition

-LRB-

providing

a

yes-no

answer

-RRB-

and

generation

-LRB-

providing

all

the

answers

-RRB-

Thereafter

we

turn

to

the

complexity

of

query

evaluation

We

focus

on

data

complexity

and

show

that

the

data

complexity

of

query

evaluation

for

is

PSPACE-complete

Therefore

unless

PTIME

PSPACE

it

is

impossible

to

evaluate

all

queries

in

polynomial

time

Next

after

reviewing

various

evaluation

methods

including

bottom-up

and

top-down

we

present

two

approaches

to

dealing

with

infinite

query

answers

The

first

more

traditional

is

concerned

with

checking

query

safety

that

is

testing

whether

a

query

has

a

finite

answer

The

second

provides

a

framework

for

finitely

representing

the

entire

answer

as

well

as

efficiently

computing

such

a

representation

Finally

we

discuss

polynomial

time

computable

queries

Modes

of

query

evaluation

Assume

P

Z

-LSB-

D

is

a

logic

program

where

Z

is

a

set

of

rules

and

D

is

a

database

and

G

a

goal

Then

Q

Z

-LSB-

f

Gg

is

a

query

Definition

An

answer

substitution

to

the

query

Q

on

the

database

D

is

a

mapping

of

variables

in

G

to

ground

terms

such

that

P

j

G

-LRB-

where

G

is

the

result

of

applying

to

G

-RRB-

Alternatively

we

could

require

that

j

MP

G

where

MP

is

the

least

Herbrand

model

of

P

An

answer

is

the

set

of

all

answer

substitutions

If

G

is

already

ground

then

the

answer

is

either

empty

or

contains

a

single

substitution

with

an

empty

domain

We

call

the

first

case

a

no

answer

and

the

second

case

a

yes

answer

Definition

Recognition

-LRB-

yes-no

query

evaluation

-RRB-

is

a

computation

of

the

yes-no

answer

to

a

query

containing

a

ground

goal

Generation

-LRB-

all-answers

query

evaluation

-RRB-

is

a

computation

of

the

entire

query

answer

-LRB-

or

a

finite

representation

of

the

query

answer

-RRB-

Computational

complexity

Following

-LSB-

-RSB-

we

study

data

complexity

that

is

complexity

as

a

function

of

the

number

of

tuples

in

the

database

assuming

that

the

query

and

the

database

schema

are

fixed

Theorem

-LSB-

-RSB-

Under

the

data

complexity

measure

recognition

is

PSPACE

complete

for

queries

The

issue

of

generation

is

somewhat

more

complicated

as

a

query

answer

may

be

infinite

We

will

come

back

to

it

later

in

this

section

after

having

introduced

formal

tools

for

the

finite

representation

of

such

answers

Evaluation

procedures

The

ideal

query

evaluation

procedure

for

should

have

the

following

properties

ffl

be

applicable

to

both

recognition

and

generation

ffl

terminate

when

the

query

answer

is

finite

-LRB-

in

particular

for

yes/no

answers

-RRB-

ffl

scale

down

work

in

polynomial

time

for

interesting

subsets

of

ffl

scale

up

work

also

for

arbitrary

logic

programs

-LRB-

of

course

in

this

case

termination

of

even

yes-no

query

evaluation

can

not

be

guaranteed

as

logic

programs

can

encode

arbitrary

Turing

machine

computations

-LSB-

-RSB-

-RRB-

With

these

criteria

in

mind

we

will

review

various

query

evaluation

techniques

of

logic

programs

Unfortunately

to

our

knowledge

no

single

method

satisfies

all

these

criteria

Bottom-up

Bottom-up

query

evaluation

is

implemented

by

a

repeated

application

of

the

TP

operator

introduced

in

Section

It

terminates

when

no

new

facts

are

computed

Thus

if

the

least

Herbrand

model

of

a

program

is

infinite

as

may

very

well

happen

for

-LRB-

see

the

examples

-RRB-

bottom-up

evaluation

does

not

terminate

It

has

though

some

redeeming

characteristics

it

works

equally

well

for

recognition

and

generation

and

is

applicable

to

an

arbitrary

logic

program

It

is

interesting

to

note

that

various

optimization

methods

developed

for

logic

programs

-LSB-

-RSB-

fail

in

general

to

guarantee

the

termination

of

queries

and

may

even

introduce

additional

sources

of

non-termination

-LSB-

-RSB-

Bottom-up

evaluation

fails

to

terminate

even

for

the

simplest

programs

that

use

the

function

symbol

in

an

essential

way

thus

it

does

not

scale

down

In

-LSB-

-RSB-

we

introduced

depth-bounded

bottom-up

evaluation

a

variant

of

bottom-up

evaluation

in

which

facts

containing

too

large

terms

-LRB-

the

bound

on

term

size

is

calculated

from

the

text

of

the

program

-RRB-

are

simply

discarded

without

losing

completeness

This

method

can

be

used

for

both

recognition

and

generation

terminates

for

queries

with

finite

answers

and

scales

down

Unfortunately

it

does

not

scale

up

and

is

incomplete

for

arbitrary

logic

programs

Top-down

Top-down

evaluation

-LRB-

SLD-resolution

-LSB-

-RSB-

or

TSLD-resolution

for

Templog

-LSB-

-RSB-

-RRB-

in

its

practical

incarnations

e.g.

the

Prolog

evaluation

strategy

introduces

additional

problems

with

termination

Guaranteeing

termination

through

memoing

-LSB-

-RSB-

breadth-first

search

or

ground

loop

checking

is

possible

for

Datalog

programs

but

not

for

programs

with

function

symbols

in

particular

programs

Similarly

to

the

bottom-up

case

a

test

of

whether

the

depth

of

terms

does

not

exceed

a

certain

bound

can

be

added

to

top-down

evaluation

in

order

to

obtain

termination

Once

this

is

achieved

top-down

evaluation

can

be

used

for

both

recognition

and

generation

On

the

other

hand

the

presence

of

a

test

on

term

depth

will

make

such

a

method

incomplete

for

arbitrary

logic

programs

Joyner

's

method

In

-LSB-

-RSB-

Joyner

proposed

a

resolution

procedure

that

uses

atom

ordering

and

clause

condensation

-LRB-

which

is

essentially

tableau

minimization

-LSB-

-RSB-

-RRB-

This

procedure

has

several

attractive

properties

First

it

is

a

complete

recognition

procedure

for

arbitrary

logic

programs

-LRB-

In

fact

it

is

also

a

refutation

procedure

for

arbitrary

first-order

formulas

-RRB-

Second

it

is

terminating

for

queries

with

finite

answers

and

does

not

require

for

termination

that

a

bound

-LRB-

calculated

from

the

text

of

the

program

-RRB-

be

supplied

However

if

is

combined

with

SLD-resolution

the

resulting

procedure

is

incomplete

For

completeness

seems

to

require

the

ability

to

resolve

rules

among

themselves

It

is

not

clear

how

to

efficiently

implement

such

a

facility

Infinite

answers

Assume

that

Z

is

a

set

of

rules

and

G

a

goal

Definition

A

query

Q

Z

-LSB-

f

Gg

is

relatively

safe

-LSB-

-RSB-

for

a

-LRB-

finite

-RRB-

database

D

if

the

answer

to

Q

on

D

is

finite

A

query

is

universally

safe

-LSB-

-RSB-

if

it

is

relatively

safe

for

any

finite

database

Safe

queries

are

well-behaved

they

will

not

fail

to

terminate

just

trying

to

print

all

the

answer

substitutions

So

it

is

important

to

be

able

to

effectively

test

for

both

kinds

of

safety

Theorem

-LSB-

-RSB-

Under

the

data

complexity

measure

testing

relative

safety

of

queries

is

PSPACE-complete

Theorem

-LSB-

-RSB-

Testing

universal

safety

of

queries

is

decidable

How

can

we

deal

with

unsafe

queries

Most

of

the

time

such

queries

make

perfect

sense

In

Example

one

could

ask

the

query

when

does

Emma

meet

the

professor

This

query

has

an

infinite

answer

Least

Herbrand

models

of

programs

can

be

finitely

represented

using

the

notion

of

relational

specification

-LSB-

-RSB-

The

same

construct

can

be

used

to

finitely

represent

infinite

query

answers

Definition

A

relational

specification

S

is

a

triple

-LRB-

T

W

B

-RRB-

where

T

is

a

finite

set

of

ground

temporal

terms

W

is

a

finite

set

of

ground

rewrite

rules

both

sides

of

which

are

ground

temporal

terms

and

B

is

a

finite

database

The

terms

in

T

are

said

to

be

representative

and

B

is

called

the

primary

database

We

write

t

W

to

indicate

that

the

ground

term

t

can

be

rewritten

to

using

the

rules

in

W

and

no

more

rewritings

are

applicable

-LRB-

is

a

canonical

form

of

t

-RRB-

Definition

A

relational

specification

S

-LRB-

T

W

B

-RRB-

represents

the

least

Herbrand

model

MP

of

a

program

P

if

the

three

following

conditions

hold

ffl

For

every

temporal

fact

p

-LRB-

t

a

-RRB-

MP

there

is

a

term

T

such

that

t

W

and

p

-LRB-

a

-RRB-

B.

ffl

For

every

term

T

such

that

p

-LRB-

a

-RRB-

B

and

every

fact

p

-LRB-

t

a

-RRB-

such

that

t

W

p

-LRB-

t

a

-RRB-

MP

ffl

The

sets

of

non-temporal

facts

in

MP

and

B

are

identical

Example

A

relational

specification

S

-LRB-

T

W

B

-RRB-

representing

the

least

Herbrand

model

of

Example

may

look

as

follows

T

W

B

ffollows

-LRB-

emma

kathy

-RRB-

follows

-LRB-

kathy

emma

-RRB-

meets

first

-LRB-

emma

-RRB-

meets

-LRB-

emma

-RRB-

meets

-LRB-

kathy

-RRB-

g

Let

us

assume

that

Q

Z

-LSB-

f

Gg

is

a

query

D

is

a

database

and

S

-LRB-

T

W

B

-RRB-

is

a

relational

specification

representing

MZ

-LSB-

D

Then

Q

can

be

evaluated

just

by

evaluating

G

in

S

without

any

reference

to

the

program

Z

-LSB-

D

If

G

is

a

ground

atom

then

it

is

rewritten

using

the

rules

in

W

until

no

more

rewrites

are

possible

and

then

it

is

checked

whether

the

resulting

atom

is

in

B

If

G

is

not

ground

the

query

G

is

evaluated

in

S

which

is

just

a

finite

relational

database

There

will

be

finitely

many

answer

substitutions

each

representing

possibly

infinitely

many

original

answer

substitutions

The

correspondence

between

those

two

types

of

substitutions

are

captured

by

the

rewrite

rules

so

the

rewrite

rules

themselves

should

be

a

part

of

the

query

answer

In

the

case

of

a

relational

specification

representing

MP

has

a

particularly

simple

form

The

set

W

contains

exactly

one

rewrite

rule

namely

k

l

c

k

c

where

-LRB-

k

l

-RRB-

is

a

period

of

MP

-LRB-

see

subsection

-RRB-

and

c

is

the

maximum

depth

of

a

ground

temporal

term

in

a

fact

from

P

Theorem

-LSB-

-RSB-

A

relational

specification

representing

MP

for

a

program

P

can

be

constructed

in

polynomial

space

-LRB-

under

the

data

complexity

measure

-RRB-

Thus

in

terms

of

the

complexity

class

constructing

a

finite

representation

of

the

entire

possibly

infinite

answer

to

a

query

is

not

harder

than

providing

a

yes/no

answer

The

size

of

a

relational

specification

may

however

be

exponential

Tractable

In

-LSB-

-RSB-

we

showed

how

to

use

the

notion

of

a

relational

specification

to

define

fragments

of

for

which

queries

can

be

evaluated

in

polynomial

time

-LRB-

under

the

data

complexity

assumption

-RRB-

Theorem

-LSB-

-RSB-

The

size

of

a

relational

specification

representing

MP

is

polynomial

if

and

only

if

the

specification

can

be

computed

in

polynomial

time

Once

we

have

a

relational

specification

representing

MP

we

can

use

it

to

answer

queries

Therefore

if

we

can

prove

that

for

a

fragment

of

the

size

of

relational

specifications

is

polynomial

then

polynomial

time

evaluation

of

queries

will

also

be

guaranteed

In

-LSB-

-RSB-

we

identified

several

interesting

fragments

of

with

this

property

Negation

Horn

clause

languages

such

as

are

said

to

be

monotonic

because

they

can

express

only

monotonic

inferences

In

the

area

of

temporal

reasoning

this

means

for

instance

that

frame

axioms

which

state

that

everything

remains

the

same

unless

explicitly

modified

can

not

be

expressed

A

simple

extension

of

namely

Stratified

remedies

this

problem

A

stratified

program

can

be

seen

as

divided

into

layers

or

strata

It

allows

the

use

of

negation

in

the

body

of

rules

but

in

such

a

way

that

there

never

be

any

recursion

through

negation

In

other

words

the

predicates

that

may

appear

negated

in

the

body

of

a

rule

in

a

layer

are

those

that

are

defined

in

layers

lower

than

For

a

complete

discussion

of

stratification

and

formal

semantics

of

programs

with

stratified

negation

we

refer

the

reader

to

-LSB-

-RSB-

Stratified

programs

have

a

distinguished

Herbrand

model

the

perfect

model

and

query

answers

can

be

defined

with

respect

to

this

model

Example

Assuming

a

database

of

facts

that

define

the

relation

promoted

the

following

program

with

negation

is

stratified

position

-LRB-

T

X

P

-RRB-

position

-LRB-

T

X

P

-RRB-

promoted

-LRB-

T

X

P

-RRB-

position

-LRB-

T

X

P

-RRB-

position

-LRB-

T

X

P

-RRB-

promoted

-LRB-

T

X

P

-RRB-

Adding

stratified

negation

to

results

in

a

significant

increase

in

query

expressiveness

while

keeping

data

expressiveness

and

complexity

of

query

evaluation

unchanged

Data

Expressiveness

Intuitively

stratified

negation

does

not

enhance

the

data

expressiveness

because

the

complement

of

a

periodic

temporal

database

is

also

a

periodic

temporal

database

Theorem

-LSB-

-RSB-

For

a

Monadic

Stratified

program

P

the

perfect

model

MP

is

ultimately

periodic

Query

Expressiveness

Having

proven

that

the

query

expressiveness

of

Datalog

corresponds

to

the

expressiveness

of

the

positive

existential

fragment

of

fixpoint

logic

on

finite

structures

Chandra

and

Harel

suggested

that

extending

Datalog

with

stratified

negation

would

lift

its

expressiveness

to

the

level

of

the

full

fixpoint

logic

on

finite

structures

-LSB-

-RSB-

However

Kolaitis

-LSB-

-RSB-

showed

using

of

result

of

Dahlhaus

's

-LSB-

-RSB-

that

Datalog

enhanced

with

stratified

negation

is

still

strictly

weaker

than

fixpoint

logic

on

finite

structures

We

have

pointed

out

similarities

between

the

query

expressiveness

results

of

Datalog

and

those

of

Monadic

However

for

the

extensions

with

stratified

negation

the

similarity

does

not

carry

over

Indeed

the

expressiveness

of

Propositional

Templog

or

Monadic

queries

was

shown

to

correspond

to

the

positive

fragment

of

the

temporal

fixpoint

calculus

TL

but

extending

with

stratified

negation

does

lift

the

expressiveness

of

queries

up

to

the

level

of

the

full

temporal

fixpoint

calculus

-LSB-

-RSB-

This

calculus

is

also

known

to

correspond

exactly

to

the

full

class

of

regular

languages

Theorem

-LSB-

-RSB-

Monadic

Stratified

queries

correspond

to

the

class

of

all

regular

languages

and

to

the

full

temporal

fixpoint

calculus

TL

Example

For

instance

p

can

be

expressed

using

double

negation

in

Stratified

as

follows

np

-LRB-

T

-RRB-

:p

-LRB-

T

-RRB-

np

-LRB-

T

-RRB-

np

-LRB-

T

-RRB-

u

-LRB-

T

-RRB-

np

-LRB-

T

-RRB-

Complexity

of

Query

Evaluation

Theorem

-LSB-

-RSB-

Under

the

data

complexity

measure

the

recognition

problem

is

PSPACE-complete

for

Stratified

Datalogqueries

A

relational

specification

representing

a

perfect

model

of

a

Stratified

program

can

be

constructed

in

polynomial

space

Relatively

little

is

known

about

query

evaluation

methods

for

Stratified

Clearly

a

general

method

for

evaluating

stratified

logic

programs

like

SLDNF-resolution

-LSB-

-RSB-

can

be

used

but

it

will

not

guarantee

termination

The

method

used

in

the

proof

of

Theorem

is

rather

impractical

although

it

achieves

the

upper

complexity

bound

Constraint-Based

Formalisms

A

database

tuple

t

of

schema

R

-LRB-

An

-RRB-

assigns

values

-LRB-

an

-RRB-

to

the

attributes

of

R.

Alternatively

it

can

be

viewed

as

imposing

equality

constraints

on

the

values

of

these

attributes

An

an

Recently

the

idea

has

emerged

that

this

view

of

tuples

as

constraints

could

be

generalized

to

other

than

equality

constraints

and

could

be

used

to

finitely

represent

data

with

an

infinite

extension

In

this

section

we

discuss

two

major

lines

of

work

based

on

this

idea

First

we

present

the

work

of

-LSB-

-RSB-

which

is

specifically

oriented

towards

the

representation

of

temporal

data

and

more

specifically

of

periodic

temporal

data

Next

we

turn

to

-LSB-

-RSB-

and

-LSB-

-RSB-

which

study

a

variety

of

applications

of

tuples

viewed

as

constraints

Linear

Repeating

Points

and

Constraints

Definition

The

framework

proposed

in

-LSB-

-RSB-

generalizes

the

notion

of

relational

database

by

allowing

the

tuples

to

contain

an

arbitrary

number

of

temporal

attributes

in

addition

to

the

usual

data

attributes

The

temporal

attributes

represent

periodic

sets

of

integers

namely

linear

repeating

points

Moreover

the

repeating

points

appearing

in

the

tuples

of

a

relation

can

be

constrained

with

linear

inequalities

Definition

A

linear

repeating

point

-LRB-

lrp

-RRB-

is

a

set

fx

-LRB-

n

-RRB-

Z

j

x

-LRB-

n

-RRB-

an

b

with

a

b

in

Z

and

n

ranging

from

up

to

in

Zg

where

Z

denotes

the

set

of

integers

Such

a

set

is

simply

denoted

by

an

b.

Notice

that

an

lrp

is

either

an

infinite

periodic

set

of

integers

or

a

singleton

-LRB-

if

a

-RRB-

For

instance

the

lrp

denotes

the

infinite

periodic

set

of

integers

f

g.

Constraints

on

the

temporal

attributes

are

conjunctions

of

atomic

constraints

We

distinguish

between

general

and

restricted

constraints

General

constraints

are

built

from

atomic

constraints

that

are

arbitrary

linear

equalities

or

inequalities

between

at

most

two

temporal

attributes

Restricted

constraints

are

built

from

equalities

and

inequalities

also

between

at

most

two

temporal

attributes

but

in

which

the

coefficients

of

temporal

attributes

are

-LRB-

this

restriction

will

be

useful

for

the

computation

of

operations

on

relations

-RRB-

More

specifically

if

Ti

and

Tj

are

temporal

attributes

restricted

atomic

constraints

are

of

the

form

Ti

Tj

a

Ti

Tj

a

Ti

-LRB->=-RRB-

a

or

Ti

a

Definition

Let

T

denote

the

collection

of

lrps

and

D

a

collection

of

nontemporal

data

values

A

generalized

tuple

of

temporal

arity

m

and

data

arity

is

an

element

of

T

m

D

together

with

-LRB-

general

or

restricted

-RRB-

constraints

on

the

temporal

components

In

other

words

a

general

tuple

of

temporal

arity

m

and

data

arity

is

a

ground

tuple

of

the

form

-LRB-

amnm

bm

d

-RRB-

with

constraints

-LRB-

Tm

-RRB-

where

ffl

each

aini

bi

-LRB-

i

m

-RRB-

is

an

lrp

-LRB-

we

assume

that

the

variables

ni

are

all

distinct

-RRB-

ffl

each

dk

-LRB-

k

-RRB-

is

a

data

constant

from

D

ffl

constraints

-LRB-

Tm

-RRB-

denotes

a

finite

set

of

constraints

over

the

temporal

attributes

Tm

Such

a

generalized

tuple

is

in

fact

a

finite

representation

of

a

possibly

infinite

set

of

ground

tuples

namely

the

set

f

-LRB-

tm

d

-RRB-

j

-LRB-

-RRB-

tm

-LRB-

amnm

bm

-RRB-

and

constraints

-LRB-

tm

-RRB-

is

satisfied

g

The

constraints

constraints

-LRB-

tm

-RRB-

in

a

generalized

tuple

thus

define

a

subset

of

the

cartesian

product

of

the

lrp

's

-LRB-

-RRB-

-LRB-

amnm

bm

-RRB-

namely

the

subset

of

tuples

that

are

actually

in

the

database

Example

For

instance

the

generalized

tuple

-LRB-

-RRB-

constrained

by

the

equality

represents

the

infinite

set

of

tuples

f

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

g

which

is

a

subset

of

the

cartesian

product

-LRB-

-RRB-

-LRB-

-RRB-

Example

The

generalized

tuple

of

the

relation

train

schedule

train

schedule

li?ege

brussels

with

represents

the

following

infinite

set

of

point-tuples

-LRB-

ground

tuples

-RRB-

f

-LRB-

li?ege

brussels

-RRB-

j

-LRB-

-RRB-

-LRB-

-RRB-

and

Definition

A

generalized

relation

is

a

finite

set

of

generalized

tuples

of

a

given

schema

Example

The

generalized

relation

action

below

describes

the

timing

of

some

activities

of

two

robots

action

It

must

be

noted

that

generalized

relations

with

an

arbitrary

number

of

temporal

attributes

are

allowed

Generalized

relations

with

one

temporal

attribute

correspond

to

pointbased

temporal

data

-LRB-

a

tuple

holds

at

specific

time

points

-RRB-

Generalized

relations

with

two

temporal

attributes

correspond

to

interval-based

temporal

data

-LRB-

a

tuple

holds

on

an

interval

specified

by

two

time

points

-RRB-

Generalized

relations

with

more

than

two

temporal

attributes

have

no

immediate

intuitive

meaning

but

are

useful

as

intermediate

steps

in

computations

For

instance

when

concatenating

temporal

intervals

the

mid-point

at

which

the

intervals

are

joined

appears

as

a

third

temporal

attribute

before

being

projected

out

Data

Expressiveness

The

concept

of

data

expressiveness

we

have

defined

in

Section

applies

directly

to

generalized

databases

It

is

quite

interesting

that

the

data

expressiveness

of

a

generalized

relation

with

just

one

temporal

attribute

is

exactly

that

of

that

is

ultimately

periodic

sets

-LRB-

see

Section

-RRB-

This

result

can

be

established

by

relating

generalized

relations

to

Presburger

arithmetic

which

in

the

monadic

case

also

defines

eventually

periodic

sets

We

consider

purely

temporal

generalized

relations

-LRB-

no

data

attributes

-RRB-

Also

it

is

necessary

to

distinguish

between

generalized

relations

with

restricted

and

with

general

constraints

since

they

lead

to

distinct

expressiveness

results

Definition

ffl

A

relation

of

temporal

arity

m

-LRB-

and

data

arity

-RRB-

is

weak-lrp-definable

if

it

can

be

defined

by

a

generalized

relation

with

m

temporal

attributes

using

only

restricted

constraints

ffl

A

relation

of

temporal

arity

m

-LRB-

and

data

arity

-RRB-

is

lrp-definable

if

it

can

be

defined

by

a

generalized

relation

with

m

temporal

attributes

using

general

constraints

Definition

An

m-ary

relation

on

the

integers

is

said

to

be

Presburger-definable

if

it

can

be

defined

by

a

Presburger

arithmetic

formula

with

m

free

variables

Note

the

following

relation

between

Presburger-definability

and

eventually

periodic

sets

-LRB-

which

can

be

found

in

e.g.

-LSB-

-RSB-

-RRB-

Proposition

A

unary

relation

that

is

a

set

of

integers

is

Presburger-definable

if

and

only

if

it

is

ultimately

periodic

The

data

expressiveness

results

for

generalized

relations

are

then

the

following

Theorem

-LSB-

-RSB-

ffl

A

unary

relation

on

the

integers

is

weak-lrp-definable

if

and

only

if

it

is

Presburgerdefinable

ffl

A

binary

predicate

on

the

integers

is

lrp-definable

if

and

only

if

it

is

Presburgerdefinable

The

result

can

not

be

generalized

to

relations

of

temporal

arity

greater

than

since

the

constraints

used

in

generalized

databases

involve

at

most

two

temporal

attributes

However

for

temporal

data

only

relations

of

temporal

arity

or

are

of

practical

significance

Query

Languages

and

Their

Evaluation

In

-LSB-

-RSB-

the

problem

of

querying

generalized

databases

is

addressed

by

first

showing

that

all

the

usual

relational

algebra

operations

can

be

computed

on

generalized

relations

and

then

by

applying

these

operations

to

the

evaluation

of

first-order

queries

-LSB-

-RSB-

gives

a

detailed

description

of

how

the

various

relational

algebra

operations

are

computed

on

generalized

databases

with

restricted

constraints

Of

all

these

operations

the

trickiest

and

the

one

requiring

that

only

restricted

constraints

be

used

is

projection

In

a

classical

relational

database

the

projection

of

a

relation

on

some

of

its

columns

simply

requires

forsaking

the

other

columns

For

generalized

databases

before

forsaking

a

temporal

column

its

constraints

have

to

be

projected

This

means

that

variables

have

to

be

eliminated

from

an

integer

constraint

system

For

real

constraints

this

could

be

done

by

a

simple

algorithm

that

eliminates

variables

by

computing

linear

combinations

of

the

constraints

But

this

is

not

adequate

for

integer

constraints

The

solution

described

in

-LSB-

-RSB-

is

that

before

computing

a

projection

database

tuples

be

normalized

that

is

that

they

be

converted

to

tuples

in

which

all

the

lrp

's

occurring

as

temporal

attributes

have

the

same

periodicity

-LRB-

and

all

the

constraints

on

the

temporal

attributes

of

the

tuple

have

the

coefficient

since

all

constraints

are

restricted

-RRB-

Only

thereafter

can

the

projection

be

carried

out

with

algorithms

that

are

appropriate

for

the

real

numbers

The

complexity

of

computing

the

relational

algebra

operations

is

also

studied

in

-LSB-

-RSB-

The

general

result

is

that

with

a

few

restrictions

everything

can

be

done

in

polynomial

time

The

first

restriction

is

that

only

normalized

relations

be

considered

-LRB-

that

is

relations

where

all

lrp

's

have

the

same

period

-RRB-

The

second

is

that

the

complexity

be

measured

for

a

family

of

databases

in

which

the

schema

of

the

relations

is

fixed

and

only

the

number

of

tuples

can

vary

This

measure

is

called

fixed-schema

complexity

the

case

in

which

the

schema

can

also

vary

being

called

general

complexity

The

exact

results

are

the

following

Theorem

-LSB-

-RSB-

The

projection

selection

union

intersection

difference

and

join

of

-LRB-

a

-RRB-

normalized

generalized

relation

-LRB-

s

-RRB-

can

be

computed

in

PTIME

under

the

fixed-schema

complexity

measure

Theorem

-LSB-

-RSB-

Under

the

general

complexity

measure

the

projection

selection

union

intersection

and

join

of

-LRB-

a

-RRB-

normalized

generalized

relation

-LRB-

s

-RRB-

can

be

computed

in

PTIME

The

difference

of

two

normalized

generalized

relations

can

be

computed

in

EXP

TIME

Note

that

the

exponential

complexity

of

computing

the

difference

of

two

generalized

relations

is

only

due

to

the

complexity

of

taking

the

negation

of

a

boolean

combination

of

constraints

and

writing

the

result

in

disjunctive

normal

form

Once

algorithms

for

computing

the

relational

algebra

operations

are

known

one

can

consider

the

evaluation

of

first-order

queries

The

natural

first-order

language

to

use

with

generalized

databases

is

a

two-sorted

first-order

logic

One

sort

is

temporal

points

-LRB-

interpreted

over

the

integers

-RRB-

the

other

is

generic

We

refer

to

the

number

of

temporal

parameters

of

a

predicate

as

its

temporal

arity

and

to

its

number

of

nontemporal

arguments

of

a

predicate

as

its

data

arity

The

language

includes

one

interpreted

predicate

of

temporal

arity

and

data

arity

namely

and

any

number

of

uninterpreted

predicates

In

the

spirit

of

what

is

done

in

relational

databases

function

symbols

are

not

used

on

the

generic

sort

On

the

temporal

sort

one

interpreted

function

can

be

used

namely

the

successor

function

Arbitrary

quantification

is

allowed

on

both

temporal

and

nontemporal

variables

Example

The

following

formula

of

this

two-sorted

first-order

query

language

refers

to

the

data

of

Example

It

expresses

the

fact

that

there

are

robots

x

and

y

and

time

instants

and

such

that

if

x

performs

over

a

time

interval

-LSB-

-RSB-

of

length

at

least

then

y

does

not

perform

any

task

over

any

subinterval

of

that

time

interval

-LSB-

-LRB-

action

-LRB-

X

-RRB-

-RRB-

oe

action

-LRB-

Y

Z

-RRB-

-RSB-

It

turns

out

that

the

data-complexity

-LSB-

-RSB-

of

evaluating

such

queries

on

a

database

is

PTIME

Indeed

if

the

query

is

fixed

the

schema

of

the

database

must

also

be

fixed

and

one

can

use

the

complexity

results

obtained

for

fixed-schema

complexity

Since

all

operations

are

polynomial

under

that

measure

one

has

the

following

Theorem

-LSB-

-RSB-

Determining

the

truth

of

yes/no

queries

on

a

normalized

generalized

database

can

be

done

in

PTIME

under

the

data

complexity

measure

Another

interesting

question

to

consider

is

the

query

expressiveness

of

the

language

we

have

just

outlined

and

its

relation

to

the

query

expressiveness

of

It

turns

out

that

in

the

monadic

case

-LRB-

one

temporal

argument

-RRB-

this

language

corresponds

exactly

to

temporal

logic

with

the

four

temporal

operators

U

-LSB-

-RSB-

The

query

expressiveness

of

this

language

is

that

of

star-free

regular

languages

-LSB-

-RSB-

which

is

incomparable

to

the

expressiveness

of

-LRB-

finitely

regular

languages

-RRB-

and

strictly

weaker

than

that

of

Stratified

-LRB-

the

whole

class

of

regular

languages

-RRB-

Linear

Repeating

Points

and

Deductive

Languages

The

fact

that

for

generalized

databases

the

query

expressiveness

of

a

first-order

language

is

incomparable

to

that

of

a

deductive

language

such

as

suggests

that

studying

the

combination

of

generalized

databases

and

deductive

languages

could

be

fruitful

Such

a

study

was

undertaken

in

-LSB-

-RSB-

The

deductive

language

that

is

considered

there

is

similar

to

with

the

following

differences

Each

predicate

can

have

more

than

one

temporal

parameter

Constraint

atoms

that

is

atoms

of

the

form

or

where

and

are

temporal

terms

can

appear

in

the

body

of

clauses

Notice

also

that

temporal

terms

are

constructed

from

temporal

variables

the

constant

and

the

successor

function

as

in

but

also

the

predecessor

function

This

is

simply

because

in

generalized

databases

the

temporal

domain

has

been

taken

to

be

the

set

of

all

integers

whereas

in

the

temporal

domain

is

the

set

of

natural

numbers

Example

Let

us

consider

the

following

extensional

relation

course

stating

that

the

database

course

is

taught

every

Monday

morning

from

until

We

assume

that

time

is

at

midnight

some

Monday

morning

and

that

the

time

unit

is

one

hour

-LRB-

so

one

week

is

time

units

-RRB-

course

database

The

extension

of

the

course

relation

is

thus

the

infinite

set

of

ground

tuples

of

the

form

-LRB-

database

-RRB-

such

that

-LRB-

-RRB-

-LRB-

-RRB-

and

The

fact

that

database

problem

sessions

are

given

right

after

the

course

and

every

other

day

thereafter

can

be

represented

as

follows

in

our

deductive

language

by

the

derived

-LRB-

intensional

-RRB-

predicate

problems

problems

-LRB-

database

-RRB-

course

-LRB-

database

-RRB-

problems

-LRB-

database

-RRB-

problems

-LRB-

database

-RRB-

The

-LRB-

model-theoretic

and

fixpoint

-RRB-

semantics

of

the

language

are

defined

analogously

to

that

of

This

language

is

in

fact

very

expressive

since

it

can

express

at

least

all

primitive

recursive

predicates

A

consequence

of

this

is

that

in

general

there

is

no

hope

of

efficiently

evaluating

queries

expressed

in

this

language

However

as

is

shown

in

-LSB-

-RSB-

the

situation

can

be

different

when

the

query

is

evaluated

on

a

generalized

database

The

basic

idea

is

that

when

the

intensional

database

on

which

the

query

is

evaluated

is

a

generalized

database

the

evaluation

can

be

done

a

generalized-tuple-at-a-time

rather

than

a

tuple-at-a-time

The

consequence

of

this

is

that

the

evaluation

can

terminate

even

when

computing

an

infinite

extension

In

the

absence

of

constraints

evaluating

queries

a

generalized-tuple-at-a-time

will

always

terminate

This

is

easy

to

understand

since

in

that

case

one

is

only

dealing

with

repeating

points

and

the

evaluation

can

be

viewed

as

a

computation

in

modulo

arithmetic

and

hence

on

a

finite

domain

In

the

presence

of

constraints

termination

depends

on

whether

the

constraints

are

strengthened

or

weakened

by

the

application

of

the

deductive

rules

In

the

first

case

termination

will

occur

in

the

latter

case

nothing

can

be

said

in

general

Example

Let

us

consider

the

naive

bottom-up

evaluation

of

the

predicate

problems

defined

in

Example

It

can

be

done

by

operating

directly

on

generalized

tuples

-LRB-

representing

possibly

infinite

sets

of

ground

tuples

-RRB-

rather

than

operating

a

tuple

at

a

time

One

obtains

the

following

sequence

of

generalized

tuples

-LRB-

we

omit

the

data

argument

database

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

after

which

the

evaluation

stops

since

no

new

points

are

added

to

the

extension

of

the

predicate

Indeed

-LRB-

-RRB-

-LRB-

-LRB-

-RRB-

-LRB-

-RRB-

-RRB-

is

a

set

of

tuples

of

integers

contained

in

a

previously

obtained

set

of

tuples

The

deductive

language

we

have

just

discussed

is

also

studied

in

-LSB-

-RSB-

However

there

the

study

is

without

any

connection

to

generalized

databases

of

linear

repeating

points

The

main

result

that

is

established

is

a

closed

form

for

Datalog

queries

over

integer

order

However

this

closed

form

is

only

obtained

in

a

restricted

case

which

does

not

allow

the

use

of

incrementation

over

recursion

It

should

be

noted

that

this

restriction

implies

that

periodic

sets

are

not

definable

Finally

-LSB-

-RSB-

studies

the

complexity

of

query

evaluation

for

various

constraint

programming

languages

among

which

is

the

language

described

in

this

section

Not

surprisingly

the

result

is

that

this

problem

is

undecidable

-LRB-

in

fact

r.e.

complete

-RRB-

Constraint

Databases

-LSB-

-RSB-

presents

a

general

study

of

constraints

in

databases

The

general

idea

is

similar

to

the

one

used

in

the

generalized

databases

of

-LSB-

-RSB-

a

generalized

database

is

a

set

of

generalized

tuples

each

of

which

is

a

set

of

constraints

The

query

language

is

then

a

traditional

query

language

augmented

with

constraints

This

general

framework

is

then

applied

to

several

specific

forms

of

constraints

and

of

query

languages

-LRB-

both

first-order

and

deductive

-RRB-

The

families

of

constraints

that

are

considered

are

Polynomial

constraints

on

the

reals

-LRB-

constraints

p

-LRB-

xn

-RRB-

or

p

-LRB-

xn

-RRB-

where

p

is

a

polynomial

in

xn

-RRB-

Order

constraints

on

the

rationals

that

is

constraints

of

the

form

u

v

u

v

u

v

u

v

where

u

and

v

are

variables

or

constants

Equality

constraints

on

the

integers

that

is

constraints

of

the

form

u

v

or

u

v

Boolean

constraints

that

is

constraints

of

the

form

s

t

where

s

and

t

are

terms

of

a

boolean

algebra

The

query

languages

that

are

considered

are

the

relational

calculus

Datalog

and

inflationary

Datalog

with

negation

all

extended

with

constraints

but

without

the

operator

The

paper

then

shows

that

for

various

combinations

of

constraint

formalisms

and

query

languages

the

bottom-up

evaluation

of

queries

is

of

reasonable

data-complexity

More

precisely

depending

on

the

chosen

constraint

and

query

languages

the

complexity

ranges

from

NC

to

PTIME

Related

Work

In

-LSB-

-RSB-

Templog

is

seen

as

an

instance

of

the

Constraint

Logic

Programming

schema

-LSB-

-RSB-

This

paper

gives

an

elegant

description

of

TSLD-resolution

as

resolution

enhanced

with

linear

equation

solving

In

-LSB-

-RSB-

a

different

semantics

for

Datalog

is

proposed

with

a

view

towards

temporal

applications

Every

fact

that

belongs

to

the

least

Herbrand

model

of

a

Datalog

program

P

is

labelled

with

the

numbers

of

the

iterations

of

the

TP

operator

in

which

it

can

be

derived

The

totality

of

such

facts

corresponds

in

a

natural

way

to

a

temporal

interpretation

thus

temporal

logic

is

suggested

as

a

query

language

If

the

set

of

facts

derived

in

the

iteration

i

is

denoted

by

Di

then

clearly

Di

ae

Di

for

all

i

This

restricts

considerably

the

range

of

infinite

temporal

databases

that

can

be

represented

using

this

framework

In

fact

only

databases

with

period

-LRB-

n

-RRB-

-LRB-

where

a

single

state

repeats

itself

indefinitely

-RRB-

can

be

represented

of

the

examples

in

our

paper

fits

this

pattern

There

is

however

a

clear

correspondence

between

the

above

approach

and

inflationary

temporal

deductive

databases

-LSB-

-RSB-

a

fragment

of

admitting

polynomial

time

query

evaluation

Moreover

many

temporal

logic

queries

can

be

directly

expressed

in

-LRB-

see

Section

-RRB-

and

all

such

queries

can

be

expressed

in

Stratified

-LRB-

Section

-RRB-

In

-LSB-

-RSB-

Datalog

with

negation

is

also

discussed

However

the

semantics

of

negation

is

inflationary

which

is

different

from

the

semantics

of

stratified

negation

-LRB-

Section

-RRB-

It

is

not

difficult

to

see

though

that

fixpoint

queries

which

have

the

same

expressive

power

as

Datalog

with

inflationary

negation

-LSB-

-RSB-

can

be

expressed

in

Stratified

Chen

and

Hsiang

-LSB-

-RSB-

have

proposed

an

extension

of

logic

programming

that

is

related

to

temporal

deductive

languages

Indeed

in

-LSB-

-RSB-

they

generalize

the

kinds

of

terms

that

can

appear

in

the

atoms

of

Horn

clauses

to

what

they

call

terms

which

finitely

denote

-LRB-

potentially

infinite

-RRB-

regular

sets

of

terms

They

develop

a

sound

and

complete

unification

algorithm

for

terms

and

show

that

logic

programs

with

terms

can

be

translated

into

finite

standard

logic

programs

However

they

point

out

that

programming

with

terms

can

avoid

some

non-termination

problems

encountered

with

standard

logic

programs

This

phenomenon

is

similar

to

the

one

we

have

described

in

Section

for

deductive

languages

over

databases

of

lrp

's

It

also

appears

in

-LSB-

-RSB-

where

logic

programs

over

temporal

terms

-LRB-

programs

-RRB-

are

transformed

into

logic

programs

over

sets

of

terms

in

order

to

obtain

finitely

computable

least

models

Formalisms

for

the

definition

of

infinite

periodic

sets

were

proposed

in

-LSB-

-RSB-

-LRB-

manysorted

logic

with

term

declarations

-RRB-

and

in

-LSB-

-RSB-

-LRB-

algebraic

term

representations

-RRB-

of

these

approaches

however

made

a

connection

to

logic

programming

We

should

also

mention

that

as

well

as

Stratified

has

been

generalized

to

the

case

of

multiple

unary

function

symbols

in

-LSB-

-RSB-

These

languages

have

applications

to

planning

It

is

interesting

to

note

that

many

techniques

carry

over

from

to

these

languages

in

particular

the

framework

for

finite

representation

of

infinite

query

answers

For

the

sake

of

completeness

let

us

mention

that

a

number

of

other

programming

languages

based

on

temporal

logic

have

been

proposed

in

the

literature

-LSB-

BFG

-RSB-

These

language

are

quite

diverse

They

are

based

on

different

subsets

of

temporal

logic

and

use

a

variety

of

execution

mechanisms

In

fact

one

can

distinguish

two

major

types

of

execution

mechanisms

defining

two

major

families

either

executing

a

formula

amounts

to

imperatively

constructing

a

model

for

this

formula

-LRB-

the

imperative

languages

-RRB-

or

the

execution

of

a

program

is

a

refutation

proof

allowing

the

inference

of

logical

consequences

of

the

program

-LRB-

languages

based

on

the

logic

programming

paradigm

like

Templog

-RRB-

The

early

Tempura

language

of

-LSB-

-RSB-

belongs

to

the

first

-LRB-

imperative

-RRB-

family

It

is

based

on

a

subset

of

interval

temporal

logic

whose

formulas

can

be

interpreted

as

traditional

imperative

programs

In

logical

terms

executing

a

Tempura

formula

-LRB-

program

-RRB-

amounts

to

building

a

model

for

that

formula

The

languages

of

-LSB-

BFG

-RSB-

also

belong

to

the

imperative

family

although

they

are

based

on

a

fragment

of

linear-time

temporal

logic

in

which

programs

are

formulas

stating

conditions

to

be

satisfied

in

the

future

with

respect

to

conditions

on

the

past

For

these

imperative

languages

the

expressiveness

is

directly

related

to

the

expressiveness

of

the

underlying

fragment

of

temporal

logic

Indeed

since

executing

a

program

is

just

building

a

model

of

this

program

no

deduction

engine

intervenes

to

enhance

the

expressive

power

In

-LSB-

-RSB-

modal

extensions

of

-LRB-

Horn

clause

-RRB-

logic

programming

are

considered

One

such

extension

is

the

THLP

language

also

described

in

-LSB-

-RSB-

which

is

equivalent

to

a

fragment

of

Templog

The

expressiveness

of

THLP

is

thus

identical

to

that

of

and

hence

to

that

of

Templog

In

-LSB-

-RSB-

an

extension

of

classical

logic

programming

distinct

from

Templog

is

proposed

This

language

is

based

on

a

different

subset

of

temporal

logic

can

only

be

applied

to

entire

clauses

and

the

only

operators

allowed

in

the

body

and

in

the

head

of

clauses

are

and

the

corresponding

operator

for

the

past

A

proof

method

is

sketched

for

this

language

but

it

is

unclear

how

it

could

be

used

as

the

basis

of

an

execution

mechanism

and

of

operational

semantics

for

the

language

The

only

semantics

defined

for

this

language

is

its

logical

semantics

which

does

not

provide

a

sufficient

basis

for

the

formal

study

of

the

language

's

expressiveness

Conclusions

The

languages

described

in

this

survey

show

that

expressive

temporal

databases

are

possible

within

simple

and

elegant

frameworks

A

natural

question

is

whether

these

frameworks

can

be

made

practical

A

first

issue

is

the

ease

of

use

It

is

unlikely

that

users

can

be

convinced

to

express

data

or

queries

in

the

precise

languages

that

have

been

described

here

However

these

languages

are

a

good

theoretical

basis

and

reference

for

more

user-oriented

languages

Such

user-oriented

languages

would

probably

combine

features

of

the

deductive

and

constraint

oriented

formalisms

A

second

consideration

is

the

ease

of

implementation

which

is

a

syntactic

subset

of

Prolog

seems

easier

to

implement

than

the

other

languages

However

an

implementation

using

an

existing

Prolog

system

could

be

too

inefficient

for

for

database

purposes

Moroever

the

termination

of

query

evaluation

could

not

be

guaranteed

Templog

requires

at

least

the

implementation

of

TSLD-resolution

and

linear

repeating

points

require

the

implementation

of

a

complete

set

of

new

relational

algebra

operators

This

means

unfortunately

that

implementation

on

top

of

an

existing

database

system

is

not

really

feasible

In

conclusion

we

view

deductive

and

constraint

temporal

databases

as

developments

that

have

fundamentally

modified

what

can

be

expressed

in

temporal

databases

However

building

systems

that

implement

these

ideas

in

a

usable

way

is

still

at

present

a

challenging

research

program

References

-LSB-

-RSB-

K.R.

Apt

H.A.

Blair

and

A.

Walker

Towards

a

Theory

of

Declarative

Knowledge

In

J.

Minker

editor

Foundations

of

Deductive

Databases

and

Logic

Programming

pages

-LCB-

Morgan

Kaufmann

-LSB-

-RSB-

M.

Abadi

and

Z.

Manna

Temporal

Logic

Programming

Journal

of

Symbolic

Computation

-LRB-

-RRB-

September

-LSB-

-RSB-

H.

Andreka

and

I.

Nemeti

The

Generalised

Completeness

of

Horn

Predicate

Logic

as

a

Programming

Language

Acta

Cybernetica

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

K.R.

Apt

Logic

Programming

In

Jan

van

Leeuwen

editor

Handbook

of

Theoretical

Computer

Science

volume

B

chapter

pages

-LCB-

Elsevier/MIT

Press

-LSB-

-RSB-

A.V.

Aho

and

J.D.

Ullman

Universality

of

Data

Retrieval

Languages

In

ACM

SIGACT-SIGPLAN

Symposium

on

Principles

of

Programming

Languages

-LSB-

-RSB-

S.

Abiteboul

and

V.

Vianu

Procedural

and

Declarative

Database

Update

Languages

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

-LSB-

-RSB-

M.

Baudinet

Logic

Programming

Semantics

Techniques

and

Applications

PhD

thesis

Stanford

University

February

-LSB-

-RSB-

M.

Baudinet

Temporal

Logic

Programming

is

Complete

and

Expressive

In

ACM

SIGACT-SIGPLAN

Symposium

on

Principles

of

Programming

Languages

-LSB-

-RSB-

M.

Baudinet

On

the

Expressiveness

of

Temporal

Logic

Programming

Submitted

September

-LSB-

-RSB-

M.

Baudinet

A

Simple

Proof

of

the

Completeness

of

Temporal

Logic

Programming

In

L.

Fari

nas

del

Cerro

and

M.

Penttonen

editors

Intensional

Logics

for

Programming

Oxford

University

Press

-LSB-

BFG

-RSB-

H.

Barringer

M.

Fisher

D.

Gabbay

G.

Gough

and

R.

Owens

MetateM

a

Framework

for

Programming

in

Temporal

Logic

Technical

report

Dept.

of

Computer

Science

University

of

Manchester

-LSB-

-RSB-

M.

Baudinet

M.

Ni?ezette

and

P.

Wolper

On

the

Representation

of

Infinite

Temporal

Data

and

Queries

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

-LSB-

-RSB-

Ch

Brzoska

Temporal

Logic

Programming

and

its

Relation

to

Constraint

Logic

Programming

In

International

Logic

Programming

Symposium

-LSB-

-RSB-

A.K.

Chandra

and

D.

Harel

Structure

and

Complexity

of

Relational

Queries

Journal

of

Computer

and

System

Sciences

-LCB-

-LSB-

-RSB-

A.K.

Chandra

and

D.

Harel

Horn

Clause

Queries

and

Generalizations

Journal

of

Logic

Programming

-LRB-

-RRB-

-LCB-

April

-LSB-

-RSB-

H.

Chen

and

J.

Hsiang

Logic

Programming

With

Recurrence

Domains

In

International

Colloquium

on

Automata

Languages

and

Programming

SpringerVerlag

LNCS

-LSB-

-RSB-

J.

Chomicki

Functional

Deductive

Databases

Query

Processing

in

the

Presence

of

Limited

Function

Symbols

PhD

thesis

Rutgers

University

New

Brunswick

New

Jersey

January

Also

Laboratory

for

Computer

Science

Research

Technical

Report

-LSB-

-RSB-

J.

Chomicki

Polynomial-Time

Computable

Queries

in

Temporal

Deductive

Databases

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

Nashville

Tennessee

April

-LSB-

-RSB-

J.

Chomicki

Depth-Bounded

Bottom-Up

Evaluation

of

Logic

Programs

Submitted

June

-LSB-

-RSB-

J.

Chomicki

and

T.

Imieli?nski

Temporal

Deductive

Databases

and

Infinite

Objects

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

Austin

Texas

March

-LSB-

-RSB-

J.

Chomicki

and

T.

Imieli?nski

Relational

Specifications

of

Infinite

Query

Answers

In

ACM

SIGMOD

International

Conference

on

Management

of

Data

Portland

Oregon

May

-LSB-

-RSB-

J.

Chomicki

and

T.

Imieli?nski

Finite

Representation

of

Infinite

Query

Answers

ACM

Transactions

on

Database

Systems

To

appear

-LSB-

-RSB-

J.

Cox

K.

McAloon

and

C.

Tretkoff

Computational

Complexity

and

Constraint

Logic

Programming

Languages

Technical

report

Department

of

Computer

and

Information

Science

Brooklyn

College

of

C.U.N.Y

To

appear

in

Annals

of

Mathematics

and

Artificial

Intelligence

-LSB-

-RSB-

E.

Dahlhaus

Skolem

Normal

Forms

concerning

the

Least

Fixpoint

In

E.

B?orger

editor

Computation

Theory

and

Logic

Springer-Verlag

LNCS

-LSB-

-RSB-

E.A.

Emerson

Temporal

and

Modal

Logic

In

Jan

van

Leeuwen

editor

Handbook

of

Theoretical

Computer

Science

volume

B

chapter

pages

-LCB-

Elsevier/MIT

Press

-LSB-

-RSB-

H.B.

Enderton

A

Mathematical

Introduction

to

Logic

Academic

Press

-LSB-

-RSB-

M.

Fujita

S.

Kono

H.

Tanaka

and

T.

Moto-oka

Tokio

Logic

Programming

Language

based

on

Temporal

Logic

and

its

Compilation

to

Prolog

In

International

Conference

on

Logic

Programming

Springer-Verlag

LNCS

-LSB-

-RSB-

D.

Gabbay

Modal

and

Temporal

Logic

Programming

In

A.

Galton

editor

Temporal

Logics

and

Their

Applications

Academic

Press

-LSB-

-RSB-

D.

Gabbay

The

Declarative

Past

and

Imperative

Future

Executable

Temporal

Logic

for

Interactive

Systems

In

B.

Banieqbal

B.

Barringer

and

A.

Pnueli

editors

Temporal

Logic

in

Specification

volume

pages

-LCB-

SpringerVerlag

LNCS

-LSB-

-RSB-

J.

Grant

and

J.

Minker

The

Impact

of

Logic

Programming

on

Databases

Communications

of

the

ACM

-LRB-

-RRB-

-LCB-

March

-LSB-

-RSB-

H.

Gallaire

J.

Minker

and

J.

Nicolas

Logic

and

Databases

a

Deductive

Approach

ACM

Computing

Surveys

-LRB-

-RRB-

-LCB-

June

-LSB-

-RSB-

D.

Gabbay

A.

Pnueli

S.

Shelah

and

S.

Stavi

On

the

Temporal

Analysis

of

Fairness

In

ACM

SIGACT-SIGPLAN

Symposium

on

Principles

of

Programming

Languages

-LSB-

-RSB-

R.

Hale

Temporal

Logic

Programming

In

A.

Galton

editor

Temporal

Logics

and

their

Applications

pages

-LCB-

Academic

Press

-LSB-

-RSB-

J.

Jaffar

and

J-L

Lassez

Constraint

Logic

Programming

In

ACM

SIGACT

SIGPLAN

Symposium

on

Principles

of

Programming

Languages

-LSB-

-RSB-

W.H.

Joyner

Jr.

Resolution

Strategies

as

Decision

Procedures

Journal

of

the

ACM

-LRB-

-RRB-

-LCB-

July

-LSB-

-RSB-

M.

Kifer

On

Safety

Domain

Independence

and

Capturability

of

Database

Queries

In

Data

and

Knowledge

Base

Conference

Jerusalem

Israel

-LSB-

-RSB-

P.C.

Kanellakis

G.M.

Kuper

and

P.Z.

Revesz

Constraint

Query

Languages

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

pages

-LCB-

Nashville

Tennessee

April

-LSB-

-RSB-

P.

Kolitis

The

Expressive

Power

of

Stratified

Logic

Programs

Information

and

Computation

-LCB-

-LSB-

-RSB-

F.

Kabanza

J-M

Stevenne

and

P.

Wolper

Handling

Infinite

Temporal

Data

In

ACM

SIGACT-SIGMOD-SIGART

Symposium

on

Principles

of

Database

Systems

pages

-LCB-

Nashville

Tennessee

April

-LSB-

-RSB-

J.W.

Lloyd

Foundations

of

Logic

Programming

Springer-Verlag

edition

-LSB-

-RSB-

B.C.

Moszkowski

Executing

Temporal

Logic

Programs

Cambridge

University

Press

-LSB-

-RSB-

M.A.

Orgun

and

W.W.

Wadge

A

Theoretical

Basis

for

Intensional

Logic

Programming

In

Symposium

on

Lucid

and

Intensional

Programming

-LSB-

-RSB-

D.

Park

Concurrency

and

Automata

on

Infinite

Sequences

In

P.

Deussen

editor

Theoretical

Computer

Science

Springer-Verlag

LNCS

-LSB-

-RSB-

D.A.

Plaisted

Complete

Problems

in

the

First-Order

Predicate

Calculus

Journal

of

Computer

and

System

Sciences

-LCB-

-LSB-

-RSB-

P.Z.

Revesz

A

Closed

Form

for

Datalog

Queries

with

Integer

Order

In

International

Conference

on

Database

Theory

pages

-LCB-

Springer-Verlag

LNCS

-LSB-

-RSB-

M.

Schmidt-Schauss

Computational

Aspects

of

an

Order-Sorted

Logic

with

Term

Declarations

Lecture

Notes

in

Artificial

Intelligence

SpringerVerlag

-LSB-

-RSB-

S-A

Tarnlund

Horn

Clause

Computability

BIT

-LCB-

-LSB-

-RSB-

W.

Thomas

A

Combinatorial

Approach

to

the

Theory

of

automata

Information

and

Control

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

W.

Thomas

Automata

on

Infinite

Objects

In

Jan

van

Leeuwen

editor

Handbook

of

Theoretical

Computer

Science

volume

B

chapter

pages

-LCB-

Elsevier/MIT

Press

-LSB-

-RSB-

A.

Tuzhilin

and

Z.M.

Kedem

Using

Temporal

Logic

and

Datalog

to

Query

Databases

Evolving

in

Time

Technical

Report

New

York

University

December

-LSB-

-RSB-

M.

Tsukamoto

S.

Nishio

and

M.

Fujio

DOT

a

Term

Representation

using

DOT

Algebra

for

Knowledge-bases

In

International

Conference

on

Deductive

and

Object-Oriented

Databases

pages

-LCB-

Springer-Verlag

Lecture

Notes

in

Compuetr

Science

-LSB-

-RSB-

S.

Tamaki

and

T.

Sato

OLD

Resolution

with

Tabulation

In

International

Conference

on

Logic

Programming

pages

-LCB-

Springer-Verlag

-LSB-

-RSB-

J.D.

Ullman

Principles

of

Database

and

Knowledge-Base

Systems

volume

Computer

Science

Press

-LSB-

-RSB-

J.D.

Ullman

Principles

of

Database

and

Knowledge-Base

Systems

volume

Computer

Science

Press

-LSB-

-RSB-

M.Y.

Vardi

The

Complexity

of

Relational

Query

Languages

In

ACM

SIGACT

Symposium

on

Theory

of

Computing

pages

-LCB-

-LSB-

-RSB-

M.

Y.

Vardi

A

Temporal

Fixpoint

Calculus

In

ACM

SIGACT-SIGPLAN

Symposium

on

Principles

of

Programming

Languages

-LSB-

-RSB-

M.H.

van

Emden

and

R.A.

Kowalski

The

Semantics

of

Predicate

Logic

as

a

Programming

Language

Journal

of

the

ACM

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

L.

Vieille

Recursive

Query

Processing

The

Power

of

Logic

Theoretical

Computer

Science

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

W.

W.

Wadge

Tense

Logic

Programming

A

Respectable

Alternative

In

Symposium

on

Lucid

and

Intensional

Programming

-LSB-

-RSB-

P.

Wolper

Synthesis

of

Communicating

Processes

from

Temporal

Logic

specifications

PhD

thesis

Stanford

University

-LSB-

-RSB-

P.

Wolper

Temporal

Logic

Can

Be

More

Expressive

Information

and

Control

-LCB-

computational complexity
constraint logic programming
expressiveness
logic programming
query processing
temporal logic