Relating

Two

Categorical

Models

of

Term

Rewriting

A.

Corradini

F.

Gadducci

and

U.

Montanari

Universit?a

di

Pisa

Dipartimento

di

Informatica

Corso

Italia

Pisa

Italy

-LRB-

fandrea,gadducci,ugog@di.unipi.it,

Tel

Fax

-RRB-

Abstract

In

the

last

years

there

has

been

a

growing

interest

towards

categorical

models

for

term

rewriting

systems

-LRB-

trs

's

-RRB-

In

our

opinion

very

interesting

are

those

associating

to

each

trs

's

a

cat-enriched

structure

a

category

whose

hom-sets

are

categories

Interpreting

rewriting

steps

as

morphisms

in

hom-categories

these

models

provide

rewriting

systems

with

a

concurrent

semantics

in

a

clean

algebraic

way

In

this

paper

we

provide

a

unified

presentation

of

two

models

recently

proposed

in

literature

by

Jos?e

Meseguer

-LSB-

-RSB-

and

John

Stell

-LSB-

-RSB-

respectively

pursuing

a

critical

analysis

of

both

of

them

More

precisely

we

show

why

they

are

to

a

certain

extent

unsatisfactory

in

providing

a

concurrent

semantics

for

rewriting

systems

It

turns

out

that

the

derivation

space

of

Meseguer

's

Rewriting

Logic

associated

with

each

term

-LRB-

i.e.

the

set

of

coinitial

computations

-RRB-

fails

in

general

to

form

a

prime

algebraic

domain

a

condition

that

is

generally

considered

as

expressing

a

directly

implementable

model

of

concurrency

for

distributed

systems

-LRB-

see

-LSB-

-RSB-

-RRB-

On

the

contrary

the

resulting

derivation

space

in

Stell

's

model

is

actually

a

prime

algebraic

domain

but

too

few

computations

are

identified

only

disjoint

concurrency

can

be

expressed

limiting

the

degree

of

parallelism

described

by

the

model

Introduction

Term

rewriting

systems

-LRB-

briefly

trs

's

see

-LSB-

-RSB-

-RRB-

are

a

simple

yet

powerful

framework

based

on

the

notion

of

-LRB-

sequence

of

-RRB-

rewrites

a

binary

transitive

relation

over

terms

usually

generated

from

a

finite

set

of

rules

-LRB-

i.e.

of

pair

of

terms

subject

to

some

further

restriction

-RRB-

where

each

element

ht

si

states

the

transformation

from

term

t

to

term

s.

Despite

their

simplicity

trs

's

propose

themselves

as

a

basic

paradigm

for

computational

devices

terms

are

states

of

an

abstract

machine

while

rewriting

rules

are

state-transforming

functions

in

this

framework

computations

simply

are

sequences

of

rewrites

A

very

intuitive

operational

model

for

trs

's

is

represented

by

their

derivation

spaces

a

class

of

-LRB-

structured

-RRB-

elements

representing

all

the

possible

computations

Research

partially

supported

by

ESPRIT

BRA

project

CONFER

the

system

can

perform

These

structures

are

easily

defined

but

unfortunately

the

resulting

operational

semantics

is

usually

too

concrete

in

order

to

obtain

a

description

as

much

as

possible

independent

from

the

actual

implementation

of

the

rewriting

machine

we

need

to

abstract

away

from

irrelevant

details

More

precisely

if

we

see

a

term

as

a

completely

distributed

structure

such

that

an

actual

rewriting

machine

can

act

simultaneously

-LRB-

in

parallel

-RRB-

on

different

subterms

then

a

concurrent

semantics

is

interested

in

exploiting

to

a

maximum

degree

the

parallelism

implicit

in

the

definition

of

trs

's

Usually

such

a

semantics

can

be

recovered

imposing

an

equivalence

relation

on

computations

equating

sequences

of

rewrites

that

are

the

same

up

to

some

conditions

Those

conditions

express

the

properties

of

the

rewriting

mechanism

over

the

distributed

system

under

examination

each

equivalence

class

represents

an

abstract

computation

corresponding

to

a

family

of

computationally

equivalent

sequences

of

rewrites

In

the

classical

approach

the

derivation

space

is

just

a

set

and

the

equivalence

on

computations

relies

on

the

notion

of

residual

given

two

computations

d

and

then

the

residual

of

after

d

is

intuitively

what-remains-to-be-done

of

after

the

execution

of

d.

Abstract

computations

are

the

elements

of

the

set

of

concrete

derivations

quotiented

by

the

smallest

equivalence

induced

by

the

axiom

schema

where

indicates

concatenation

of

rewrites

This

equivalence

is

known

as

permutation

equivalence

-LSB-

-RSB-

and

it

equates

computations

that

are

the

same

up

to

permutation

of

independent

rewrites

Recently

and

sesqui-categories

have

been

proposed

respectively

by

Jos?e

Meseguer

-LSB-

-RSB-

and

John

Stell

-LSB-

-RSB-

as

a

more

abstract

algebraic

way

to

equip

trs

's

with

a

concurrent

semantics

A

catenriched

structure

as

a

or

a

sesqui-category

is

given

by

a

category

such

that

also

each

hom-set

forms

a

category

the

class

of

morphisms

-LRB-

called

cells

-RRB-

of

these

hom-categories

are

closed

under

certain

composition

operators

and

are

subject

to

suitable

coherence

axioms

In

the

paper

we

show

a

unified

two-phase

method

to

generate

such

algebraic

structures

starting

from

a

trs

's

First

to

each

trs

R

a

c-computad

is

associated

a

pair

hDR

SRi

where

DR

is

a

category

whose

arrows

represent

terms

while

SR

is

a

collection

of

cells

describing

the

rewriting

rules

of

R

then

from

the

c-computad

an

enriched

structure

is

freely

generated

obtaining

a

derivation

space

-LRB-

the

cells

of

the

enriched

structure

-RRB-

that

is

already

subject

to

an

equivalence

relation

due

to

the

coherence

axioms

since

there

exists

a

correspondence

between

cells

and

computations

this

way

a

trs

is

equipped

with

a

concurrent

semantics

The

resulting

construction

is

strictly

related

in

the

case

of

to

the

functorial

semantics

considered

by

Meseguer

in

the

Appendix

of

-LSB-

-RSB-

while

for

sesqui-categories

it

can

be

considered

as

an

original

algebraic

presentation

of

Stell

's

proposal

-LSB-

-RSB-

In

the

second

part

of

the

paper

we

will

consider

some

algebraic

properties

of

the

equivalences

on

derivations

induced

by

the

two

models

analyzing

in

particular

the

natural

partial

order

on

computations

In

a

classical

set-theoretic

context

a

similar

task

has

been

tackled

for

calculus

by

Laneve

in

-LSB-

-RSB-

where

a

new

semantics

is

introduced

-LRB-

induced

by

the

distributive

permutation

equivalence

where

only

permutation

of

distributed

rewrites

is

allowed

-RRB-

showing

that

the

corresponding

derivation

space

forms

a

prime

algebraic

domain

Prime

algebraic

domains

-LRB-

pad

's

-RRB-

are

a

simple

general

and

well-accepted

model

to

describe

the

behaviour

of

concurrent

non-deterministic

systems

Their

acceptance

in

the

concurrency

field

is

due

besides

to

their

historical

relevance

-LRB-

dating

back

to

the

work

of

Kahn

and

Plotkin

on

concrete

domains

and

of

Berry

on

dI

domains

-RRB-

to

their

tight

correspondence

with

Prime

Events

Structures

-LSB-

-RSB-

Firstly

introduced

in

the

early

eighties

Prime

Event

Structures

-LRB-

pes

's

-RRB-

are

partial

orders

of

events

equipped

with

a

conflict

relation

Such

structures

are

very

suitable

for

describing

the

behaviour

of

distributed

and

nondeterministic

computational

devices

generating

instantaneous

atomic

events

which

can

be

causally

related

or

mutually

exclusive

the

level

of

abstraction

they

capture

is

considered

as

directly

reflecting

that

of

a

possible

concurrent

implementation

where

each

event

corresponds

to

a

basic

action

of

the

underlying

machine

To

each

pes

is

associated

a

set

of

configurations

compatible

left-closed

subsets

of

its

events

Intuitively

a

configuration

corresponds

to

a

specific

state

of

the

system

reached

after

some

computation

and

its

events

are

all

those

generated

during

that

specific

computation

A

fundamental

result

due

to

Winskel

shows

that

the

set

of

all

configurations

of

a

pes

ordered

by

set

inclusion

-LRB-

its

domain

of

configurations

-RRB-

forms

a

pad

moreover

for

each

pad

there

is

a

pes

such

that

its

domain

of

configurations

is

isomorphic

to

the

given

pad

Thus

the

use

of

pad

's

or

pes

's

for

the

description

of

computational

systems

is

equivalent

Coming

back

to

term

rewriting

systems

in

each

of

the

two

models

mentioned

above

the

collection

of

all

abstract

derivations

starting

from

a

given

initial

term

t

can

be

equipped

easily

with

a

prefix

partial

ordering

d

iff

there

exists

a

derivation

such

that

d

In

Section

we

will

show

that

only

the

prefix

partial

order

induced

by

Stell

's

model

is

a

pad

while

that

induced

by

Meseguer

's

model

fails

to

satisfy

the

distributive

property

of

pad

's

The

paper

has

the

following

structure

In

Section

we

recall

the

basic

notions

of

enriched

category

theory

which

are

useful

for

our

discussion

In

Section

besides

the

definitions

of

term

algebras

and

of

term

rewriting

systems

we

introduce

some

notions

borrowed

from

Meseguer

's

Rewriting

Logic

-LSB-

-RSB-

In

Section

we

present

an

alternative

categorical

description

of

trs

and

we

introduce

in

a

unified

presentation

the

two

categorical

models

proposed

by

Jos?e

Meseguer

and

John

Stell

In

Section

we

analize

the

adequacy

of

such

modelizations

along

the

line

discussed

in

this

introduction

providing

a

pad

semantics

for

sesqui-categorical

models

Finally

in

Section

we

draw

our

conclusions

about

the

previous

results

suggesting

further

directions

for

future

work

Background

on

and

Sesqui-categories

In

the

following

we

assume

that

some

basic

definitions

of

category

theory

are

known

for

which

we

refer

the

reader

to

-LSB-

-RSB-

In

this

section

we

will

introduce

and

sesqui-categories

lifting

to

this

enriched

context

some

constructions

of

the

classical

category

theory

Basically

a

cat-enriched

category

simply

is

a

category

C

such

that

given

any

two

object

a

b

the

hom-set

C

-LSB-

a

b

-RSB-

i.e.

the

class

of

morphisms

from

a

to

b

is

a

category

moreover

these

hom-categories

satisfy

particular

composition

properties

A

morphism

in

C

-LSB-

a

b

-RSB-

a

cell

is

denoted

as

f

-RRB-

g

a

b

where

f

g

a

b

or

graphicallly

as

a

f

g

OO

OO

b

The

following

definition

is

adapted

from

-LSB-

-RSB-

-LRB-

and

Sesqui-Categories

-RRB-

Let

C

be

a

category

such

that

each

homset

C

-LSB-

a

b

-RSB-

also

forms

a

category

Moreover

let

us

assume

that

for

each

triple

a

b

c

of

objects

there

are

two

composition

functions

L

and

R

such

that

given

f

-RRB-

h

a

b

and

g

-RRB-

i

b

c

then

f

L

C

-LSB-

a

c

-RSB-

and

R

g

C

-LSB-

a

c

-RSB-

Graphically

a

f

b

g

i

OO

OO

c

a

f

g

f

i

OO

OO

c

C

-LSB-

a

c

-RSB-

-LRB-

analogously

for

R

g

-RRB-

where

denotes

composition

inside

C.

Let

us

consider

the

situation

denoted

by

the

following

cells

a

f

b

j

OO

OO

FF

OO

OO

g

c

k

ssss

OO

OO

EE

OO

OO

ffi

h

d

i

e

A

-LRB-

or

simply

C

-RRB-

is

a

category

C

-LRB-

called

the

underlying

category

-RRB-

with

a

structure

as

the

one

above

defined

such

that

the

composition

functions

are

subject

to

the

following

equations

-LRB-

-RRB-

idc

L

-LRB-

-RRB-

-LRB-

f

g

-RRB-

L

f

L

-LRB-

g

L

-RRB-

-LRB-

-RRB-

g

L

idh

idg

h

-LRB-

-RRB-

g

L

-LRB-

ffi

-RRB-

-LRB-

g

L

-RRB-

-LRB-

g

L

ffi

-RRB-

-LRB-

-RRB-

R

idc

-LRB-

-RRB-

R

-LRB-

h

i

-RRB-

-LRB-

R

h

-RRB-

R

i

-LRB-

-RRB-

idg

R

h

idg

h

-LRB-

-RRB-

-LRB-

-RRB-

R

h

-LRB-

R

h

-RRB-

-LRB-

R

h

-RRB-

-LRB-

-RRB-

-LRB-

f

L

-RRB-

R

h

f

L

-LRB-

R

h

-RRB-

-LRB-

-RRB-

-LRB-

j

L

-RRB-

-LRB-

R

h

-RRB-

-LRB-

R

k

-RRB-

-LRB-

g

L

-RRB-

We

are

quite

informal

here

both

and

sesqui-categories

are

categories

enriched

over

Cat

in

the

sense

of

-LSB-

-RSB-

but

the

tensor

product

used

is

different

in

the

two

cases

-LRB-

see

-LSB-

-RSB-

-RRB-

In

the

following

we

shall

refer

to

both

and

sesqui-categories

as

cat-enriched

categories

stressing

that

their

hom-sets

form

categories

-LSB-

-RSB-

contains

a

comprehensive

introduction

to

this

topic

where

denotes

composition

insides

hom-categories

A

sesqui-category

CS

-LRB-

or

simply

C

usually

there

is

no

ambiguity

-RRB-

is

a

category

C

with

a

structure

subject

to

equations

-LRB-

-RRB-

-LRB-

-RRB-

A

-LRB-

sesqui-functor

or

just

functor

in

both

cases

-RRB-

F

C

D

is

a

function

mapping

objects

to

objects

morphisms

to

morphisms

and

cells

to

cells

preserving

identities

and

compositions

of

all

kinds

ut

Let

-LRB-

S-Cat

-RRB-

be

the

category

of

-LRB-

sesqui-categories

-RRB-

and

functors

-LRB-

sesqui-functors

-RRB-

there

exists

an

inclusion

functor

Ui

S-Cat

whose

left

adjoint

Fi

simply

quotients

the

structure

of

a

sesqui-category

with

respect

to

the

axiom

-LRB-

-RRB-

-LRB-

or

interchange

axiom

-RRB-

As

a

matter

of

fact

is

reflective

inside

S-Cat

Note

also

that

thanks

to

axiom

-LRB-

-RRB-

it

is

possible

to

define

the

notion

of

horizontal

composition

of

cells

so

that

the

given

definition

for

is

then

equivalent

to

the

classical

one

-LRB-

see

-LSB-

-RSB-

-RRB-

-LRB-

j

L

-RRB-

-LRB-

R

h

-RRB-

-LRB-

R

k

-RRB-

-LRB-

g

L

-RRB-

A

category

C

is

cartesian

if

it

has

a

terminal

object

such

that

for

every

object

a

there

exists

a

unique

arrow

a

a

and

-LRB-

binary

-RRB-

products

i.e.

a

triple

ssa

b

ha

b

a

b

a

a

b

bi

for

each

pair

a

b

of

objects

such

that

given

the

arrows

hf

c

a

g

c

bi

there

is

a

unique

arrow

hf

gi

c

a

b

satisfying

hf

gi

f

and

hf

gi

g

These

properties

are

required

for

cells

in

an

enriched

context

-LRB-

Cartesian

Cat-Enriched

Categories

-RRB-

Let

C

be

a

-LRB-

sesqui-category

-RRB-

such

that

the

underlying

category

C

is

cartesian

We

say

that

C

has

finite

-LRB-

sesqui-products

-RRB-

if

for

every

pair

f

-RRB-

g

c

a

and

h

-RRB-

k

c

b

of

cells

there

exists

a

unique

cell

hff

i

hf

hi

-RRB-

hg

ki

c

a

b

satisfying

R

and

R

Graphically

c

hf

hi

-RRB-

-RRB-

hg

ki

OO

OO

a

b

a

c

f

g

OO

OO

a

-LRB-

similarly

for

-RRB-

C

has

terminal

if

for

every

cell

f

-RRB-

g

c

a

we

have

R!c

a

where

is

terminal

in

C

and

a

a

c

c

ut

We

define

-LRB-

SC-Cat

-RRB-

as

the

category

of

cartesian

-LRB-

sesquicategories

-RRB-

and

functors

preserving

products

and

terminal

object

the

pair

of

functors

hUi

Fii

introduced

above

still

forms

an

adjunction

when

restricted

to

and

SC-Cat

respectively

if

we

require

that

functors

in

those

categories

preserve

products

and

terminal

object

on

the

nose

We

will

be

interested

in

a

finitary

presentation

of

an

enriched

structure

i.e.

in

a

set

of

generators

such

that

a

cat-enriched

category

can

be

obtained

freely

composing

cells

An

appropriate

structure

for

that

is

represented

by

c-computads

-LRB-

C-Computads

-RRB-

A

c-computad

is

a

pair

hC

Si

where

C

is

a

category

and

S

is

a

set

of

cells

each

of

which

has

two

parallel

arrows

of

C

as

source

and

target

respectively

Given

the

c-computads

hC

Si

and

a

c-morphism

is

a

pair

hF

hi

such

that

F

C

is

a

functor

h

S

is

a

function

and

for

every

cell

f

-RRB-

g

S

we

have

h

-LRB-

-RRB-

F

-LRB-

f

-RRB-

-RRB-

F

-LRB-

g

-RRB-

ut

A

c-computad

hC

Si

is

cartesian

if

so

is

C

while

a

c-morphism

hF

hi

preserves

products

and

terminal

object

if

F

does

so

Let

C-Comp

be

the

category

of

cartesian

c-computads

and

c-morphisms

preserving

products

and

terminal

object

there

exists

an

obvious

forgetful

functor

C-Comp

which

forgets

the

composition

of

cells

with

left

adjoint

This

adjoint

composes

the

cells

of

a

c-computad

in

all

the

possible

ways

both

horizontally

and

vertically

imposing

further

equalities

in

order

to

satisfy

the

axioms

of

a

and

to

preserve

finite

products

and

terminal

object

on

the

underlying

category

There

exists

also

a

similar

adjunction

pair

hUs

Fsi

between

SC-Cat

and

C-Comp

such

that

the

following

diagram

commutes

C-Comp

fflffl

Fs

N

N

N

N

N

N

N

N

N

N

SC-Cat

Fi

OO

Us

oo

Ui

ff

NNNNNNNNNN

All

functors

preserve

products

and

terminal

object

on

the

nose

in

particular

those

originating

from

C-Comp

preserve

products

in

the

underlying

category

Term

Algebras

and

Rewriting

Systems

We

start

recalling

some

well-known

results

about

universal

algebras

-LRB-

see

e.g.

-LSB-

-RSB-

-RRB-

We

will

introduce

them

in

the

classical

set-theoretical

way

dealing

in

particular

with

the

structure

of

terms

in

free

algebras

-LRB-

The

Class

of

algebras

-RRB-

Let

be

a

-LRB-

one-sorted

-RRB-

signature

i.e.

a

ranked

alphabet

of

operator

symbols

-LSB-

-LRB-

saying

that

f

is

of

arity

n

for

f

n

-RRB-

A

algebra

is

a

pair

A

hjAj

aeAi

such

that

jAj

is

a

set

-LRB-

the

carrier

-RRB-

and

aeA

ffA

j

f

g

is

a

family

of

functions

such

that

for

each

f

n

fA

jAjn

jAj

Let

A

B

be

two

algebras

a

homomorphism

o

A

B

is

a

function

o

jAj

jBj

preserving

operators

i.e.

such

that

for

each

f

n

o

ffi

fA

fB

ffi

on

ut

It

is

well-known

that

for

each

signature

there

exists

an

initial

algebra

often

called

the

word

algebra

and

denoted

by

T

the

elements

of

the

word

algebra

are

all

the

terms

freely

generated

from

the

constants

and

the

operators

of

Given

a

set

X

xng

of

variables

the

elements

of

the

algebra

T

-LRB-

X

-RRB-

i.e.

the

algebra

of

terms

with

variables

in

X

are

the

terms

of

T

-LSB-

X

freely

generated

from

adding

the

elements

of

X

as

new

constants

Given

a

term

t

f

-LRB-

tn

-RRB-

a

subterm

of

t

could

be

simply

defined

as

t

itself

or

any

subterm

of

ti

but

since

we

want

to

distinguish

among

different

occurrences

of

the

same

subterm

in

t

we

need

to

define

in

a

formal

way

the

notion

of

occurrence

The

set

O

-LRB-

t

-RRB-

of

occurrences

of

a

term

t

is

the

subset

of

IlN

defined

inductively

in

the

following

way

-LRB-

the

empty

string

-RRB-

is

an

occurrence

of

t

if

t

f

-LRB-

tn

-RRB-

and

w

O

-LRB-

ti

-RRB-

then

iw

O

-LRB-

t

-RRB-

In

the

following

as

a

subterm

of

t

we

mean

a

pair

hw

si

s

is

the

actual

subterm

while

w

is

the

position

of

that

particular

subterm

in

t.

Each

O

-LRB-

t

-RRB-

can

be

equipped

with

a

partial

order

relation

iff

there

exists

such

that

two

occurrences

are

disjoint

if

neither

nor

two

subterms

are

disjoint

if

so

are

their

respective

occurrences

Finally

given

two

finite

sets

X

Y

of

variables

a

substitution

is

a

function

oe

X

T

-LRB-

Y

-RRB-

usually

denoted

as

a

set

of

the

form

xn

tng

for

xioe

ti

-LRB-

in

postfix

notation

-RRB-

A

substitution

oe

extends

to

a

function

-LRB-

also

denoted

oe

-RRB-

from

T

-LRB-

X

-RRB-

to

T

-LRB-

Y

-RRB-

defined

inductively

as

f

-LRB-

sn

-RRB-

oe

f

-LRB-

snoe

-RRB-

for

every

operator

f

Now

we

are

ready

to

introduce

-LRB-

term

-RRB-

rewriting

systems

which

are

just

-LRB-

labelled

-RRB-

sets

of

rules

i.e.

of

pairs

of

terms

-LRB-

-LRB-

Term

-RRB-

Rewriting

Systems

-RRB-

Let

X

be

a

set

of

variables

A

-LRB-

term

-RRB-

rewriting

system

R

is

a

tuple

-LRB-

L

R

-RRB-

where

is

a

signature

L

is

a

set

of

labels

and

R

is

a

function

R

L

T

-LRB-

X

-RRB-

T

-LRB-

X

-RRB-

such

that

for

all

d

L

if

R

-LRB-

d

-RRB-

hl

ri

then

var

-LRB-

r

-RRB-

var

-LRB-

l

-RRB-

X

and

l

is

not

a

variable

We

write

d

l

r

R

if

d

L

and

R

-LRB-

d

-RRB-

hl

ri

sometimes

to

make

explicit

the

variables

contained

in

a

rule

we

will

write

d

-LRB-

xn

-RRB-

l

-LRB-

xn

-RRB-

r

-LRB-

xn

-RRB-

R

where

xng

var

-LRB-

l

-RRB-

moreover

given

a

substitution

oe

xn

tng

we

will

write

l

-LRB-

tn

-RRB-

for

loe

ut

From

the

classical

viewpoint

a

rule

d

l

r

can

be

applied

to

a

term

t

if

there

is

a

subterm

hw

si

of

t

such

that

l

matches

s

and

the

result

is

the

term

t

where

the

matched

subterm

is

replaced

by

a

suitable

instantiation

of

r.

Moreover

a

term

can

be

rewritten

into

another

if

there

exists

an

appropriate

chain

of

rules

applications

This

presentation

makes

sequences

of

rewrites

the

basic

notion

it

does

not

allow

to

reason

about

how

a

rewrite

can

be

executed

i.e.

to

record

the

possible

different

justifications

of

a

derivation

To

this

aim

we

introduce

now

an

alternative

definition

of

rewriting

borrowed

from

the

seminal

work

by

Jos?e

Meseguer

-LSB-

-RSB-

The

idea

is

to

take

a

logical

viewpoint

regarding

a

rewriting

system

R

as

a

theory

and

any

rewriting

making

use

of

rules

in

R

as

a

sequent

entailed

by

the

theory

The

entailment

relation

is

defined

inductively

by

the

deduction

rules

of

rewriting

logic

-LRB-

Proof

Terms

and

Rewriting

Sequents

-RRB-

Let

R

-LRB-

L

R

-RRB-

be

a

rewriting

system

Let

-LSB-

n?n

be

the

signature

containing

all

the

rules

d

l

r

R

with

the

corresponding

arity

given

by

the

number

of

variables

in

d

more

precisely

for

each

n

n

fd

j

d

-LRB-

xn

-RRB-

l

-LRB-

xn

-RRB-

r

-LRB-

xn

-RRB-

Rg

A

proof

term

is

a

term

of

the

algebra

TR

T

-LSB-

-LSB-

f?g

-LRB-

X

-RRB-

where

is

a

binary

operator

-LRB-

we

assume

that

there

are

no

clashes

of

names

among

the

various

sets

of

operators

-RRB-

A

-LRB-

rewriting

-RRB-

sequent

is

a

triple

hff

t

si

-LRB-

usually

written

as

t

s

-RRB-

where

is

a

proof

term

and

t

s

T

-LRB-

X

-RRB-

ut

So

sequents

in

rewriting

logic

have

the

form

t

s

where

t

and

s

are

terms

and

is

a

proof

term

encoding

a

justification

of

the

rewriting

of

t

into

s

We

say

that

t

rewrites

to

s

via

if

the

sequent

t

s

can

be

obtained

by

finitely

many

applications

of

certain

rules

of

deduction

-LRB-

Rewriting

Logic

-RRB-

Let

R

-LRB-

L

R

-RRB-

be

a

rewriting

system

We

say

that

R

entails

the

full

sequent

s

t

if

it

can

be

obtained

by

a

finite

number

of

applications

of

the

following

rules

of

deduction

-LRB-

Reflexivity

-RRB-

t

T

t

t

t

-LRB-

Full

Instantiation

-RRB-

d

l

r

R

d

n

i

ti

si

sequents

for

i

n

d

-LRB-

n

-RRB-

l

-LRB-

tn

-RRB-

r

-LRB-

sn

-RRB-

-LRB-

Congruence

-RRB-

f

n

i

ti

si

sequents

for

i

n

f

-LRB-

n

-RRB-

f

-LRB-

tn

-RRB-

f

-LRB-

sn

-RRB-

-LRB-

Transitivity

-RRB-

s

t

t

u

s

u

The

rewriting

system

R

entails

the

flat

sequent

s

t

if

it

can

be

obtained

by

a

finite

number

of

applications

of

the

rules

Identity

Congruence

Transitivity

and

Flat

Instantiation

where

-LRB-

Flat

Instantiation

-RRB-

d

l

r

R

d

n

ti

T

-LRB-

X

-RRB-

for

i

n

d

-LRB-

tn

-RRB-

l

-LRB-

tn

-RRB-

r

-LRB-

tn

-RRB-

ut

Let

us

point

out

the

meaning

of

these

rules

Reflexivity

and

Transitivity

are

self-explaining

Congruence

states

that

disjoint

rewrites

can

be

executed

in

parallel

the

associated

proof

term

provides

the

context

for

the

respective

justifications

The

most

interesting

rules

are

the

two

different

kinds

of

instantiation

Full

Instantiation

allows

for

nested

rewriting

two

subterms

matching

the

left-hand

sides

of

two

rules

can

be

rewritten

in

parallel

even

if

their

roots

are

not

disjoint

i.e.

if

one

is

above

the

other

provided

that

they

do

not

overlap

On

the

contrary

Flat

Instantiation

does

not

allow

such

nesting

each

rule

can

only

be

instantiated

with

elements

of

T

-LRB-

X

-RRB-

and

thus

the

rule

names

in

a

proof

term

generated

using

this

rule

instead

of

Full

Instantiation

will

appear

at

mutually

disjoint

positions

It

is

worth

stressing

that

on

the

one

hand

full

sequents

correspond

exactly

to

the

entailment

relation

defined

by

Meseguer

-LRB-

for

the

unconditional

case

-RRB-

in

-LSB-

-RSB-

On

the

other

hand

we

introduced

flat

sequents

as

the

syntactical

counterpart

of

Stell

's

categorical

model

as

we

will

see

in

the

next

sections

As

an

example

consider

the

rewriting

system

V

fd

-LRB-

x

-RRB-

f

-LRB-

x

-RRB-

g

-LRB-

x

-RRB-

a

bg

It

entails

the

flat

sequents

d

-LRB-

a

-RRB-

g

-LRB-

-RRB-

and

f

-LRB-

-RRB-

d

-LRB-

b

-RRB-

with

source

f

-LRB-

a

-RRB-

and

target

g

-LRB-

b

-RRB-

rule

d

has

been

instantiated

with

fx

ag

and

fx

bg

respectively

while

has

been

contextualized

it

also

entails

the

full

sequent

d

-LRB-

-RRB-

f

-LRB-

a

-RRB-

g

-LRB-

b

-RRB-

where

is

nested

inside

d.

Graphically

we

have

the

rewrites

f

d

-LRB-

a

-RRB-

g

g

a

a

g

-LRB-

-RRB-

b

f

f

d

-LRB-

b

-RRB-

g

a

f

-LRB-

-RRB-

b

b

f

d

-LRB-

-RRB-

g

a

b

using

the

standard

-LRB-

yet

suggestive

in

our

case

-RRB-

representation

of

terms

as

trees

The

complete

agreement

between

the

classical

definition

of

derivability

among

terms

and

the

one

above

using

Rewriting

Logic

was

already

stated

in

-LSB-

-RSB-

-LRB-

and

it

has

been

formally

established

and

generalized

to

infinite

rewriting

in

-LSB-

-RSB-

-RRB-

More

precisely

it

is

not

difficult

to

show

that

there

exists

a

derivation

from

t

to

s

in

a

trs

R

iff

R

entails

a

sequent

-LRB-

flat

or

full

-RRB-

t

s

The

same

kind

of

agreement

holds

between

full

and

flat

entailment

a

rewriting

system

R

entails

a

full

sequent

t

s

iff

there

exists

a

finite

chain

i

ti

si

i

n

of

flat

sequents

such

that

n

t

s.

So

why

to

distinguish

between

flat

and

full

rewrites

First

of

all

we

must

remind

the

reader

that

sequents

represent

an

operational

model

for

rewriting

systems

each

sequent

can

be

considered

as

the

encoding

of

a

concrete

computation

of

the

machine

If

we

consider

a

term

as

a

totally

distributed

structure

i.e.

such

that

an

actual

rewriting

machine

can

act

separately

on

each

occurrence

of

the

term

then

full

sequents

are

able

to

describe

the

simultaneous

execution

of

nested

rewrites

Instead

a

flat

sequent

can

express

only

disjoint

concurrency

two

rewrites

can

be

executed

simultaneously

only

if

they

act

on

disjoint

positions

of

a

term

In

other

words

choosing

a

set

of

deduction

rules

is

implicitly

the

same

as

choosing

a

particular

implementation

schema

so

to

say

for

a

rewriting

system

We

already

stated

in

the

introduction

the

reasons

why

providing

a

concurrent

semantics

for

a

rewriting

system

means

equipping

its

set

of

computations

with

a

suitable

equivalence

relation

This

is

a

particularly

easy

task

in

the

setting

of

Rewriting

Logic

where

the

elements

of

the

space

of

computations

are

encoded

by

terms

of

the

algebra

TR

So

an

equivalence

relation

can

be

easily

expressed

as

an

appropriate

set

of

axioms

on

proof

terms

-LRB-

Abstract

Sequents

-RRB-

Let

R

be

a

rewriting

system

An

abstract

flat

sequent

entailed

by

R

is

an

equivalence

class

of

flat

sequents

entailed

by

R

modulo

the

following

set

E

of

axioms

which

are

intended

to

apply

to

the

corresponding

proof

terms

-LCB-

-LRB-

Associativity

-RRB-

ff

proof

terms

-LRB-

-RRB-

-LRB-

-RRB-

-LCB-

-LRB-

Distributivity

-RRB-

f

n

i

i

proof

terms

for

i

n

f

-LRB-

n

n

-RRB-

f

-LRB-

n

-RRB-

f

-LRB-

n

-RRB-

-LCB-

-LRB-

Identity

-RRB-

s

t

sequent

s

t

It

is

easy

to

check

that

proof

terms

equated

by

the

above

equations

have

the

same

source

and

target

terms

thus

an

abstract

flat

sequent

can

be

represented

safely

as

-LSB-

-RSB-

E

s

t.

Similarly

an

abstract

full

sequent

entailed

by

R

is

an

equivalence

class

-LSB-

-RSB-

s

t

of

full

sequents

entailed

by

R

where

-LSB-

-RSB-

is

an

equivalence

class

of

proof

terms

modulo

the

equations

in

which

is

the

union

of

the

above

equations

and

the

following

one

-LCB-

-LRB-

Interchange

-RRB-

d

l

r

R

d

n

i

ti

si

sequents

for

i

n

d

-LRB-

n

-RRB-

l

-LRB-

n

-RRB-

d

-LRB-

sn

-RRB-

d

-LRB-

tn

-RRB-

r

-LRB-

n

-RRB-

ut

Associativity

and

Identity

need

no

explanation

Also

Distributivity

has

an

obvious

meaning

to

give

a

context

to

the

composition

of

two

rewrites

is

the

same

as

to

compose

the

contextualization

of

the

single

rewrites

The

Interchange

axiom

is

applied

to

full

sequents

only

it

states

that

each

nested

rewrite

can

be

expressed

as

the

sequential

composition

of

two

simpler

rewrites

Similarly

to

Definition

the

set

of

axioms

coincides

with

those

given

by

Meseguer

while

we

introduced

E

as

we

will

see

in

the

next

section

as

the

algebraic

counterpart

of

Stell

's

categorical

model

Categorical

Models

of

Rewriting

Systems

The

aim

of

the

previous

section

was

to

provide

set-theoretic

models

for

rewriting

systems

Instead

the

main

concern

of

this

section

is

for

categorical

models

we

want

to

introduce

enriched

structures

such

that

their

cells

are

in

one-to-one

correspondence

with

the

abstract

sequents

of

a

rewriting

system

We

first

define

a

structure

such

that

its

set

of

cells

is

in

one-to-one

correspondence

with

the

rewrite

rules

in

R

and

moreover

the

underlying

category

is

able

to

describe

in

a

faithful

way

the

structure

of

the

word

algebra

associated

to

a

given

signature

Given

a

signature

we

denote

by

Th

-LRB-

-RRB-

the

associated

Lawvere

theory

-LSB-

-RSB-

it

is

a

category

with

finite

products

having

natural

numbers

as

objects

freely

generated

from

the

operators

of

-LRB-

Lawvere

Theories

-RRB-

Given

a

signature

the

associated

Lawvere

theory

is

the

category

Th

-LRB-

-RRB-

with

finite

products

such

that

-LCB-

its

objects

are

underlined

natural

numbers

is

the

terminal

object

and

the

product

is

defined

as

n

m

n

m

-LCB-

the

arrows

are

generated

by

the

following

inference

rules

-LRB-

generators

-RRB-

f

n

f

n

-LRB-

pairing

-RRB-

s

n

m

t

n

hs

ti

n

m

-LRB-

identities

-RRB-

n

IlN

idn

n

n

-LRB-

projections

-RRB-

n

m

IlN

n

m

n

n

m

m

-LRB-

composition

-RRB-

s

n

m

t

m

k

s

t

n

k

-LRB-

terminal

arrows

-RRB-

n

IlN

n

n

and

satisfying

the

axioms

of

cartesian

categories

ut

It

can

be

shown

that

arrows

from

n

to

are

in

one-to-one

correspondence

with

terms

whose

variables

are

among

xn

by

t

n

we

shall

denote

the

arrow

corresponding

to

a

term

t.

Similarly

an

arrow

n

m

corresponds

to

a

muple

of

terms

with

n

variables

and

arrows

composition

is

terms

substitution

Note

that

since

is

the

terminal

object

there

exists

a

-LRB-

unique

-RRB-

arrow

m

m

for

m

IlN

As

for

the

so-called

duplicators

rn

hidn

idni

n

these

arrows

play

a

fundamental

r

ole

in

the

one-to-one

correspondence

between

arrows

and

terms

Let

us

consider

a

constant

c

as

a

generator

the

corresponding

arrow

is

c

while

when

considering

c

as

an

element

of

T

-LRB-

-RRB-

then

the

associated

arrow

is

c

moreover

these

arrows

are

unique

since

for

each

s

m

n

we

have

s

m

n.

Without

going

any

further

the

Lawvere

theory

Th

-LRB-

-RRB-

can

be

regarded

simply

as

an

alternative

presentation

of

the

signature

-LRB-

where

the

basic

operators

are

those

we

called

generators

-RRB-

while

each

homset

Th

-LRB-

-RRB-

-LSB-

n

m

-RSB-

-LRB-

i.e.

the

set

of

morphisms

with

source

n

and

target

m

-RRB-

is

equivalent

to

-LSB-

T

-LRB-

xn

-RRB-

-RSB-

m

the

set

of

m-tuples

of

terms

of

the

free

algebra

with

at

most

n

variables

-LRB-

From

Rewriting

Systems

to

Computads

-RRB-

Given

a

rewriting

system

R

-LRB-

L

R

-RRB-

the

associated

c-computad

Th

-LRB-

R

-RRB-

is

given

by

the

pair

hTh

-LRB-

-RRB-

Rci

where

Rc

is

a

set

of

cells

between

the

arrows

of

Th

-LRB-

-RRB-

such

that

s

t

R

iff

c

s

t

Rc

ut

After

seminal

studies

in

the

late

Eighties

-LSB-

-RSB-

the

correspondence

between

rewriting

systems

and

c-computads

has

been

at

the

basis

of

many

works

on

rewriting

The

usual

technique

consists

of

freely

generating

from

a

c-computad

a

cat-enriched

structure

such

that

its

cells

represent

-LRB-

equivalence

classes

of

-RRB-

sequences

of

rewrites

given

a

cell

c

left-composition

s

L

c

instantiates

the

rewrite

corresponding

to

c

while

right-composition

c?Rt

inserts

it

in

a

context

The

approaches

by

Meseguer

-LSB-

-RSB-

using

and

by

Stell

-LSB-

-RSB-

using

sesqui-categories

are

instances

of

such

a

general

idea

Thus

they

can

be

easily

rephrased

in

this

categorical

setting

by

using

the

free

functors

relating

c-computads

and

cat-enriched

categories

introduced

after

Definition

It

is

worth

stressing

that

this

presentation

departs

from

those

proposed

in

the

original

works

-LRB-

dramatically

so

for

Stell

's

model

-RRB-

but

it

is

essentially

the

same

in

the

sense

that

the

induced

equivalences

on

derivations

are

actually

coincident

-LRB-

Space

of

Computations

-RRB-

Let

R

be

a

rewriting

system

and

let

Th

-LRB-

R

-RRB-

be

its

associated

c-computads

Then

the

associated

Meseguer

's

space

of

computations

-LRB-

R

-RRB-

is

the

cartesian

-LRB-

Th

-LRB-

R

-RRB-

-RRB-

while

its

Stell

's

space

of

computations

S-Th

-LRB-

R

-RRB-

is

the

cartesian

sesqui-category

Fs

-LRB-

Th

-LRB-

R

-RRB-

-RRB-

ut

Both

these

cat-enriched

categories

provide

concurrent

models

for

rewriting

systems

since

they

impose

an

equivalence

relation

over

cells

-LRB-

i.e.

sequences

of

rewrites

-RRB-

Different

equivalences

since

the

interchange

axiom

plays

a

crucial

r

ole

Let

us

consider

the

rewriting

system

W

fd

-LRB-

x

-RRB-

f

-LRB-

x

-RRB-

g

-LRB-

x

x

-RRB-

a

b

-LRB-

x

-RRB-

h

-LRB-

x

-RRB-

cg

the

computad

Th

-LRB-

W

-RRB-

has

the

following

set

of

cells

f

OO

OO

d

g

a

b

OO

OO

h

OO

OO

d

b

First

of

all

note

the

importance

of

duplicator

and

terminal

arrow

for

the

correspondence

between

rewriting

rules

and

cells

Note

also

that

cells

such

as

-LRB-

R

f

-RRB-

-LRB-

b

L

d

-RRB-

and

-LRB-

a

L

d

-RRB-

-LRB-

R

-LRB-

g

-RRB-

-RRB-

-LRB-

a

L

d

-RRB-

-LRB-

R

g

-RRB-

originating

from

a

f

-LRB-

the

morphism

associated

to

the

term

f

-LRB-

a

-RRB-

-RRB-

belong

to

both

spaces

of

computations

But

while

in

Stell

's

space

they

are

different

in

Meseguer

's

space

thanks

to

the

interchange

axiom

they

are

equated

The

same

happens

to

the

cells

-LRB-

R

h

-RRB-

-LRB-

b

L

-RRB-

and

-LRB-

a

L

-RRB-

-LRB-

R

-LRB-

b

-RRB-

-RRB-

-LRB-

a

L

-RRB-

originating

from

the

morphism

a

h

This

suggests

that

sesqui-categories

are

suitable

models

of

flat

entailment

as

an

example

there

is

no

intuitive

semantical

counterpart

for

the

abstract

full

sequent

-LSB-

d

-LRB-

-RRB-

-RSB-

f

-LRB-

a

-RRB-

g

-LRB-

b

b

-RRB-

in

the

sesqui-category

S-Th

-LRB-

W

-RRB-

On

the

contrary

are

models

for

the

full

entailment

relation

since

the

interchange

axiom

holds

the

cell

associated

to

that

sequent

is

given

by

-LRB-

R

f

-RRB-

-LRB-

b

L

d

-RRB-

-LRB-

a

L

d

-RRB-

-LRB-

R

-LRB-

g

-RRB-

-RRB-

d

All

this

discussion

is

summarized

by

the

following

theorem

stating

in

a

clear

way

the

relationship

between

spaces

of

computations

and

abstract

sequents

-LRB-

Correspondence

of

Algebraic

and

Categorical

Models

-RRB-

Let

R

be

a

rewriting

system

Then

the

following

statements

hold

For

each

n

IlN

there

exists

a

bijective

function

OEn

between

the

set

of

all

abstract

flat

sequents

entailed

by

R

containing

variables

in

xng

and

the

cells

in

S-Th

-LRB-

R

-RRB-

-LSB-

n

-RSB-

such

that

OE

-LRB-

-LSB-

-RSB-

E

-RRB-

s

t

iff

-LSB-

-RSB-

E

s

t.

Similarly

for

each

n

IlN

there

exists

a

bijective

function

n

between

the

set

of

all

abstract

full

sequents

entailed

by

R

containing

variables

in

xng

and

the

cells

in

-LRB-

R

-RRB-

-LSB-

n

-RSB-

such

that

-LRB-

-LSB-

-RSB-

-RRB-

s

t

iff

-LSB-

-RSB-

s

t.

ut

Categorical

Models

and

Prime

Algebraic

Domains

In

this

section

we

aim

at

analyzing

the

algebraic

properties

of

the

categorical

models

we

just

introduced

As

a

start

we

introduce

Prime

Algebraic

Domains

-LRB-

pad

's

for

short

see

-LSB-

-RSB-

-RRB-

A

pad

is

simply

a

partial

order

-LRB-

po

-RRB-

verifying

some

additional

properties

The

use

of

po

's

in

semantics

relies

on

the

old

idea

that

a

computing

machine

determines

an

ordered

space

of

computations

the

richer

structure

of

pad

's

however

make

them

especially

suitable

for

modelling

distributed

systems

-LRB-

Prime

Algebraic

Domains

-RRB-

Let

D

hD

vi

be

a

po

The

least

upper

bound

-LRB-

shortly

lub

-RRB-

of

a

set

X

D

is

an

element

FX

such

that

x

FX

for

all

x

X

and

such

that

for

all

z

D

-LRB-

X

x

z

-RRB-

-RRB-

FX

z

We

write

x

t

y

for

Ffx

yg

Symmetrically

the

greatest

lower

bound

-LRB-

shortly

glb

-RRB-

of

a

set

X

D

is

an

element

uX

such

that

uX

x

for

all

x

X

and

such

that

for

all

z

D

-LRB-

X

z

x

-RRB-

-RRB-

z

uX

We

write

x

u

y

for

ufx

yg

A

directed

subset

of

D

is

a

subset

S

D

such

that

for

any

finite

subset

X

S

there

is

an

element

s

S

such

that

X

x

s.

An

element

x

D

is

finite

if

for

all

directed

sets

S

x

v

FS

implies

that

there

is

some

s

S

such

that

x

v

s.

D

is

finitary

if

for

every

finite

element

x

D

the

set

fy

j

y

v

xg

is

finite

An

element

x

D

is

complete

prime

-LRB-

prime

-RRB-

if

for

each

X

D

-LRB-

each

finite

X

D

-RRB-

if

FX

exists

and

x

v

FX

then

there

exists

an

y

X

such

that

x

v

y.

D

is

prime

algebraic

if

for

all

x

D

x

Ffy

v

x

j

y

is

complete

primeg

For

x

y

D

we

write

x

y

-LRB-

and

we

say

that

x

and

y

are

compatible

-RRB-

if

there

exists

a

z

such

that

x

v

z

and

y

v

z

We

say

that

X

D

is

pairwise

compatible

if

for

all

x

y

X

we

have

x

y.

A

finitary

partial

order

hD

vi

is

distributive

if

whenever

x

y

then

we

have

-LRB-

x

t

y

-RRB-

u

z

-LRB-

x

u

z

-RRB-

t

-LRB-

y

u

z

-RRB-

D

is

finitely

coherent

if

it

has

lub

's

of

finite

pairwise

compatible

subsets

D

is

a

coherent

domain

if

it

has

lub

's

of

arbitrary

pairwise

compatible

subsets

ut

Fact

Any

coherent

finitary

prime

algebraic

domain

D

is

distributive

ut

As

we

remarked

in

the

introduction

whenever

the

derivation

space

of

a

model

forms

a

pad

this

can

be

seen

as

an

implicit

confirmation

of

the

adequate

degree

of

concurrency

of

that

model

Given

term

t

we

define

now

formally

its

derivation

space

as

the

subset

of

cells

originating

from

t

-LRB-

Derivation

Spaces

-RRB-

Let

R

h

L

Ri

be

a

rewriting

system

and

t

T

-LRB-

X

-RRB-

The

Meseguer

's

derivation

space

-LRB-

t

-RRB-

associated

to

t

is

the

partial

order

-LRB-

t

-RRB-

where

-LRB-

t

-RRB-

is

the

set

of

coinitial

cells

in

-LRB-

R

-RRB-

originating

from

t

and

is

the

partial

ordering

relation

defined

as

An

equivalent

definition

could

be

given

in

categorical

terms

Let

us

assume

that

t

n

and

let

us

denote

-LRB-

R

-RRB-

-LSB-

n

-RSB-

by

C

then

the

objects

of

the

comma

category

-LRB-

t

C

-RRB-

coincide

with

the

elements

of

the

derivation

space

-LRB-

t

-RRB-

The

same

relation

holds

for

sesqui-categorical

models

iff

there

exists

such

that

Similarly

we

define

the

Stell

's

derivation

space

LS

-LRB-

t

-RRB-

hDS

-LRB-

t

-RRB-

vSi

by

simply

replacing

-LRB-

R

-RRB-

with

S-Th

-LRB-

R

-RRB-

in

the

above

definition

ut

It

turns

out

that

in

general

the

derivation

spaces

induced

by

models

fail

to

satisfy

the

distributive

property

of

pad

's

since

the

ordering

in

which

rewrites

are

executed

influences

the

number

of

basic

steps

which

are

to

be

This

is

summarized

by

a

ve

result

of

category

theory

due

to

the

structure

of

cells

in

a

cartesian

no

notion

of

length

is

definable

As

for

a

counterexample

to

distributivity

let

us

consider

the

rewriting

system

W

defined

in

the

previous

section

If

we

look

at

the

space

of

computations

-LRB-

W

-RRB-

and

the

term

f

-LRB-

a

-RRB-

the

associated

derivation

space

-LRB-

f

-LRB-

a

-RRB-

-RRB-

has

the

following

structure

-LRB-

where

the

partial

ordering

flows

downwards

-RRB-

ida

f

R

f

a

L

d

a

L

d

R

-LRB-

a

-RRB-

g

a

L

d

R

-LRB-

a

-RRB-

g

R

f

b

L

d

a

L

d

-LRB-

-RRB-

g

Let

x

a

L

d

R

-LRB-

a

-RRB-

g

y

a

L

d

R

-LRB-

a

-RRB-

g

and

z

R

f

then

z

-LRB-

xty

-RRB-

uz

-LRB-

xuz

-RRB-

t

-LRB-

y

uz

-RRB-

ida

f

hence

-LRB-

f

-LRB-

a

-RRB-

-RRB-

is

not

distributive

In

categorical

terms

this

means

that

to

allow

together

the

cartesian

structure

and

the

interchange

axiom

does

not

permit

to

recover

a

pad

semantics

since

the

execution

ordering

influences

in

models

the

number

of

basic

steps

it

creates

a

causal

link

between

different

processors

Instead

in

Stell

's

approach

the

interchange

axiom

is

dropped

still

preserving

the

cartesian

structure

on

cells

this

way

we

are

able

to

state

the

following

theorem

-LRB-

Derivation

Spaces

and

pad

's

-RRB-

Let

R

h

L

Ri

be

a

rewriting

system

For

any

t

T

-LRB-

X

-RRB-

the

po

LS

-LRB-

t

-RRB-

is

a

coherent

finitary

pad

ut

Conclusions

The

main

purpose

of

this

paper

was

to

analyze

two

categorical

semantics

for

term

rewriting

systems

proposed

in

the

literature

To

this

aim

we

firstly

introduced

a

new

unified

presentation

for

them

Then

we

showed

that

the

derivation

spaces

associated

to

Stell

's

model

are

prime

algebraic

domains

that

is

a

well

accepted

model

for

expressing

the

concurrency

of

an

abstract

formalism

On

the

contrary

this

is

not

true

in

general

for

the

derivation

spaces

associated

to

Meseguer

's

model

-LRB-

based

on

cartesian

structure

plus

interchange

axiom

-RRB-

The

same

result

could

be

inferred

also

by

the

analysis

of

-LSB-

-RSB-

In

the

first

paper

it

is

shown

that

the

equivalence

induced

on

rewrites

in

Meseguer

's

space

of

computations

coincides

with

permutation

equivalence

In

the

second

it

is

shown

that

in

the

case

of

calculus

-LRB-

and

more

generally

for

any

trs

-RRB-

permutation

equivalence

can

not

be

the

basis

for

a

prime

algebraic

domain

semantics

However

we

view

Stell

's

proposal

as

too

narrow

dropping

interchange

means

limiting

the

degree

of

concurrency

expressible

by

the

model

in

an

unacceptable

way

For

instance

let

us

consider

the

rewriting

system

V

-LRB-

Section

-RRB-

the

computations

corresponding

to

d

-LRB-

a

-RRB-

and

d

-LRB-

b

-RRB-

f

-LRB-

a

-RRB-

g

-LRB-

b

-RRB-

are

not

equated

in

the

sesqui-category

S-Th

-LRB-

V

-RRB-

On

the

other

hand

the

model

fails

to

generate

a

sc

pda

when

non-linear

rewriting

rules

are

involved

-LRB-

a

rule

is

linear

if

each

variable

appears

exactly

once

both

in

the

left

and

right-hand

side

-RRB-

since

for

such

rules

the

execution

order

influences

the

number

of

basic

steps

to

be

performed

As

an

example

in

the

-LRB-

W

-RRB-

-LRB-

Section

-RRB-

the

following

derivations

with

different

length

are

equated

a

b

OO

OO

ha

ai

hb

bi

OO

OO

ha

ai

OO

OO

OO

hb

bi

OO

OO

ha

bi

-LRB-

y

-RRB-

a

b

OO

OO

-LRB-

z

-RRB-

where

L

idbi

and

hida

The

cartesian

structure

on

cells

allows

for

implicit

garbage

collection

and

duplication

-LRB-

as

discussed

in

-LSB-

-RSB-

-RRB-

these

housekeeping

operations

are

performed

silently

in

the

sense

that

the

abstract

machine

corresponding

to

the

model

can

not

distinguish

for

instance

between

states

where

garbage

has

been

already

collected

and

states

where

it

has

not

The

situation

is

well-shown

by

-LRB-

y

-RRB-

and

-LRB-

z

-RRB-

it

seems

evident

that

models

with

interchange

axiom

and

implicit

behaviour

on

these

operation

can

not

be

the

basis

for

a

pad

semantics

Stell

's

solution

still

keeps

these

operations

silent

while

dropping

interchange

forces

the

model

to

distinguish

between

derivations

differing

for

the

order

of

execution

of

nested

rewrites

A

current

trend

of

work

is

investigating

the

case

of

preserving

interchange

and

dealing

with

some

kind

of

weak

cartesianity

-LRB-

along

the

line

of

Jacobs

-LSB-

-RSB-

for

the

semantics

of

linear

logic

-RRB-

making

housekeeping

explicit

Although

a

detailed

discussion

about

the

actual

implementability

of

term

rewriting

in

a

way

reflecting

the

degree

of

concurrency

of

either

models

goes

beyond

the

scope

of

this

paper

some

comment

is

in

order

Even

if

the

computations

of

the

model

do

not

form

a

pad

it

does

not

mean

that

the

model

can

not

be

implemented

on

a

parallel

computer

as

by

the

way

has

been

shown

by

Meseguer

's

work

on

the

Rewriting

Rule

Machine

-LRB-

see

-LSB-

-RSB-

-RRB-

However

if

a

concurrent

machine

-LRB-

one

with

loosely

coupled

processors

-RRB-

is

chosen

as

target

the

results

of

this

paper

show

that

the

model

can

not

be

implemented

directly

i.e.

by

representing

operations

of

processors

with

events

of

a

pes

having

the

same

domain

of

computations

Of

course

the

model

can

be

mapped

to

a

concrete

concurrent

machine

but

the

compilation

process

should

be

designed

carefully

in

order

to

minimize

hidden

expensive

synchronizations

and

sequentializations

of

processors

which

are

unavoidable

according

to

our

results

Acknowledgments

We

wish

to

thank

Jos?e

Meseguer

for

the

interesting

discussions

and

his

careful

reviewing

of

the

manuscript

References

-LSB-

-RSB-

J.A.

Goguen

J.W.

Tatcher

E.G.

Wagner

J.R.

Wright

Initial

Algebra

Semantics

and

Continuous

Algebras

Journal

of

ACM

-LRB-

-RRB-

pp.

-LSB-

-RSB-

G.

Boudol

Computational

Semantics

of

Term

Rewriting

Systems

in

Algebraic

Methods

in

Semantics

eds

M.

Nivat

and

J.

Reynolds

Cambridge

University

Press

-LSB-

-RSB-

A.

Corradini

F.

Gadducci

CPO

Models

for

Infinite

Term

Rewriting

draft

-LSB-

-RSB-

A.

Corradini

Term

Rewriting

in

Parallel

draft

-LSB-

-RSB-

N.

Dershowitz

J.P.

Jouannaud

Rewrite

Systems

Handbook

of

Theoretical

Computer

Science

B

ed

J.

van

Leeuwen

North

Holland

pp.

-LCB-

-LSB-

-RSB-

B.

Jacobs

Semantics

of

Weakening

and

Contraction

draft

-LSB-

-RSB-

G.M.

Kelly

Basic

Concepts

of

Enriched

Category

Theory

London

Mathematical

Society

LN

Series

-LSB-

-RSB-

G.M.

Kelly

R.H.

Street

Review

of

the

Elements

of

Lecture

Notes

in

Mathematics

pp.

-LSB-

-RSB-

C.

Laneve

Distributive

Evaluations

of

calculus

Fundamenta

Informaticae

-LRB-

-RRB-

pp.

-LSB-

-RSB-

F.

W.

Lawvere

Functorial

Semantics

of

Algebraic

Theories

Proc

National

Academy

of

Science

pp.

-LSB-

-RSB-

J.J.

L?evy

Optimal

Reductions

in

the

calculus

in

To

H.B.

Curry

Essays

in

Combinatory

Logic

Lambda

Calculus

and

Formalism

eds

J.P.

Seldin

and

J.R.

Hindley

Academic

Press

pp.

-LSB-

-RSB-

C.

Laneve

U.

Montanari

Axiomatizing

Permutation

Equivalence

in

the

calculus

in

Proc

ALP

LNCS

pp.

-LSB-

-RSB-

P.

Lincoln

J.

Meseguer

L.

Ricciulli

The

Rewrite

Rule

Machine

Node

Architecture

and

its

Performance

in

Proc

CONPAR

LNCS

pp.

-LSB-

-RSB-

J.

Meseguer

Functorial

Semantics

of

Rewrite

Systems

appendix

of

Rewriting

as

a

Unified

Model

of

Concurrency

SRI

Technical

Report

-LSB-

-RSB-

J.

Meseguer

Conditional

Rewriting

Logic

as

a

Unified

Model

of

Concurrency

in

Selected

Papers

of

Workshop

on

Concurrency

and

Compositionality

Theoretical

Computer

Science

pp.

-LSB-

-RSB-

S.

MacLane

Categories

for

the

Working

Mathematician

Springer

-LSB-

-RSB-

N.

Mart

Oliet

J.

Meseguer

Rewriting

Logic

as

a

Logical

and

Semantic

Framework

SRI

Technical

Report

-LSB-

-RSB-

A.J.

Power

An

Abstract

Formulation

for

Rewrite

Systems

in

Proc

CTCS

LNCS

pp.

-LSB-

-RSB-

D.E.

Rydeheard

J.G.

Stell

Foundations

of

Equational

Deduction

in

Proc

CTCS

LNCS

pp.

-LSB-

-RSB-

J.

G.

Stell

Categorical

Aspects

of

Unification

and

Rewriting

Ph.D.

Thesis

Faculty

of

Science

University

of

Manchester

-LSB-

-RSB-

J.

G.

Stell

Modelling

Term

Rewriting

System

by

Sesqui-categories

Technical

Report

Keele

University

-LSB-

-RSB-

R.H.

Street

Categorical

Structures

in

Handbook

of

Algebra

eds

M.

Hazewinkel

et

al.

Elsevier

preprint

-LSB-

-RSB-

G.

Winskel

An

Introduction

to

Event

Structures

Lecture

Notes

for

the

REX

Summer

School

LNCS

pp.

categorical models
concurrency
rewriting logic
term rewriting


A technique for adding range restrictions to generalized searching problems Prosenjit Gupta ? Ravi Janardany Michiel Smidz August 30 , 1996 Abstract In a generalized searching problem , a set S of n colored geometric objects has to be stored in a data structure , such that for any given query object q , the distinct colors of the objects of S intersected by q can be reported efficiently . In this paper , a general technique is presented for adding a range restriction to such a problem . The technique is applied to the problem of querying a set of colored points -LRB- resp . fat triangles -RRB- with a fat triangle -LRB- resp . point -RRB- . For both problems , a data structure is obtained having size O -LRB- n1 + ffl -RRB- and query time O -LRB- -LRB- log n -RRB- 2 + C -RRB- . Here , C denotes the number of colors reported by the query , and ffl is an arbitrarily small positive constant . 1 Introduction Geometric searching problems arise in a large variety of application areas , such as computer graphics , robotics , VLSI layout design , and databases . In such a problem , a set S of n geometric objects has to be stored in a data structure , such that for any given query object q , we can efficiently report all objects of S that intersect q . The efficiency of such a data structure is typically expressed by its size and query time , where the latter has the form O -LRB- f -LRB- n -RRB- + K ? g -LRB- n -RRB- -RRB- , for some \ small '' functions f and g . In this expression , K denotes the number of elements of S that intersect the query object . We call these problems standard searching problems , in order to distinguish them from generalized searching problems , which are the subject of this paper . ? Max-Planck-Institut f?ur Informatik , Im Stadtwald , D-66123 Saarbr?ucken , Germany . E-mail : pgupta@mpi-sb.mpg.de . yDepartment of Computer Science , University of Minnesota , Minneapolis , MN 55455 , U.S.A. E - mail : janardan@cs.umn.edu . This author was supported by a Grant -LCB- in -LCB- Aid of Research from the Graduate School of the University of Minnesota . zDepartment of Computer Science , King 's College London , Strand , London WC2R 2LS , United Kingdom . E-mail : michiel@dcs.kcl.ac.uk . Part of this work was done while the author was visiting the Max-Planck-Institut f?ur Informatik , Saarbr?ucken . In many applications , a more general form of searching problem arises : The objects in S come aggregated in disjoint groups and of interest are questions regarding the intersection of q with the groups rather than with the objects . Here , we say that q intersects a group if and only if it intersects at least one object in the group . We will associate with each group a different color and imagine that all the objects in the group have that color . Then , in the generalized searching problem , we want to report the distinct colors of those elements of S that intersect q. Note that the generalized problem reduces to the standard one when each color class has cardinality one . For applications of these generalized searching problems , see -LSB- 1 , 4 , 6 , 8 -RSB- . We can solve a generalized searching problem by first determining the objects of S that intersect q and then reading off the distinct colors . However , the query time can be very high since q could intersect ? -LRB- n -RRB- objects but only O -LRB- 1 -RRB- distinct colors . For a generalized searching problem , we want to obtain query times that are sensitive to the number C of distinct colors intersected , rather than K. Typically , our goal is to obtain query times of the form O -LRB- f -LRB- n -RRB- + C -RRB- or O -LRB- f -LRB- n -RRB- + C ? g -LRB- n -RRB- -RRB- , where f and g are polylogarithmic . Generalized searching problems first appeared in -LSB- 6 -RSB- . Subsequently , several papers were published on these type of problems . See -LSB- 1 , 3 , 4 , 5 , 7 , 8 -RSB- . In this paper , we consider the problem of transforming generalized searching problems into other problems by adding a range restriction . This transformation was introduced for standard searching problems by Bentley -LSB- 2 -RSB- . Let PR -LRB- q ; S -RRB- denote the answer to a generalized searching problem PR with query object q and object set S. To add a range restriction to PR , we give each object p in S an additional parameter kp 2 IR . In the transformed searching problem , we only query objects in S that have their parameter in a given range . We define this more precisely . Definition 1 Let PR -LRB- q ; S -RRB- be a generalized searching problem for a set S of objects with query object q. To add a range restriction , we associate with each object p in S a real number kp . In the transformed generalized searching problem TPR , a query consists of a query object q together with an interval -LSB- a ; b -RSB- , and TPR -LRB- q ; -LSB- a ; b -RSB- ; S -RRB- : = PR -LRB- q ; fp 2 S : a < = kp < = bg -RRB- : In the case where the range restriction is of the form -LRB- ? 1 ; b -RSB- or -LSB- a ; 1 -RRB- , we speak about a half-infinite range restriction . As an example , consider the d-dimensional generalized orthogonal range searching problem , in which we are given a set S of n colored points in IRd . The query is an axes-parallel d-box q , and we want to report the distinct colors of those points that are contained in q . This problem is obtained by adding a range restriction to the -LRB- d ? 1 -RRB- - dimensional generalized range searching problem . As mentioned , the notion of adding a range restriction -LRB- for standard problems -RRB- first appeared in Bentley -LSB- 2 -RSB- . He gave a general technique that transforms a data structure for solving the standard problem PR into a data structure for the standard problem TPR . Later , other general techniques were developed by Willard and Lueker -LSB- 11 -RSB- , Generalized Problem Space Query Time Reference Querying Points with Fat Triangles n -LRB- log n -RRB- 3 -LRB- log n -RRB- 4 + C -LRB- log n -RRB- 2 -LSB- 5 -RSB- n1 + ffl -LRB- log n -RRB- 2 + C this paper Querying Fat Triangles with Points n -LRB- log n -RRB- 2 -LRB- log n -RRB- 3 + C log n -LSB- 5 -RSB- n1 + ffl -LRB- log n -RRB- 2 + C -LSB- 5 -RSB- n1 + ffl -LRB- log n -RRB- 2 + C this paper Table 1 : Overview of results for generalized problems on fat triangles . All bounds given are \ big -LCB- oh '' . C denotes the output size , and ffl is an arbitrarily small positive constant . Scholten and Overmars -LSB- 10 -RSB- , van Kreveld -LSB- 8 -RSB- , and Lenhof and Smid -LSB- 9 -RSB- . With the exception of -LSB- 8 -RSB- , these techniques can be applied to generalized searching problems , but this leads to data structures in which each color may be reported a logarithmic number of times . -LRB- That is , using the notation above , we have g -LRB- n -RRB- = ? -LRB- log n -RRB- . -RRB- The results in -LSB- 8 -RSB- provide structures where each color is reported at most a constant number of times . We discuss this in more detail below . The main result of this paper is a general technique that transforms data structures DS and TDS solving the generalized searching problems PR and TPR , respectively , into a data structure TDS solving TPR that uses much less space than TDS does . More precisely , if we start with -LRB- i -RRB- a data structure DS having O -LRB- polylog -LRB- n -RRB- + C -RRB- query time and using O -LRB- n1 + ffl -RRB- space , and -LRB- ii -RRB- a data structure TDS having O -LRB- polylog -LRB- n -RRB- + C -RRB- query time and using -LRB- possibly high -RRB- polynomial space , and apply the transformation several times , we get a data structure for TPR having O -LRB- polylog -LRB- n -RRB- + C -RRB- query time and using only O -LRB- n1 + ffl -RRB- space . Here , ffl is an arbitrarily small positive constant . We remark that in earlier work , van Kreveld presented an alternative approach for obtaining O -LRB- n1 + ffl -RRB- space and O -LRB- polylog -LRB- n -RRB- + C -RRB- query time for range-restricted colored problems ; see Theorem 5.1 -LRB- ii -RRB- , Theorem 5.3 -LRB- ii -RRB- , and Corollary 7.3 -LRB- i -RRB- in -LSB- 8 -RSB- . His work is based on multiway balanced search trees with secondary structures . Our approach is different : we construct TDS iteratively from DS and TDS by using a \ bootstrapping '' approach , which is interesting in its own right . We illustrate our general technique by giving efficient data structures for the following two problems : Store a set of colored points -LRB- resp . fat triangles -RRB- in a data structure , such that for any query fat triangle -LRB- resp . point -RRB- q , we can report the distinct colors of those points -LRB- resp . triangles -RRB- that are contained in -LRB- resp . contain -RRB- q. Here , a triangle is called fat , if all its angles are at least equal to some fixed constant . This problem was considered before in -LSB- 5 -RSB- . See Table 1 for this and our results . Again , some of our results were known already . However , the techniques in this paper allow us to now derive these results in a unified way . The rest of this paper is organized as follows . In Section 2 , we give the general technique of adding a range restriction to a generalized searching problem . In Section 3 , we show how to apply this technique to generalized problems for fat triangles . We conclude the paper in Section 4 with some final remarks . We now discuss one important issue that arises in the encoding and handling of colors . Throughout the paper , we assume that our algorithms incorporate the mechanisms that we describe here and so we will not repeat them afterwards . The number of colors for a given problem can range from 1 to n . We encode each color as an integer in the range -LSB- 1 ; n -RSB- . This allows us to use colors as array indices . In many of our generalized searching problems , when answering a query we may encounter the same color more than once -LRB- but no more than O -LRB- 1 -RRB- times -RRB- . Our goal is to eliminate the duplicate colors efficiently before we output the answer . We can do this by using an array , A -LSB- 1 : n -RSB- , of colors to keep track of the distinct colors that are found during a query . We also store the distinct colors found in a linked list . After the query , A can be reset in time proportional to the output size by scanning the list . 2 Adding a half-infinite range restriction Let S be a set of n colored objects , and let PR -LRB- q ; S -RRB- be a generalized searching problem for S with query object q. Let each object p of S have an additional parameter kp 2 IR . Let TPR be the generalized searching problem that is obtained by adding a half-infinite range restriction to PR . Assume we have a data structure DS that stores the set S , such that generalized queries PR -LRB- q ; S -RRB- can be solved in O -LRB- -LRB- log n -RRB- u + C -RRB- time , for some positive constant u. Let the size of DS be bounded by O -LRB- n1 + ffl -RRB- , where ffl is an arbitrarily small positive constant . Also , assume we have a data structure TDS for the set S , such that generalized queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- can be solved in O -LRB- -LRB- log n -RRB- v + C -RRB- time , for some positive constant v. Let the size of TDS be bounded by O -LRB- nw -RRB- for some constant w > 1 . We will show how to construct a data structure that solves generalized queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- in O -LRB- -LRB- log n -RRB- max -LRB- u ; v -RRB- + C -RRB- time , using O -LRB- -LRB- n1 + ffl -RRB- space , for an arbitrarily small positive constant ffl . The basic transformation : Sort the elements of S in non-increasing order of their parameter kp . Let the sorted set be S = fp1 ; p2 ; : : : ; png , i.e. , kp1 > = kp2 > = : : : > = kpn . Let m be a parameter such that 1 < = m < = n. For < = i < n = m , let Si = fp1 ; p2 ; : : : ; pimg ; and S0i = fpim +1 ; pim +2 ; : : :p -LRB- i +1 -RRB- mg : For each i , < = i < n = m , we store the set Si in a data structure DS i -LRB- of type DS -RRB- for solving generalized queries of the form PR -LRB- q ; Si -RRB- . Moreover , we store the set S0i in a data structure TDS i -LRB- of type TDS -RRB- for solving generalized queries of the form TPR -LRB- q ; -LSB- a ; 1 -RRB- ; S0i -RRB- . Having defined the transformed data structure , we show how to answer generalized queries of the form TPR -LRB- q ; -LSB- a ; 1 -RRB- ; S -RRB- . Without loss of generality we may assume that a < = kp1 and a > kpn ; otherwise , in the former case , the answer is the empty set while in the latter case there is effectively no range-restriction . Find the index i such that kpim > = a > kp -LRB- i +1 -RRB- m : Then , solve the generalized query PR -LRB- q ; Si -RRB- using the structure DS i , and solve the generalized query TPR -LRB- q ; -LSB- a ; 1 -RRB- ; S0i -RRB- using the structure TDS i. Output the union of the colors reported by these two queries , after having removed duplicate colors . Lemma 1 The basic transformation results in a data structure for the generalized searching problem TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- 1 . with a query time of O -LRB- -LRB- log n -RRB- max -LRB- u ; v -RRB- + C -RRB- , 2 . using O -LRB- n2 + ffl = m + nmw ? 1 -RRB- space . Proof : To prove the correctness of the query algorithm , observe that all elements p of Sn -LRB- Si -LSB- S0i -RRB- have a parameter kp that is smaller than a. Hence , these elements certainly do not satisfy the query . Moreover , all elements p of the set Si have a parameter kp that satisfies the range restriction . It is clear that the query time of the transformed data structure is bounded by O -LRB- -LRB- log n -RRB- max -LRB- u ; v -RRB- + C -RRB- . -LRB- Note that each color is reported at most once by the query on DS i and , similarly , by the query on TDS i. -RRB- It remains to prove the space bound . The total size of the structures DS i , < = i < n = m , is bounded by O @ n = m X i = 0 -LRB- im -RRB- 1 + ffl 1 A = O ? m1 + ffl ? -LRB- n = m -RRB- 1 + ffl ? -LRB- n = m -RRB- ? = O -LRB- n2 + ffl = m -RRB- : Similarly , the total size of the structures TDS i is bounded by O @ n = m X i = 0 mw 1 A = O -LRB- nmw ? 1 -RRB- : This completes the proof . Using this lemma , we can prove the main result of this section . Theorem 1 Let DS be a data structure that stores a set S of n colored objects , such that generalized queries PR -LRB- q ; S -RRB- can be solved in O -LRB- -LRB- log n -RRB- u + C -RRB- time , for some positive constant u. Let the size of DS be bounded by O -LRB- n1 + ffl -RRB- , where ffl is an arbitrarily small positive constant . Let TDS be a data structure for the set S , such that generalized queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- can be solved in O -LRB- -LRB- log n -RRB- v + C -RRB- time , for some positive constant v. Let the size of TDS be bounded by O -LRB- nw -RRB- for some constant w > 1 . There exists a data structure that solves generalized queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- 1 . with a query time of O -LRB- -LRB- log n -RRB- max -LRB- u ; v -RRB- + C -RRB- , 2 . using O -LRB- n1 + ffl -RRB- space , for an arbitrarily small positive constant ffl . Proof : First assume that w > 2 , i.e. , the data structure TDS uses more than quadratic space . Choosing m = n1 = w in Lemma 1 gives a data structure for solving queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- , with a query time of O -LRB- -LRB- log n -RRB- max -LRB- u ; v -RRB- + C -RRB- , and using space O -LRB- n2 + ffl ? 1 = w + n2 ? 1 = w -RRB- ; which is bounded by O -LRB- n2 -RRB- , provided ffl < = 1 = w. Hence , we can assume that the generalized problem TPR can be solved with quadratic space and O -LRB- -LRB- log n -RRB- z + C -RRB- query time , where z = max -LRB- u ; v -RRB- . We will prove by induction that for any positive integer constant ` there is a data structure TDS ` for the generalized problem TPR , with O -LRB- -LRB- log n -RRB- z + C -RRB- query time , using O -LRB- n1 +1 = ` + ffl -RRB- space . Choosing ` large enough , the space bound becomes O -LRB- n1 +2 ffl -RRB- . Hence , starting with ffl = 2 instead of ffl will complete the proof . For ` = 1 , the claim has been proved already . So , let ` > = 1 , and assume the claim holds for ` . Apply Lemma 1 to the structures DS and TDS ` , choosing m = n ` =-LRB- ` +1 -RRB- . This gives a data structure TDS ` +1 for solving queries TPR -LRB- q ; -LSB- a : 1 -RRB- ; S -RRB- . Straightforward calculations show that TDS ` +1 has a query time of O -LRB- -LRB- log n -RRB- z + C -RRB- , and uses O -LRB- n1 +1 =-LRB- ` +1 -RRB- + ffl -RRB- space . Theorem 1 implies that in order to solve the generalized problem TPR , it suffices to have -LRB- i -RRB- a data structure for PR with polylogarithmic query time and O -LRB- n1 + ffl -RRB- space , and -LRB- ii -RRB- a data structure for TPR with polylogarithmic query time and polynomial space . In many applications , the latter data structure is obtained from the following result , which is due to van Kreveld -LSB- 8 -RSB- -LRB- Corollary 7.3 -LRB- ii -RRB- -RRB- . For convenience , we restate the result in -LSB- 8 -RSB- in a slightly different form . Theorem 2 -LRB- -LSB- 8 -RSB- -RRB- Let S be a set of n colored points in IRd , where d > = 2 is a constant , and let k be an integer constant . There exists a data structure of size O -LRB- nd + ffl -RRB- , such that for any query region q in IRd that is the intersection of at most k halfspaces , we can in O -LRB- log n + C -RRB- time report the C distinct colors of all points of S that are contained in q . Here ffl is an arbitrarily small positive constant . 3 Generalized query problems for fat triangles Let S be a set of n colored points in the plane . We want to store these points in a data structure , such that generalized fat triangle queries can be solved efficiently . In such a query , we are given a fat triangle , and we have to report the distinct colors of all points of S that are contained in the triangle . A triangle is called fat , if all its angles are at least equal to some fixed constant . We start by solving a simpler problem . Then , we apply Theorem 1 twice in order to get our result . Let R be a fixed ray that starts in the origin . If q is a point in the plane , then Rq denotes the ray that is obtained by translating R such that its starting point coincides with q , i.e. , Rq = R + q. Consider generalized queries of the following form : Given a point q and a ray T starting in q , such that T makes an angle at most ss with Rq . We want to report the distinct colors of those points of S that are contained in the wedge defined by T and Rq . By Theorem 2 , there is a data structure TDS for this wedge problem having O -LRB- log n + C -RRB- query time and using polynomial space . Let DS be the data structure of -LSB- 5 -RSB- for solving the generalized halfplane searching problem with O -LRB- -LRB- log n -RRB- 2 + C -RRB- query time using O -LRB- n log n -RRB- space . We show that we obtain the above wedge problem by adding a half-infinite range restriction to DS . In a query , we want to report the distinct colors of those points that are , say , below the line through T and , say , above the line through Rq . Let ` be the line through the origin orthogonal to R. Project all points of S onto ` . Each point of S gets this projection as the additional parameter . Note that these parameters define an ordering along ` in the natural way . A point of S is above the line through Rq if and only if its additional parameter is \ larger '' than the projection of q onto ` , where \ larger '' refers to the ordering along ` . Hence , among all points that are larger than q 's projection , we want the distinct colors of those that are below the line through T . Therefore , applying Theorem 1 to DS and TDS , we get the following result . Lemma 2 Let S be a set of n colored points in the plane , and let R be a fixed ray that starts in the origin . There exists a data structure of size O -LRB- n1 + ffl -RRB- such that for any point q and any ray T starting in q , such that T makes an angle at most ss with Rq -LRB- i.e. , the ray R translated to q -RRB- , we can report in O -LRB- -LRB- log n -RRB- 2 + C -RRB- time , all C distinct colors of those points of S that are contained in the wedge defined by T and Rq . Here , ffl is an arbitrarily small positive constant . Next , we show how to solve generalized fat wedge queries . In such a query , we are given a wedge whose angle is between and ss , where is a constant . Choose t = d2ss = ffe coordinate systems CS i = -LRB- xi ; yi -RRB- , all sharing the origin , such that CS i +1 is offset from CS i by an angle . For each i , let DS i be the data structure of Lemma 2 storing the points of S , where we take R = xi . A fat wedge query is solved as follows . Let q be the apex of the query wedge , and let A and B be its bounding rays . Find an index i , such that -LRB- xi -RRB- q | i.e. , xi translated by the vector q | is contained in the wedge . Then we query the data structure DS i twice , once with the wedge defined by A and -LRB- xi -RRB- q , and once with the wedge defined by B and -LRB- xi -RRB- q . We output the union of the colors reported by these two queries , after having removed duplicate colors . This proves : Lemma 3 Let S be a set of n colored points in the plane . There exists a data structure of size O -LRB- n1 + ffl -RRB- such that for any fat query wedge , we can report in O -LRB- -LRB- log n -RRB- 2 + C -RRB- time , all C distinct colors of those points of S that are contained in it . Here , ffl is an arbitrarily small positive constant . Now we are ready to consider generalized fat triangle queries . Let T be a fat query triangle . We decompose T into two triangles T1 and T2 by drawing a vertical line through the middle vertex . Hence , for i = 1 ; 2 , Ti has a vertical side , and the vertex opposite to this side has angle at least . We can think of Ti as a range-restricted fat-wedge query , where the additional parameter of a point of S is its x-coordinate . Our goal is to get a data structure DS for such a query which uses O -LRB- n1 + ffl -RRB- space and has a query time of O -LRB- -LRB- log n -RRB- 2 + C -RRB- . Given DS , we can solve the fat triangle query for T by querying DS with T1 and T2 , and reporting the union of the colors reported by these two queries . Let DS be the data structure of Lemma 3 . By Theorem 2 , there is a data structure TDS for range-restricted fat-wedge queries having O -LRB- log n + C -RRB- query time and using polynomial space . Then , Theorem 1 gives the data structure DS . This proves the following result . Theorem 3 Let S be a set of n colored points in the plane . There exists a data structure of size O -LRB- n1 + ffl -RRB- such that for any fat query triangle , we can report in O -LRB- -LRB- log n -RRB- 2 + C -RRB- time , all C distinct colors of those points of S that are contained in it . Here , ffl is an arbitrarily small positive constant . Using basically the same approach , we can solve the generalized searching problem of querying fat triangles with points . We leave the details to the reader . Theorem 4 Let S be a set of n colored fat triangles in the plane . There exists a data structure of size O -LRB- n1 + ffl -RRB- such that for any query point q , we can report in O -LRB- -LRB- log n -RRB- 2 + C -RRB- time , all C distinct colors of those triangles of S that contained q. Here , ffl is an arbitrarily small positive constant . 4 Concluding remarks We have given a general technique for adding a range restriction to a generalized searching problem . This results in data structures for generalized searching problems on fat triangles having O -LRB- -LRB- log n -RRB- 2 + C -RRB- query time using O -LRB- n1 + ffl -RRB- space . Our technique can also be used to solve the d-dimensional generalized orthogonal range searching problem with O -LRB- log n + C -RRB- query time and O -LRB- n1 + ffl -RRB- space . -LRB- This was known already , see Corollary 7.3 -LRB- i -RRB- in -LSB- 8 -RSB- . -RRB- It remains open if this problem can be solved with O -LRB- polylog -LRB- n -RRB- + C -RRB- query time and O -LRB- n -LRB- log n -RRB- O -LRB- 1 -RRB- n -RRB- space for dimensions d > = 4 . -LRB- For efficient solutions in dimensions d < = 3 , see -LSB- 4 , 6 -RSB- . -RRB- The results of this paper only apply to generalized reporting problems . In a generalized counting problem , we want to report the number of distinct colors of the objects that intersect the query object . Is there a general technique for adding a range restriction to such generalized counting problems ? References -LSB- 1 -RSB- P.K. Agarwal and M. van Kreveld . Connected component and simple polygon intersection searching . Proceedings 3th Workshop on Algorithms and Data Structures , Lecture Notes in Computer Science , Vol . 709 , Springer-Verlag , Berlin , 1993 , pp. 36 -LCB- 47 . -LSB- 2 -RSB- J.L. Bentley . Decomposable searching problems . Information Processing Letters 8 -LRB- 1979 -RRB- , pp. 244 -LCB- 251 . -LSB- 3 -RSB- P. Gupta , R. Janardan , and M. Smid . On intersection searching problems involving curved objects . Proceedings 4th Scandinavian Workshop on Algorithm Theory , Lecture Notes in Computer Science , Vol . 824 , Springer-Verlag , Berlin , 1994 , pp. 183 -LCB- 194 . -LSB- 4 -RSB- P. Gupta , R. Janardan , and M. Smid . Further results on generalized intersection searching problems : counting , reporting , and dynamization . Journal of Algorithms 19 -LRB- 1995 -RRB- , pp. 282 -LCB- 317 . -LSB- 5 -RSB- P. Gupta , R. Janardan , and M. Smid . Algorithms for generalized halfspace range searching and other intersection searching problems . Computational Geometry : Theory and Applications 5 -LRB- 1996 -RRB- , pp. 321 -LCB- 340 . -LSB- 6 -RSB- R. Janardan and M. Lopez . Generalized intersection searching problems . International Journal on Computational Geometry & Applications 3 -LRB- 1993 -RRB- , pp. 39 -LCB- 69 . -LSB- 7 -RSB- M. Katz . 3-D vertical ray shooting and 2-D point enclosure , range searching , and arc shooting amidst convex fat objects . Report INRIA , Nr . 2583 , 1995 . -LSB- 8 -RSB- M. van Kreveld . New results on data structures in computational geometry . Ph.D. . Thesis , Department of Computer Science , University of Utrecht , the Netherlands , 1992 . -LSB- 9 -RSB- H.-P . Lenhof and M. Smid . Using persistent data structures for adding range restrictions to searching problems . RAIRO Theoretical Informatics and Applications 28 -LRB- 1994 -RRB- , pp. 25 -LCB- 49 . -LSB- 10 -RSB- H.W. Scholten and M.H. Overmars . General methods for adding range restrictions to decomposable searching problems . Journal of Symbolic Computation 7 -LRB- 1989 -RRB- , pp. 1 -LCB- 10 . -LSB- 11 -RSB- D.E. Willard and G.S. Lueker . Adding range restriction capability to dynamic data structures . Journal of the ACM 32 -LRB- 1985 -RRB- , pp. 597 -LCB- 617 .

O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O B I O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O B I O O O O O O O O O O O O O O O

computational geometry
data structures
intersection searching
range restriction