abstract state machines and computationally complete query languages
Download
Skip this Video
Download Presentation
Abstract State Machines and Computationally Complete Query Languages

Loading in 2 Seconds...

play fullscreen
1 / 57

Abstract State Machines and Computationally Complete Query Languages - PowerPoint PPT Presentation


  • 66 Views
  • Uploaded on

Abstract State Machines and Computationally Complete Query Languages. Andreas Blass, U Michigan Yuri Gurevich, Microsoft Research & U Michigan Jan Van den Bussche, U Limburg. Outline. Databases and queries Query languages: while new , while new sets ASMs Notions of polynomial time

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Abstract State Machines and Computationally Complete Query Languages' - qamra


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
abstract state machines and computationally complete query languages

Abstract State MachinesandComputationally Complete Query Languages

Andreas Blass, U Michigan

Yuri Gurevich, Microsoft Research & U Michigan

Jan Van den Bussche, U Limburg

outline
Outline
  • Databases and queries
  • Query languages:
    • whilenew, whilenewsets
    • ASMs
  • Notions of polynomial time
  • Comparisons
relational databases
Relational databases
  • Database schema = Finite set S of relation names with associated arities
  • DatabaseB over S = Finite structure over S
    • Finite domain D of atomic values
    • For each R S, a k-ary relation RB onD
relational databases1
Relational databases
  • Database schema = Finite set S of relation names with associated arities
  • DatabaseB over S = Finite structure over S
    • Finite domain D of atomic values
    • For each R S, a k-ary relation RB onD

arity associated to R in S

relational databases2
Relational databases
  • Database schema = Finite set S of relation names with associated arities
  • DatabaseB over S = Finite structure over S
    • Finite domain D of atomic values
    • For each R S, a k-ary relation RB onD

E.g. Graph:

arity associated to R in S

relational databases3
Relational databases
  • Database schema = Finite set S of relation names with associated arities
  • DatabaseB over S = Finite structure over S
    • Finite domain D of atomic values
    • For each R S, a k-ary relation RB onD

E.g. Graph:

arity associated to R in S

1

2

3

4

relational databases4
Relational databases

D

1

2

3

4

E

(1,2)

(2,3)

(2,4)

(3,4)

  • Database schema = Finite set S of relation names with associated arities
  • DatabaseB over S = Finite structure over S
    • Finite domain D of atomic values
    • For each R S, a k-ary relation RB onD

E.g. Graph:

arity associated to R in S

1

2

3

4

queries
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations

(over a common schema)

(of a common arity)

queries1
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.

(over a common schema)

(of a common arity)

queries2
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.
  • Arity 0: {( )} or { } Boolean query

(over a common schema)

(of a common arity)

queries3
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.
  • Arity 0: {( )} or { } Boolean query

E.g. On a graph:

    • Give all pairs of nodes that are targets of a common source.

(over a common schema)

(of a common arity)

queries4
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.
  • Arity 0: {( )} or { } Boolean query

E.g. On a graph:

    • Give all pairs of nodes that are targets of a common source.
    • Is f(m)=2000?

(over a common schema)

(of a common arity)

queries5
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.
  • Arity 0: {( )} or { } Boolean query

E.g. On a graph:

    • Give all pairs of nodes that are targets of a common source.
    • Is f(m)=2000?

(over a common schema)

(of a common arity)

number of edges in graph

queries6
Queries
  • General definition of query: a (partial, computable) mapping Q
    • from databases
    • to relations
  • Q(B) is the answer to the query Q on database B.
  • Arity 0: {( )} or { } Boolean query

E.g. On a graph:

    • Give all pairs of nodes that are targets of a common source.
    • Is f(m)=2000?

(over a common schema)

(of a common arity)

arbitrary computable function on N

the consistency criterion
The consistency criterion
  • The answer of a query on a database can depend only on information that is logically contained in that database.
  • If his an isomorphism B B, then h is also an isomorphism Q(B)  Q(B).
query languages
Query languages
  • In practice: SQL
    • first-order logic + counting, summation, …

E.g. Give all pairs of nodes that are targets of a common source:

query languages1
Query languages
  • In practice: SQL
    • first-order logic + counting, summation, …

E.g. Give all pairs of nodes that are targets of a common source:

select E1.target, E2.target

from E E1, E E2

where E1.source = E2.source

query languages2
Query languages
  • In practice: SQL
    • first-order logic + counting, summation, …

E.g. Give all pairs of nodes that are targets of a common source:

select E1.target, E2.target

from E E1, E E2

where E1.source = E2.source

(x,y) z(E(z,x)  E(z,y))

expressiveness of first order logic fo
Expressiveness of first-order logic (FO)

2000

0

if m is even

if m is odd

f(m) =

  • Many useful queries are expressible in FO.
  • But many others are not:
    • Connectivity: Is the graph connected?
    • Is f(m)=2000, where
expressiveness of first order logic fo1
Expressiveness of first-order logic (FO)

2000

0

if m is even

if m is odd

f(m) =

  • Many useful queries are expressible in FO.
  • But many others are not:
    • Connectivity: Is the graph connected?
    • Is f(m)=2000, where
    • (parity query)
towards a complete language while
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

towards a complete language while1
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

relation variable of arity j

towards a complete language while2
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

FO-formula over db relations and relation variables

towards a complete language while3
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

    • sequential composition
towards a complete language while4
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

    • sequential composition
    • while-loops:

while  do … od

towards a complete language while5
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

    • sequential composition
    • while-loops:

while  do … od

FO-sentence

towards a complete language while6
Towards a complete language: while
  • Make FO basis of a small programming language for working with relations:
    • relation variables (typed by fixed arities)
    • operations on relations provided by FO
    • assignment:

X(x1,…,xj)(x1,…,xj)

    • sequential composition
    • while-loops:

while  do … od

  • Chandra & Harel [1982]
example while program
Example while-program
  • Connectivity query:

Seen(2);

Path(2)  E;

whilePath  Seen   do

Seen  Path;

Path  Path  (x,z) y(Path(x,y)  E(y,z));

od.

example while program1
Example while-program
  • Connectivity query:

Seen(2);

Path(2)  E;

whilePath  Seen   do

Seen  Path;

Path  Path  (x,z) y(Path(x,y)  E(y,z));

od.

  • Parity query:
example while program2
Example while-program
  • Connectivity query:

Seen(2);

Path(2)  E;

whilePath  Seen   do

Seen  Path;

Path  Path  (x,z) y(Path(x,y)  E(y,z));

od.

  • Parity query: Not!
a complete language while new
A complete language: whilenew
  • S. Abiteboul & V. Vianu [1988]
  • Allow introduction of new domain elements in the computation.
  • New operator:
a complete language while new1
A complete language: whilenew
  • S. Abiteboul & V. Vianu [1988]
  • Allow introduction of new domain elements in the computation.
  • New operator: new
a complete language while new2
A complete language: whilenew

X

R

a b a

c d b

f g c

a b

c d

f g

  • S. Abiteboul & V. Vianu [1988]
  • Allow introduction of new domain elements in the computation.
  • New operator: new

X(3) newR(2)

a complete language while new3
A complete language: whilenew

X

R

a b a

c d b

f g c

a b

c d

f g

  • S. Abiteboul & V. Vianu [1988]
  • Allow introduction of new domain elements in the computation.
  • New operator: new

X(3) newR(2)

  • Every partial computable query can be programmed in whilenew.
parity in while new
Parity in whilenew
  • Easy to check parity of a set Sequipped with a successor relation:

Even(0) true;

Visit(1)  first element of S ;

whileVisit   do

Even  Even;

Visit  succ(x)Visit(x)

od.

parity in while new1
Parity in whilenew
  • Make a set S of new elements, one for each edge:

S0 newE;

S  3(S0);

parity in while new2
Parity in whilenew
  • Compute a successor relation on S:

Impossible!

parity in while new3
Parity in whilenew
  • Compute the tree T of all m! successor relations, where m = |S|:

T new  ;

Seen  ;

Extend  r,xTr  Sx;

whileExtend   do

X  newExtend;

T  T  p3X; succ  succ  p1,3X;

Seen  Seen  n,x nXn,x,n

 xx  Seenn,x;

Extend  n,xn  p3X  Sx  Seen(n,x

od.

we can t do better
We can’t do better!
  • whilenew-PSPACE: class of whilenew-programs running in polynomial space.

Theorem: [Abiteboul–Vianu 1991] The parity query cannot be done in whilenew-PSPACE.

  • Intuition: In whilenew you cannot make arbitrary choices (recall consistency criterion)
    • Instead of choosing one successor relation, we must work with them all.
  • whilenew-PTIME: class of whilenew-PSPACE-programs running in polynomial time.
slide40
BGS
  • Blass, Gurevich, Shelah [1996]:
    • How can we formalize algorithms that never have to make arbitrary choices?
    • What can such algorithms still do in polynomial time?
  • Instantiation of ASMs for expressing database queries.
bgs asms
BGS ASMs
  • Universe: HF(D)
    • every x D is in HF(D);
    • every finite set of elements of HF(D) is itself in HF(D).
  • Infinite, but at any point only finitely many sets are “active”.
  • Set-theoretic static functions:
    • pairing
    • bounded set-construction
  • forall do (parallel ASMs)
connectivity with a bgs asm
Connectivity with a BGS-ASM

ifMode0then

forallxDdoFrontierxx enddo,

Mode  1

endif,

ifMode= 1 then

forallxDdo

Reached(x) := Reached(x) Frontier(x),

Frontier(x) := {y D z  Frontier(x):

E(z,y)  y  Reached(x) Frontier(x)}

enddo,

Halt := {Frontier(x)x D} =

endif.

bgs ptime
BGS-PTIME
  • BGS-PTIME: class of BGS-ASMs
    • running for at most polynomially many steps
    • constructing at most polynomially many sets
  • “Choiceless polynomial time”
bgs ptime versus while new ptime
BGS-PTIME versus whilenew-PTIME?
  • Structure In:

• •  •

• •  •

n

2n

bgs ptime versus while new ptime1
BGS-PTIME versus whilenew-PTIME?
  • Structure In:
  • There is a PTIME BGS-program that outputs:

• •  •

• •  •

n

2n

bgs ptime versus while new ptime2
BGS-PTIME versus whilenew-PTIME?
  • Structure In:
  • There is a PTIME BGS-program that outputs:
    • true on every In with neven;

• •  •

• •  •

n

2n

bgs ptime versus while new ptime3
BGS-PTIME versus whilenew-PTIME?
  • Structure In:
  • There is a PTIME BGS-program that outputs:
    • true on every In with neven;
    • falseodd.

• •  •

• •  •

n

2n

bgs ptime versus while new ptime4
BGS-PTIME versus whilenew-PTIME?
  • Structure In:
  • There is a PTIME BGS-program that outputs:
    • true on every In with neven;
    • falseodd.
  • (Just construct all red subsets of even size.)

• •  •

• •  •

n

2n

bgs ptime versus while new ptime5
BGS-PTIME versus whilenew-PTIME?
  • Structure In:
  • There is a PTIME BGS-program that outputs:
    • true on every In with neven;
    • falseodd.
  • (Just construct all red subsets of even size.)

Theorem: There is no such PSPACE whilenew-program (let alone PTIME).

• •  •

• •  •

n

2n

sets versus lists
Sets versus lists
  • BGS programs can construct sets.
  • whilenew programs can only construct lists.
    • operator new works tuple- ( list-) based.
  • Lists are ordered; sets can be unordered.
  • If you want to simulate something unordered by something ordered, you have to work with all orders.
    • (Recall parity in whilenew.)
  • BGS-PTIME strictly encompasses whilenew-PTIME.
the language while new sets
The language whilenewsets
  • Theory of object-based query languages, studied late 80s – early 90s.
  • Operator new from whilenew is really tuple-new.
  • We need also a set-new!
  • Language whilenewsets
set new
set-new

R

a d

a e

b e

b d

c e

c f

c g

Y(2):=set-newR(2)

set new1
set-new

Y(2):=set-newR(2)

R

a d

a e

b e

b d

c e

c f

c g

set new2
set-new

Y(2):=set-newR(2)

R

a d

a e

b e

b d

c e

c f

c g

set new3
set-new

Y(2):=set-newR(2)

Y

R

a a

b a

c b

a d

a e

b e

b d

c e

c f

c g

equivalence results
Equivalence results
  • whilenewsets and BGS can simulate each other.
  • Simulation:
    • linear step overhead
    • polynomial space overhead
  • BGS-PTIME =whilenewsets-PTIME  whilenew-PTIME
concluding remarks
Concluding remarks
  • ASMs and query languages are quite related, and share the common concern of computation on the “logical” level.
  • Purely mathematically,
    • basic parallel ASMs
    • whilenew

are essentially the same thing.

  • ASMs clearly win from query languages in flexibility, appeal to practitioners, developed philosophy, and people like Yuri and Egon.
  • whilenew never “escaped” database theory!
  • Challenge: the Web (querying XML, WWW, …)
ad