DynFO A Parallel Dynamic

y

Neil Immerman SushantPatnaik

Computer Science Dept Computer Science Dept

University of Massachusetts University of Massachusetts

Amherst MA Amherst MA

patnaikbearcom immermancsumassedu

Abstract

Traditionally computational complexity has considered only static problems Clas

sical Complexity Classes suchasNCP and NP are dened in terms of the complexity

of checking up on presentation of an entire input whether the input satises a certain

prop erty

For many applications of computers it is more appropriate to mo del the pro cess as

a dynamic one There is a fairly large ob ject b eing worked on over a p erio d of time

The ob ject is rep eatedly mo died by users and computations are p erformed

Wedevelop a theory of Dynamic ComplexityWe study the new complexity class

Dynamic FirstOrder Logic DynFO This is the set of prop erties that can b e main

tained and queried in rstorder logic ie relational calculus on a relational database

We showthatmanyinteresting prop erties are in DynFO including multiplication graph

connectivity bipartiteness and the computation of minimum spanning trees Note that

none of these problems is in static FO and this fact has b een used to justify increasing

the p ower of query languages b eyond rstorder It is thus striking that these prob

lems are indeed dynamic rstorder and thus were computable in rstorder database

languages all along

We also dene b oundedexpansion reductions which honor dynamic complexity

classes Weprove that certain standard complete problems for static complexity classes

suchas REACH for P remain complete via these new reductions On the other hand

a

weprove that other such problems including REACH for NL and REACH for are

d

no longer complete via b oundedexpansion reductions Furthermore weshowthata

version of REACH calledREACH is not in DynFO unless all of P is contained

a a

in parallel linear time

Intro duction

Traditional complexity classes are not completely appropriate for database systems Unfor

tunately appropriate Database Complexity Classes havenotyet b een dened This pap er

makes a step towards correcting this situation

Research of b oth authors supp orted by NSF grants CCR and CCR

y

Current address Bear Stearns Park Avenue New York NY

In our view the main two dierences b etween database complexity and traditional com

plexity are

Databases are dynamic The work to b e done consists of a long sequence of small

up dates and queries to a large database Each up date and query should b e p erformed

very quickly in comparison to the size of the database

Computations on databases are for the most part disk access b ound The cost of

computing a request is usually tied closely to the numb er of disk pages that must b e

read or written to fulll the request

Of course a signicant p ercentage of all uses of computers have the ab ovetwo features In

this pap er we fo cus on the rst issue Dynamic complexity is quite relevantinmostday

to day tasks For example texing a le compiling a program pro cessing a visual scene

p erforming a complicated calculation in Mathematica etc Yet an adequate theory of

dynamic complexity is lacking Recently there have b een some signicantcontributions in

this direction eg MSV Note that dynamic complexity is dierent although somewhat

related to online complexitywhich is receiving a great deal of attention lately

We will dene the complexity class DynFO to b e the set of dynamic problems that can b e

expressed in rstorder logic What this means is that we maintain a database of relevant

information that the action invoked byeach insert delete and query is rstorder ex

pressible This is very natural in the database setting In fact DynFO is really the set of

queries that are computable in a traditional rstorder query language

Manyinteresting queries such as connectivity for undirected graphs are not rstorder when

considered as static queries This has led to muchwork on database query languages such

as Datalog that are more expressive than rstorder logic

We show the surprising fact that a wealth of problems including connectivity are in

DynFO Thus considered as dynamic problems and that is what database problems

are these problems are already rstorder computable The problems we showtobein

DynFO include reachability in undirected graphs maintaining a minimum spanning forest

k edge connectivity and bipartiteness All regular languages are shown to b e in DynFO

In P it is shown that some NPcomplete problems admit DynFO approximation algo

rithms Dong and Su DS showed that reachability in directed acyclic graphs and in

function graphs is in DynFO The static versions of all these problems are not rstorder

Related work on dynamic complexity app ears in MSV In DST rstorder incremen

tal evaluation system FOIES are dened A problem has an FOIES i it is in DynFO In

TY Tarjan and Yao prop ose a dynamic mo del whose complexity measure is the num

b er of prob es into a data structure and any other computation is free A log n log log n

lower b ound on a dynamic prex multiplication problem was proved in FS Other lower

b ounds M R have b een proved using these metho ds

Other work on dynamic complexity for databases includes the theory of maintaining materi

alized views up on up dates J GMS Io and in integrity constraint simplication

LST N The design of dynamic is an active eld See for example

E E b R CT F F among many others There is also a large

amountofwork in the programming language community on incremental computation see

for example RR LT

This pap er is organized as follows In Section we b egin with some background on Descrip

tive Complexity In Section for any static complexityclass C we dene the corresp onding

dynamic class DynC The class DynFO is the case we emphasize In Section we present

the ab ovementioned DynFO algorithms In Section we describ e and investigate reduc

tions honoring dynamic complexity Finallywe suggest some future directions for the study

of dynamic complexity

Descriptive Complexity Background and Denitions

In this section we recall the notation of Descriptive Complexity See I for a survey and

IL for an extensive study of rstorder reductions

In the development of descriptive complexity it has turned out that natural complexity

classes have natural descriptivecharacterizations For example space corresp onds to

number of variables and parallel time is linearly related to quantierdepth Sequential

time on the other hand do es not seem to have a natural descriptivecharacterization We

liketothinkofthisasyet another indication that sequential time is not a natural notion

simply an artifact of the socalled VonNeumann b ottleneck As another example the

class P consisting of those problems that can b e p erformed in a p olynomial amountofwork

has an extremely natural characterization as FOLFP rstorder logic closed under the

ability to make inductive denitions

It is reassuring that our notions of naturalness in logic corresp ond so nicely with naturalness

in complexity theory In the presentwork weventure into the terrain of dynamic complexity

What is natural is not yet clear We use the intuitions gained from the descriptive approach

to aid us in our search

We will co de all inputs as nite logical structures ie relational databases A vocabulary

a

a

r

c c i is a tuple of input relation and constantsymb ols A structure hR R

s

r

A A A A

with vo cabulary is a tuple A hjAjR R c c i whose universe is the nonempty

r s

A

set jAjFor each relation symbol R of arity a in A has a relation R of arity a dened

i i i

i

A a

i

on jAj ie R jAj For each constantsymbol c A has a sp ecied elementofits

j

i

A

jAjWe use the notation jjAjj to denote the cardinality of the universe of A universe c

j

Since we are only interested in nite structures we let STRUC denote the set of nite

structures of vo cabulary We dene a complexity theoretic problem to b e anysubset

S STRUC for some A problem is the same thing as a b o olean query

For anyvo cabulary there is a corresp onding rstorder language L built up from the

symb ols of and the numeric relation symb ols and BIT and numeric constants

min max using logical connectives variables x y z and quantiers

represents a total ordering on the universe whichmaybeidentied with the set f n

g The constants min max represent the minimum and maximum elements in this ordering

th

BITx y means that when x is co ded as a log n bit numb er the y bit of this enco ding is

a one

In static complexitytheentire input structure A is xed and weareinterested in deciding

whether AS forarelevant prop erty S In the dynamic case the structure changes over

time The actions wehave in mind are a sequence of insertions and deletions of tuples in

the input relations We will usually think of our dynamic structure A hf n

gR R c c iashaving a xed size p otential universe jAj f n g

r s

and a unary relation R sp ecifying the elements in the active domain The initial structure

n

of size n for this vo cabulary will b e taken to b e A hf n g fg i

having R fg indicating that the single element is in the active domain and all other

relations are empty

FirstOrder Reductions

Here we briey describ e rstorder reductions a natural way of reducing one problem to

another in the descriptivecontext Firstorder reductions are used in Section to build new

reductions that honor dynamic complexityFurthermore reductions are used in Section as

a motivation for the denition of Dynamic Complexity More information ab out rstorder

reductions can b e found in IL Recall that a rstorder query is a rstorder denable

mapping from structures of one vo cabulary to structures of another A rstorder reduction

is simply a rstorder query that is also a manyone reduction We give an example and

then the formal denition

Example Let graph reachability denote the following problem given a graph Gand

vertices s t determine if there is a path from s to t in GWe shall use REACH to denote

graph reachability on directed graphs Let REACH b e the restriction of REACH to

u

undirected graphs Let REACH b e the restriction of REACH in whichwe only allow

d

deterministic paths ie if the edge u v is on the path then this must b e the unique edge

leaving u Notice that REACH is reducible to REACH as follows Given a directed

u

d

graph Glet G b e the undirected graph that results from G by the following steps

Remove all edges out of t

Removeallmultiple edges leaving anyvertex

Make each remaining edge undirected

Observe that there is a deterministic path in G from s to t i there is a path from s to t in

G

The following rstorder formula accomplishes these three steps and is thus a rst

du

order reduction from REACH to REACH More precisely the rstorder reduction

u

d

is the expression I st whose meaning is Make the new edge relation

xy

du du

fx y j gandmaps to s and t to t

du

x y E x y x t z E x z z y

x y x y y x

du

I is a unary rstorder reduction it leaves the size of the universe unchanged Nowwe

du

dene k ary rstorder reductions These map structures with universe size n to structures

k

with universe size n

Denition FirstOrder Reductions Let and be twovo cabularies with

a

a

r

R hR c c i Let S STRUC T STRUC betwo problems Let k be

s

r

a p ositiveinteger Supp ose we are given an r tuple of formulas L i r

i

where the free variables of are a subset of fx x g Finally supp ose we are

i

k a

i

t t where each t is a k tuple of constantsymb ols from L given an stuple

s j

Let I t t i b e a tuple of these formulas and constants Here h

x x s r

d

d max ka Then I induces a mapping also called I from STRUC toSTRUC as

i i

follows Let A STRUC and let n jjAjj

k

I A hfn gR R t t i

r s

Here each c is given by the corresp onding k tuple of constants The relation R is deter

j i

k

mined by the formula fori r More precisely let the function hi jAj

i

jI Aj b e given by

k

hu u u i u u n u n

k k k

Then

R fhu u ihu u i jAj u u g

i i

k ka ka

k a

i i

i

Supp ose that I isamanyone reduction from S to T ie for all A in STRUC

AS I A T

Then wesay that I is a k ary rstorder reduction of S to T

Dynamic Complexity Classes

We think of an implementation of a problem S STRUC as a mapping I from

STRUC toSTRUC where T STRUC is an easier problem The map I should b e a

manyone reduction from S to T meaning that any structure A has the prop erty S i I A

has the prop erty T Actually in our denition b elow the mapping I will map a sequence

of inserts deletes and changesr to a structure In the interesting sp ecial case when I r

dep ends only on the corresp onding structure A and not which sequence of requests created

it we call I memoryless

The idea is that I A is the data structure our internal representation of A We are

thinking and talking ab out a structure ASTRUC but the structure that we actually

have in memory and disk and are manipulating is I A STRUC In this wayeach

request to A is interpreted as a corresp onding series of actions on I A The fact that I

isamanyone reduction insures that the query asking whether AS can b e answered

according as whether I A T In order for this to b e useful T must b e a problem of low

dynamic complexity

Next wegive the formal denition of dynamic complexity classes The issue is that the

structure I A can b e up dated eciently in resp onse to any request to A In particular if

T FOandallsuch requests are rstorder computable then S DynFO

Denition of DynC

For any complexity class C we dene its dynamic version DynC as follows Let

a

a

r

hR c c i be a vo cabulary and let S STRUC beany problem Let R

s

r

a

i

R finsi a deli a setj a j i r a f n g j sg

n

b e the set of p ossible requests to insert tuplea into the relation R delete tuplea from

i

relation R or set constant c to a Let R b e the set of nite sequences from R

i j n

n

STRUC b e the naturally dened evaluation of a sequence of requests Let eval R

n

n

n

initialized byeval A

n

Dene S Dyn C i there exists another problem T STRUC suchthatT C and

there exist maps

f R STRUC g STRUC R STRUC

n n n

n

satisfying the following prop erties

For allr R eval r S f r T

n n

n

For all s R andr R f rsg f r s

n n n n

n

O

jjf r jj jjeval r jj

n n

The functions g and the initial structure f are uniformly computable in com

n n

plexity C as a function of n

Note that the condition says that each single request s R can b e resp onded to

n

quickly ie with complexity C According to the denition of R the kind of up dates

n

allowed are single inserts or deletes of tuples and assignments to constants Of course it

would b e interesting to consider other p ossible sets of up dates

We will say that the ab ovemapf is memoryless if the value of f r dep ends only on

eval r

n

In the ab ove if no deletes are allowed then we get the class Dyn C the semidynamic

s

version of C One can also consider amortized versions of these two classes Furthermore

there are some cases where wewould like extra but p olynomial precomputation to compute

the initial structure f If we relax condition in this way then the resulting class is

called DynC Dyn C with p olynomial precomputation

Wehavethus dened the dynamic complexity classes DynC for any static class C Two

particularly interesting examples are DynFO and DynTIMEtn for tn less than n

where the latter is the set of problems computable dynamically on a RAM with word size

O log n in time tn

Example Consider the simple b o olean query PARITY which is true i the input

binary string has an o dd numb er of ones This is well known not to b e in static FO

This exp ects that the complexity class C is closed under p olynomial increases in the input size For more

restricted classes C such as linear time we insist that jjf r jj O jjeval r jj

n n

A FSS The dynamic for PARITY maintains a bit b which is toggled after

anychange to the string We also rememb er the input string so that we can tell if a request

has actually changed the string

The vo cabulary of the PARITY problem is hM i consisting of a single monadic relation

th

symb ol Let A b e the structure co ding the binary string w ThenA j M iithe i

w w

bit of w is a one Let hM bi where b is a b o olean constant symb ol The problem T

obviouslyinFO is given as follows

T fA STRUC jAj bg

The initial data structure f hf n g false i consists of a string of all s

n

with the b o olean b initialized to false

ToshowthatPARITY is in DynFOwe need to give the rstorder formulas that compute

g B s for any request s R The cases are the setting of a bit of w to or Let M b

n n

denote the relations in the data structure B b efore the request and M b are their values

afterwards

insa M

M M x x a

b b M a b M a

dela M

M M x x a

b b M a b M a

Note In the denition of DynC we assumed that our problem S had only the basic

requests R Equation dened The denition of DynC remains valid when we allow

n

an arbitrary set of op erations O to b e p erformed on the input structures It thus makes

n

sense to ask whether any data structure with a given set of op erations is in DynC

Problems in DynFO

It is well known that the graph reachability problem is not rstorder expressible and this

has often b een used as a justication for using database query languages more p owerful

than FO CH Thus the following two theorems are striking

Theorem REACH is in DynFO

u

Pro of Wemaintain a spanning forest of the underlying graph via relations Fx y and

PVx y u and the input relation E Fx y means that the edge x y is in the current

spanning forest PVx y u means that there is a unique path in the forest from x to y

via vertex u The vertex umay b e one of the endp oints So for example if Fx y is true

then so are PVx y x and PVx y y Wemaintain the undirected nature of the graph

byinterpreting insertEa b or deleteEa b to do the op eration on b oth a bandb a

InsertE a bWe denote the up dated relations as E F and PV In the sequel we shall

use Px y to abbreviate x y PV x y x and Eqx y c d to abbreviate the formula

x c y d x d y c

Maintaining the input edge relation is trivial

E x y Ex y Eqx y a b

The edges in the forest remain unchanged if vertices a and b were already in the same

connected comp onent Otherwise the only new forest edge is a b

F x y Fx y Eqx y a b Pa b

Now all that remains is to compute PV The latter changes i edge a b connects two

formerly disconnected trees In this case all new tuples x y z have x coming from one of

the trees containing a and bandy coming from the other

PV x y z PV x y z uv Equ v a b P x u P v y

PV x u z PV v y z

DeleteE a bIfedgea b is not in the forest Fa b then the up dated relations are

unchanged except that E a b is set to false Otherwise we rst identify the vertices of

the two trees in the forest created by the deletion and then we pick an edge say eoutof

all the edges if any that run b etween the two trees and insert e into the forest up dating

the relations PV and F appropriately

We dene a temp orary relation T to denote the PV relation after a b is deleted b efore

the new edge e is inserted

Tx y z PVx y z PV x y a PVx y b

Using T we then pick the new edge that must b e added to the spanning forest Newx y

is true if and only if edge x y is the minimum edge that connects the two disconnected

comp onents

Newx y E x y T a x a T b y b

uv E u v T a u a T b v b x u x u y v

E F and PV are then dened as follows

E x y Ex y Eqx y a b

We removea b from the forest and add the new edge

F x y Fx y Eqx y a b Newx y Newy x

Note that this uses an ordering on the vertices If no such ordering is given then we can order edges by

their order of insertion In the presence of an ordering relation we can mo dify the construction to always

maintain the minimum spanning forest as in Theorem This is then memoryless

The paths in the forest from x to y via z that did not pass through a and b

are valid Also new paths have to b e added as a result of the insertion of a

new edge in the forest

PV x y z Tx y z u v Newu v Newv u Tx u x

Ty v y Tx u z Ty v z

In PI we asked if the pro of of Theorem could b e carried out using auxiliary relations

of aritytwo instead of three Quite recently Dong and Su haveshown that the answer is yes

DS They show that the arity three construction of PV can b e replaced by a directed

version of F and its They also use EhrenfeuchtFrasse games to show

that arity one do es not suce

We next give a new DynFO algorithm for the following result of Dong and Su By REACH

acyclic we mean the REACH problem restricted to queries in which the input graph is

acyclic during its entire history

Theorem DS REACH and REACH acyclic areinDynFO

d

Pro of That REACH is in DynFO follows from Theorem together with the fact that

d

REACH is reducible to REACH Example We defer the details of this until the

u

d

pro of of Prop osition

For the REACH acyclic case the inserts are assumed to always preserve acyclicityWe

maintain the path relation P x y which means that there is a path from x to y in the

graph

InsertEa b

P x y P x y P x a P b y

DeleteEa b

P x y P x y P x a P b y

uv P x u P u a E u v P v a P v y v b u a

In the case where there is a path from x to y using the edge a b consider any path not

using this edge Let u b e the last vertex along this path from which a is reachable Note

that u y b ecause the graph was acyclic b efore the deletion of edge a b Thus the

edge u v describ ed in the ab oveformula must exist and acyclicity insures that the path

x u v y do es not involve the edge a b

For G a directed acyclic graph the Transitive Reduction TRG is the minimal subgraph

of G having the same transitive closure as G

Corollary Transitive Reduction for directed acyclic graphs is in memoryless DynFO

Pro of We maintain the path relation P inaway that is quite similar to the pro of of

Theorem

InsertEa bIfP a b already holds then there is no change Otherwise wemayhave

to remove some edges from TR

TR x y P a b x a y b TRx y P x a P b y

DeleteEa bWehave to determine the new edges that might b e added in TR For an

edge x y Newx y holds if there was a path from x to y via a b and no path of length

greater than one remains in the graph when a b is deleted

Newx y E x y TRx y P x a P b y

uv P x u P u a E u v P v a P v y v b u a

TR x y TRx y x a y b Newx y

Theorem Minimum Spanning Forests can becomputedin DynFO

Pro of The general idea is to maintain the forest edges and nonforest edges dynamically

and to maintain the relations PVx y eandFx y asinthecaseofREACH Let Wa b

u

denote the weight of edge a b The dierence from REACH is that wehavetomaintain

u

the minimum weighted forest That changes our up date pro cedures in the following way

Deletion of the edge a b is handled as follows We determine using PV all the vertices

that can b e reached from a in the tree and all those that can b e reached from b These give

the vertices in the two trees that the original tree splits into Then instead of cho osing

the lexicographically rst nonforest edge that reconnects the two pieces wecho ose the

minimum weight such edge and insert it If there is more than one such minimum edge

then we break the tie with the ordering PV is up dated accordingly to reect the merging

of two disconnected trees into one

When the edge a b is inserted we determine if there exists a path b etween a and b If

there is no path then a b merges two trees into one and PV is up dated as b efore for

REACH Otherwise using PV we can determine the forestedges that app ear in the

u

unique path in the forest b etween b and aandcheck to see if the weight of the new edge

a b is less than the weightofany of these edges If not then a b is not a forest edge

and nothing changes Otherwise let c d b e the maximum weight edge on the path from

a to b WemakeFc d false and F a b true and up date PV accordingly It is easy to

see that if the weights are all distinct or in the presence of an ordering on the edges this

construction is memoryless

We next show that DynFO algorithms exist for Bipartiteness Edge ConnectivityLowest

Common Ancestors in directed forests and Maximal Matching in b ounded degree graphs

This last problem has no known sublineartime fully dynamic algorithm

Theorem DynFO algorithms exist for the fol lowing problems

Bipartiteness

k Edge Connectivity for a xedconstant k

Maximal Matching in undirectedgraphs

Lowest Common Ancestor in directedforests

Pro of

Bipartiteness We maintain bipartiteness in undirected graphs by maintaining

relations PVx y z and Fx y as for REACH and also Oddx y which means that

u

there exists a path of o dd length from x to y in the spanning forest The graph is bipartite

i xy E x y Oddx y Weshowhow to up date Odd in DynFO

InsertE a b If the new edge a b b ecomes a forestedge we determine for all newly

connected vertices x and y whether the new path is o dd If a b do es not b ecome a forest

edge then Odd is unchanged

h

Odd Oddx y PV a b a uv Equ v a b PVx u x PVy v y

i

Oddx u Oddy v Oddx u Oddy v

DeleteE a b If a b is a nonforest edge Odd is unchanged Otherwise for all ver

tices x y whichareinthetwo disconnected trees that result from deletion of a b make

Oddx y and PVx y z false Then we select some edge if any that spans the discon

nected comp onents and insert it in and up date Odd and PV exactly as for the insertion

case

k Edge Connectivity As b efore wemaintain the relations EF and PV Insertions

and deletions are handled as for REACH The query is handled as follows Since k is

u

constant we universally quantify over k edges sayx y x y and then for every

k k

pair of vertices x and y check for a path b etween x and y in the graph that is obtained

after deletion of edges x y x y by comp osing the DynFOformula for a single

k k

deletion k times

Maximal Matching Wemaintain a maximal matching in DynFOby maintaining

under insertions and deletions of edges a relation Matchx y which means that the edge

x y is in the matching Initially for the empty graph Matchx y is false for all x and

y As usual all relations are symmetric We shall use MPx to abbreviate the formula

z Matchx z

InsertE a b The matching remains unchanged except that the edge a bischecked to

see whether it can b e added

Match x y Matchx y Eqx y a b MPa MPb

DeleteEa bIfa b is not in the matching then Match is unchanged Otherwise we

removea b from the matching We pick the minimum unmatched vertex adjacentto aif

anyandmatch it with a Then we do the same for b

Lowest Common Ancestor In a directed forest wemaintain the relation P exactly

as in Theorem Vertex a is the lowest common ancestor of x and y i

P a x P a y z P z x P z y P z a

Wehave shown that DynFOcontains some interesting problems that are not static rst

order In particular DynFOcontains natural complete problems for L and NL As we

will see in the next section these problems do not remain complete via the reductions that

honor dynamic complexity Thus it do es not necessarily follow that DynFOcontains the

classes L or NL We can prove the following

Theorem Every regular language is in DynFO

Pro of We are given a deterministic nite automaton D hQsFi and an input

size n Let f gLetw b e a string of length n jw j Let A b e the

t w

logical structure co ding w

A hf n gR R i

w t

th

The universe of A consists of the p ositions of the n letters in w A j R j i the j

w w i

character of w is With this enco ding the allowable op erations are to insert or delete a

i

character into any p osition in the string As usual there is a numeric predicate giving

the usual total ordering on f n g The deletion of a character at p osition iis

equivalent to setting the character at that p osition to the empty string

A natural dynamic algorithm for the regular language LD is to maintain a complete

binary tree with leaves at the input p ositions n At the leaf l i at p osition i

we store the transition function of D on reading input symbol Thatiswe store a table

i

for f Q Q Ateachinternal no de of the tree we store the comp osition

i

l i

of the functions of its twochildren Thus at every no de v of the tree wehave stored the

transition function function f w where w is the subword of w that is sitting

v v v

b elow v s subtree In particular the current string is in LD i f s F wheref is the

r r

mapping stored at the ro ot

Since D is a nite state machine these mappings consist of a b ounded numb er of bits each

When wechange the symbol this aects the log n no des on the path from l itor

i

Wecanthus guess the O log n bits that change in the tree by existentially quantifying

O variables Remember that the value of a variable is a number between and n

ie log n bits and wehave the BIT predicate available for deco ding We then universally

assert that eachofthelogn p ositions has b een up dated correctly

We conclude this section with two other lowlevel problems that are in DynFO

Prop osition Multiplication is in DynFO

Pro of Given two nbit numbers x y their addition can b e expressed in FO DynFO

Wemaintain the pro duct in a bit arrayP Supp ose the up date op eration is Changex i b

Change y i b is analogous There are two cases

If the bit is changed from to then P is given by shifting y by i bits to the rightand

then adding it to P It is easily accomplished by a rstorder formula

If the bit is changed from to then P is given by shifting y by i bits to the right and then

adding the s complement of the resulting number to P Again this is easily accomplished

by a rstorder formula

k

Prop osition For any constant k D the Dyck language on k parentheses is in

DynFO

k

Pro of This is similar to the pro of in BC that D is in ThC the class of problems

k

accepted by b oundeddepth p olynomialsize threshold circuits D can b e parsed using the

level trick assign a level to eachparenthesis starting at one and ignoring the dierences in

parenthesis typ e The level of a parenthesis equals the numberofleftparentheses to its left

including it minus the numb er of right parentheses strictly to its left A right parenthesis

matches a left one if it is the closest parenthesis to the right on the same level A string is

k

in D i all parentheses have a p ositivelevel and each left parenthesis has a matching right

parenthesis of the same typ e

The level of each p osition can b e maintained in DynFO For example the insertion of a

left parenthesis at p osition p causes a one to b e added to the level of each p osition q p

Once the levels are maintained the fact that every left parenthesis has a matching right

one of the same typ e is rstorder expressible

Dynamic Reductions

Nowwe dene appropriate reductions for comparing dynamic complexityclassesFor these

classes rst order reductions are to o p owerful We restrict them by imp osing the following

expansion prop erty cf MSV for a similar restriction

Denition Boundedexpansion rstorder reductions bfo are rstorder reductions

Denition such that each tuple in a relation and each constant of the input structure

aects at most a constantnumb er of tuples and constants in the output structure This

dep endency is oblivious ie only dep ending on the numeric predicates BIT and not

on the input predicates This is similar to the denition of rstorder pro jections IL in

whicheach output bit must dep end on at most one input bit Furthermore a bfo reduction

n

is required to map the initial structure A to a structure with only a b ounded number of

tuples present If this condition is relaxed we get b ounded expansion rstorder reductions

with precomputation bfo If S is reducible to T via b oundedexpansion rstorder

reductions with precomputation we write S T S T

bfo

bfo

As an example consider the rstorder reduction I from Example Observe that this

du

is b ounded expansion b ecause each insertion or deletion of an edge a b from the graph G

can cause at most two edges to b e inserted or deleted in G I G

du

Since the comp osition of bfo or bfo reductions are bfo bfo respectively it follows that

Prop osition The relations and aretransitive

bfo

bfo

As desired bfo reductions preserve dynamic complexity

Prop osition If T DynFO and S T thenS DynFO

bfo

Pro of We are given a bfo reduction I fromS to T Anychange to an input AforS

corresp onds to a b ounded number of changes to I A Given a request r to Awe know the

number k of p ossibly aected tuples and constants in I A Since I is rstorder wecan

existentially quantify all the changed tuples and constants Then we can resp ond to the k

or fewer changes using the DynFO algorithm for T Since I is a manyone reduction every

answer of a query to T will also b e the correct answer for the given query to S

n m

A bfo reduction allows I A to b e quite dierent from the standard initial structure B

n

This corresp onds to some precomputation to handle I A as an initial structure Thus we

have

Corollary If T DynFO and S T then S DynFO

bfo

Boundedexpansion reductions with precomputation are an appropriate reduction for com

paring the dynamic complexity of problems We also note that most natural reductions

for Pcomplete and NPcomplete problems are either b ounded expansion or can b e easily

mo died to b e so see P MI Wegive one such example here

Prop osition REACH and CVAL arecomplete for P via bfo reductions

a

Pro of REACH is the reachability problem for alternating graphs It is equivalentto

a

CVAL the circuit value problem In I it is shown that REACH is complete for

a

ASPACElog n via rstorder reductions Recall that ASPACE log n P The pro of

dep ends on the fact that REACH is the natural complete problem for ASPACE log n

a

An alternating machine can put o lo oking at its input until the last step of its computation

Thus each input bit is copied only once and the rstorder reductions from I b ecome

b ounded expansion

n

The reason that Prop osition requires bfo reductions is that I A contains more than

a b ounded numb er of edges and vertices marked or equivalently for CVAL more than

n

a b ounded numb er of wires and no des marked and In fact I A represents the entire

computation tree of an ASPACElog nmachine on input all zeros Clearly there is a related

whichknows by heart the rstorder describable graph problem whichwe call REACH

a

n m

I A and starts its input there instead of at B In general wehave

Prop osition For any problem S that is hardforacomplexity class C via bfo reduc

tions thereisa relatedproblem S that is hard for C via bfo reductions In particular

REACH is complete for P via bfo reductions

a

The following corollary indicates that REACH is probably not in DynFO Let CRAMtn

a

b e the set of problems computable by uniform CRCWPRAMS using p olynomially much

hardware It is known that FO CRAM Ib Let CRAM tn b e CRAMtn with

p olynomial precomputation Then

Corollary DynFO CRAMn and DynFO CRAM n

If REACH DynFO then P DynFO and thus PCRAM n

a

If REACH DynFOthen P DynFO and thus PCRAMn

a

Things are more complicated for the lower complexity classes L and NL The reason is that

bfo reductions preserve the numb er of times that the input is read This do es not matter

for P and larger classes as wemay simply copy the input reading it once For appropriate

complexity classes C dene readO times C to b e the set of problems S C such that

there exists a constant k suchthatany accepting computation on an input w for S reads

no bit of w more than k times

Prop osition Let S T beproblems Let C beanycomplexity class that is closed under

rstorder reductions If S T and T readO times C Then S readO times

bfo

C

Pro of To test if input A is in S we run the readO times C algorithm to test if

I A T Each time the algorithm needs to read a bit b of I A it examines the relevant

bits of A By the denition of bfo reductions these can b e determined in a rstorder way

Furthermore the b oundedexpansion prop erty insures that each bit of A is thus queried

only a b ounded numb er of times

Now clearly REACH is in readonce L and REACH is in readonce NL since no accepting

d

computation need check the existence of a particular edge more than once Thus if these

problems remained complete for their resp ective classes via bfo reductions then it would

followthatLwould b e equal to readO times L and NL would b e equal to readO

times NL These latter facts are false

Fact BRS Thereisaproblem in L that is not in readO times NL

It follows that

Corollary REACH is not complete for L via bfo reductions and

d

REACH is not complete for NL via bfo reductions

The standard pro of that REACH and REACH are complete for L and NL map each input

d

w to a computation graph of a xed Turing machine on input w The reason this mapping

is not b ounded expansion is that many dierent no des in the computation tree mightread

a particular bit of w and thus have an edge to a next no de according to the value of this

bit AvariantofREACH called COLORREACH is invented in MSV to nesse this

diculty An input to COLORREACH consists of a directed graph with outdegree at

most two with the outgoing edges lab eled zero and one There is a given partition of the

vertices V V V V Furthermore there is a bitvector C r C tells us

r

for eachvertex v V whether to follow the oneedge or the zeroedge out of v Thus by

setting a single bit C i we are deciding on edges out of all the vertices in V By letting V

i i

b e the set of no des that would query bit iwehave transformed the REACH problem to

one where the standard reduction is now b ounded expansion

Fact MSV COLORREACH is complete for NL via bfo reductions

It is not hard to see that one can colorize most complete problems via rstorder reduc

tions to get a version that is complete via bfo reductions Here are two examples Let

COLORREACH b e the subproblem of COLORREACH in which V is empty and so

d

Q

with the color vector C given every vertex has outdegree one Let COLOR S bethe

Q

colorized version of the problem S iterated multiplication of elements of the sym

metric group on ve ob jects IL B This means that for each p osition there is a pair

of group elements and The p ositions are partitioned into classes P P and bit

r

C i tells us whether to pick or for all the p ositions in class P

i

Corollary COLORREACH is complete for L via bfo reductions and COLOR

d

Q

S is complete for NC via bfo reductions

Another idea from MSV indicates that dynamic complexity classes may not b e as robust

under changes to the form of the input as static classes are

Denition MSV For any problem S dene the padded form of S as follows

PAD S fw w w j n N jw j n w w w w S g

n n

ClearlyPADS is computationally equivalentto S However changing a single bit of

the input to S requires n changes to the input to PADS Thus a DynFO algorithm for

PADREACH hasn rstorder steps to resp ond to any real change to the input to S Re

a

call that REACH is complete for P via rstorder reductions Thus so is PADREACH

a a

Also it is easy to see that REACH is in FOn I It follows that a complete problem

a

for P is in DynFO

Theorem PADREACH isin DynFO

a

Conclusions

Wehave dened dynamic complexity classes and their reductions In particular wehave

b egun an investigation of the rich dynamic complexity class DynFO Muchwork remains

to b e done Wepointtoward a few of the many directions

Do es DynFO contain any of the complexity classes ThC NC L NL We con

jecture that ThC DynFO and that REACH DynFOandthus DynFO

a

P

Is REACH in DynFO We conjecture that it is

Further work needs to b e done concerning the role and value of precomputation in

the dynamic setting

In this pap er wehave only considered problems that have the basic set of requests as

dened in Equation As p ointed out in Note one can consider dierentsetsof

p ossible requests For example an interesting subset of DynFO results if we require

rstorder resp onse to any rstorder change to the input This and other changes to

the request set should b e investigated

Find natural complete problems for Dynamic Classes

Find natural descriptive languages that capture Dynamic Classes

Determine an automatic way to lo ok at a query and gure out what to save in a data

structure so that the query will havelow dynamic complexity

Acknowledgements Thanks to Ron Fagin Paris Kanellakis and Peter Miltersen for

useful discussions

References

A M Ajtai Formulae on Finite Structures Annals of Pure and Applied

Logic

B DM Barrington BoundedWidth PolynomialSize Branching Programs Recog

nize Exactly Those Languages in NC J Comput Sys Sci

BC DM Barrington JC Corb ett On the Relative Complexity of some Languages

in NC Technical Report Department of Computer Science University

of Massachusetts Amherst

BRS A Boro din R Razb orov S SmolenskyOnLower Bounds for Readk Times

Branching Programs Preprint

CH A Chandra and D Harel Structure and Complexity of Relational Queries

J Comput Sys Sci

CT R Cohen R Tamassia Dynamic Expression Trees and their applications Pro

ceedings of the nd Annual ACMSIAM SODA

DS G Dong J Su SpaceBounded FOIES ACM Symp Principles Database Sys

tems

DS G Dong J Su Incremental and Decremental Evaluation of Transitive Closure

by FirstOrder Queries Information and Computation

DST G Dong J Su R Top or FirstOrder Incremental Evaluation of Datalog

Queries Proceedings of the International Conference on Database Theory

LNCS Springer Verlag

E D Eppstein Z Galil G F Italiano A Nissenzweig Sparsication A technique

for sp eeding up dynamic graph algorithms IEEE Found of Comp Sci Symp

E b D Eppstein Z Galil G F Italiano A Nissenzweig Sparsication and Planarity

Testing Proceedings of ACM Symposium on Theory of Computing

Fa Ron Fagin Generalized FirstOrder Sp ectra and PolynomialTime Recognizable

Sets in Complexity of Computation ed R Karp SIAMAMS Proc

F GF Frederickson Data structures for online up dating of minimum spanning

trees SIAM J Comput

F GF Frederickson Ambivalent data structures for dynamic edge connectivity

and k smallest spanning trees IEEE Found of Comp Sci Symp

FS M Fredman and M Saks The Cell Prob e Complexity of Dynamic Data Struc

tures st ACM STOC Symp

FSS M Furst JB Saxe and M Sipser Parity Circuits and the PolynomialTime

Hierarchy Math Systems Theory

GMS A Gupta I S Mumick V S Subrahmanian Maintaining Views Incrementally

Proceedings of the ACM SIGMOD

I N Immerman Descriptive and Computational Complexity in Computational

Complexity Theory ed J Hartmanis Proc Symp in Applied Math American

Mathematical So ciety

Ib Neil Immerman ExpressibilityandParallel Complexity SIAM J of Comput

I N Immerman Languages That Capture Complexity Classes SIAM J Com

put

I N Immerman NumberofQuantiers is Better than Number of Tap e Cells

J Comput Sys Sci

IL N Immerman S Landau The Complexity of Iterated Multiplication Infor

mation and Computation

Io Y Ionanadis A Time Bound on the Materialization of Some Recursively Dened

Views Proceedings of International ConferenceonVery Large Data Bases

J H Jakobsson On Materializing Views and Online Queries Proceedings of In

ternational ConferenceonDatabase Theory Berlin

LT Y Liu and T Teitelbaum Systematic Derivation of Incremental Programs

Science of Computer Programming

LST J W LLoydEASonenberg and R W Top or Integrity ConstraintChecking

in Stratied Databases Journal of Logic Programming

MI JA Medina and N Immerman A Syntactic Characterization of NP

Completeness IEEE Symp Logic In Comput Sci

M P B Miltersen The Bit Prob e Complexity Measure Revisited Proceedings of

the Tenth Symposium on Theoretical Aspects of Computer Science

MSV Peter Bro Miltersen Sairam Subramanian Jerey Scott Vitter and

Rob erto Tamassia Complexity Mo dels for Incremental Computation Theo

ret Comp Sci

N JM Nicolas Logic for Improving Integrity Checking in Relational Databases

Acta Informatica

P S Patnaik The Dynamic Complexity of Approximation Manuscript Computer

Science Dept University of Massachusetts

PI S Patnaik and N Immerman DynFO A Parallel Dynamic Complexity Class

ACM Symp Principles Database Systems

RR G Ramalingam and T Reps On the computational complexity of dynamic graph

problems Theoret Comp Sci

R M Rauch Improved Data Structures for Fully Dynamic Biconnectivity ACM

Symp Theory Of Comput

TY R Tarjan and A Yao Storing a Sparse Table Communications of the ACM