Foundations of Query Languages

Similar documents
Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in

Definition: Alternating time and space Game Semantics: State of machine determines who

Lecture 8: Complete Problems for Other Complexity Classes

CSE200: Computability and complexity Space Complexity

Logarithmic space. Evgenij Thorstensen V18. Evgenij Thorstensen Logarithmic space V18 1 / 18

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Circuits. Lecture 11 Uniform Circuit Complexity

Outline. Complexity Theory. Example. Sketch of a log-space TM for palindromes. Log-space computations. Example VU , SS 2018

Definition: Alternating time and space Game Semantics: State of machine determines who

1 PSPACE-Completeness

Parallelism and Machine Models

Space Complexity. The space complexity of a program is how much memory it uses.

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

Notes for Lecture 3... x 4

1 Circuit Complexity. CS 6743 Lecture 15 1 Fall Definitions

SOLUTION: SOLUTION: SOLUTION:

Lecture Notes Each circuit agrees with M on inputs of length equal to its index, i.e. n, x {0, 1} n, C n (x) = M(x).

Umans Complexity Theory Lectures

CS151 Complexity Theory. Lecture 1 April 3, 2017

INAPPROX APPROX PTAS. FPTAS Knapsack P

PRAM lower bounds. 1 Overview. 2 Definitions. 3 Monotone Circuit Value Problem

CS 151 Complexity Theory Spring Solution Set 5

1 Deterministic Turing Machines

Principles of Knowledge Representation and Reasoning

Lecture 11: Proofs, Games, and Alternation

POLYNOMIAL SPACE QSAT. Games. Polynomial space cont d

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CS151 Complexity Theory

CS5371 Theory of Computation. Lecture 24: Complexity IX (PSPACE-complete, L, NL, NL-complete)

CSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits

Apropos of an errata in ÜB 10 exercise 3

Fundamentos lógicos de bases de datos (Logical foundations of databases)

6.841/18.405J: Advanced Complexity Wednesday, February 12, Lecture Lecture 3

CS256 Applied Theory of Computation

Umans Complexity Theory Lectures

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Ταουσάκος Θανάσης Αλγόριθμοι και Πολυπλοκότητα II 7 Φεβρουαρίου 2013

Non-Approximability Results (2 nd part) 1/19

Polynomial Time Computation. Topics in Logic and Complexity Handout 2. Nondeterministic Polynomial Time. Succinct Certificates.

Introduction to Complexity Theory. Bernhard Häupler. May 2, 2006

Lecture 4. 1 Circuit Complexity. Notes on Complexity Theory: Fall 2005 Last updated: September, Jonathan Katz

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

Lecture 20: conp and Friends, Oracles in Complexity Theory

Real Interactive Proofs for VPSPACE

About the relationship between formal logic and complexity classes

Advanced topic: Space complexity

Notes on Computer Theory Last updated: November, Circuits

Algorithmic Model Theory SS 2016

MACHINE COMPUTING. the limitations

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

Boolean circuits. Lecture Definitions

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

Lecture 4 : Quest for Structure in Counting Problems

Lecture 5: The Landscape of Complexity Classes

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

Complexity Theory 112. Space Complexity

Umans Complexity Theory Lectures

The space complexity of a standard Turing machine. The space complexity of a nondeterministic Turing machine

CS21 Decidability and Tractability

Models of Computation

A Complexity Theory for Parallel Computation

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

NP-completeness. Chapter 34. Sergey Bereg

More Complexity. Klaus Sutner Carnegie Mellon University. Fall 2017

Part I: Definitions and Properties

Universality for Nondeterministic Logspace

Computability and Complexity Theory: An Introduction

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Reductions to Graph Isomorphism

34.1 Polynomial time. Abstract problems

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Lecture 22: PSPACE

Computational Complexity Theory. Markus Bläser, Holger Dell, Karteek Sreenivasaiah Universität des Saarlandes Draft June 15, 2015 and forever

A.Antonopoulos 18/1/2010

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

CS151 Complexity Theory. Lecture 4 April 12, 2017

198:538 Lecture Given on February 23rd, 1998

CS6901: review of Theory of Computation and Algorithms

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Computer Science. Questions for discussion Part II. Computer Science COMPUTER SCIENCE. Section 4.2.

1 Deterministic Turing Machines

Properties That Characterize

PSPACE COMPLETENESS TBQF. THURSDAY April 17

COMPUTATIONAL COMPLEXITY

if t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas)

CS21 Decidability and Tractability

Notes for Lecture 3... x 4

CSE 105 THEORY OF COMPUTATION

Space is a computation resource. Unlike time it can be reused. Computational Complexity, by Fu Yuxi Space Complexity 1 / 44

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan 9/6/2004. Notes for Lecture 3

Simulating classical circuits with quantum circuits. The complexity class Reversible-P. Universal gate set for reversible circuits P = Reversible-P

Theory of Computation. Ch.8 Space Complexity. wherein all branches of its computation halt on all

Introduction to Computational Complexity

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Transcription:

Foundations of Query Languages SS 2011 2. 2. Foundations of Query Languages Dr. Fang Wei Lehrstuhl für Datenbanken und Informationssysteme Universität Freiburg SS 2011 Dr. Fang Wei 30. Mai 2011 Seite 1

Measurement of Query Processing Complexity classes are usually defined for Decision (yes/no) problems. Queries may have a large output. It would be unfair to count the size of the output as complexity. We therefore consider the following decision problems, which areall computationally equivalent purposes (logspace equivalent). Boolean Queries D = Q? The Query of Tuple problem (QOT)t Q(D)? The Query-Emptiness problem Q(D) Dr. Fang Wei 30. Mai 2011 Seite 2

Measurement of Query Processing Data Complexity Q(D): where D is considered as input, while Q as fixed. Query Complexity Q(D): where Q is considered as input, while D as fixed. Combined Complexity Q(D): both D and Q are considered as input. Dr. Fang Wei 30. Mai 2011 Seite 3

QBF Problem QBF (Quantified Boolean Formulas) (a.k.a. QSAT) Q 1 x 1 Q 2 x 2... Q n x n φ(x 1, x 2,..., x n ) Q i {, } is a quantifier, φ is a Boolean formula in CNF; Q 1... Q n alternates between and. For instance, x 1 x 2... x n Dr. Fang Wei 30. Mai 2011 Seite 4

QBF Example x 1 x 2 x 3 (x 1 x 2 x 3 ) (x 2 x3) (x 1 x 2 x 3 ) ( x 1 x 2 ) x 1 x 2 x 3 (x 1 x 2 x 3 ) (x 2 x3) (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dr. Fang Wei 30. Mai 2011 Seite 5

QBF Problem - Algorithm Dr. Fang Wei 30. Mai 2011 Seite 6

QBF Problem - Algorithm Depth of recursion: n, at each step the stack size is poly(n) QBF in PSPACE Dr. Fang Wei 30. Mai 2011 Seite 7

Logspace Transducer A logspace transducer is a Turing machine with a read-only input tape, a write-only output tape, and a read/write work tape. The work tape may contain O(log n) symbols. A logspace transducer M computes a function f : Σ Σ, where f (w) is the string remaining on the output tape after M halts when it is started with w on its input tape. f is a logspace computable function Dr. Fang Wei 30. Mai 2011 Seite 8

Logspace computation Some capabilities of logspace machines Maintain (a constant number) of counters on the worktape, and increment or decrement such counter Locate particular items of a well-structured input (integers, list item) via pointers consisting of input-tape address Access, process and compare input items in a bit-by-bit fashion Binary integer addition, subtraction, comparing data items or lists, copying data items, searching, sorting, etc. Dr. Fang Wei 30. Mai 2011 Seite 9

Language in Logspace is a member of Logspace. A = {0 k 1 k k 0} on the work tape, maintain a counter C, and one pointer P to the input tape Read the content of what P is pointing to; increase the counter as long as the content is 0 (move P to right) As soon as the first 1 is met, start decreasing the counter Accept if read the end and the counter is set to 0, reject otherwise Dr. Fang Wei 30. Mai 2011 Seite 10

Join Operation in Logspace Join of two relations r and s on attribute A Maintain two tuple pointers τ r and τ s Outer loop: move τ r to point successively to each tuple of r For each such tuple t r, an inner loop makes τ s successively point to each tuple t s For each combination of tuples t r and t s, identify the fields corresponding to attribute A and check, bit by bit, where the A-value of t r and t s are equal If yes, the relevant part of t r and t s are (bitwise) copied to the output tape Space used on work tape: 4 pointers + 2 + a constant number of counters Dr. Fang Wei 30. Mai 2011 Seite 11

Complexity of FO Queries Theorem Evaluating Boolean FO (or RA) queries is as follows: PSPACE complete (combined complexity) PSPACE complete (query complexity) in LOGSPACE (data complexity) The same complexity results apply to the Query-emptiness problem and to the QOT-Problem Dr. Fang Wei 30. Mai 2011 Seite 12

FO Evaluation Dr. Fang Wei 30. Mai 2011 Seite 13

FO Complexity m(log m + m log n) Combined complexity (both m and n as input): m(log m + m log n) PSPACE Data complexity (n as input, m as constant): log n LOGSPACE Query complexity: (m as input, n as constant) : m 2 PSPACE Dr. Fang Wei 30. Mai 2011 Seite 14

FO Complexity: Combined Complexity PSPACE hardness proof: polynomial reduction from QBF problem (PSPACE complete) dom: {1, 0} Database: true(1), false(0) x 1 x 2 x 3 (x 1 x 2 x 3 )... x 1 x 2 x 3 (true(x 1 ) false(x 2 ) true(x 3 ))... Dr. Fang Wei 30. Mai 2011 Seite 15

Data Complexity Data complexity (n as input, m as constant): log n in Logspace Can we get a better upper bound? AC0 NC1 L NL LOGCFL NC2 We first need to define circuit complexity classes. Dr. Fang Wei 30. Mai 2011 Seite 16

Boolean Circuits size= # gates depth= longest path from input to output formula(or expression): graph is a tree can build circuit family that decides L Dr. Fang Wei 30. Mai 2011 Seite 17

Circuit Family What is the function of this circuit? It accepts the language that consists of strings with at least two 1 s. Dr. Fang Wei 30. Mai 2011 Seite 18

Circuit Family What is the function of this circuit? It accepts the language that consists of strings with at least two 1 s. Dr. Fang Wei 30. Mai 2011 Seite 19

Circuit Family What is the function of this circuit? It accepts the language that consists of strings with at least two 1 s. Dr. Fang Wei 30. Mai 2011 Seite 20

Circuit Family Dr. Fang Wei 30. Mai 2011 Seite 21

Circuit Family Dr. Fang Wei 30. Mai 2011 Seite 22

Circuit Family 2 steps, O(n) processors Dr. Fang Wei 30. Mai 2011 Seite 23

Parallelism uniform circuits allow refinement of polynomial time: Dr. Fang Wei 30. Mai 2011 Seite 24

Small Depth Circuit A small depth circuit is a polynomial-size circuit whose depth is poly-logarithmic in its size. That is: a circuit with size=poly(n) and depth=o(log k n) Such circuits capture the notion of efficient parallel computation. Dr. Fang Wei 30. Mai 2011 Seite 25

NC and AC NC = k NC k (Nick s Class) class of languages decided by families of fan-in 2 circuits {C n } s.t. size(c n )=poly(n) and depth(c n )=O(log k n). AC = k AC k, defined analogously, difference: arbitrary fan-in allowed. Dr. Fang Wei 30. Mai 2011 Seite 26

Examples Σ = {0, 1} 1 Σ 1 NC0 {0 k 1 k (k 0)} AC0 PARITY := {w Σ #1(w)odd} NC1 Dr. Fang Wei 30. Mai 2011 Seite 27

Data Complexity Theorem Data complexity of FO query: Complete for logtime uniform AC0. Dr. Fang Wei 30. Mai 2011 Seite 28

Dr. Fang Wei 30. Mai 2011 Seite 29

Dr. Fang Wei 30. Mai 2011 Seite 30

Dr. Fang Wei 30. Mai 2011 Seite 31

Dr. Fang Wei 30. Mai 2011 Seite 32

Dr. Fang Wei 30. Mai 2011 Seite 33

Dr. Fang Wei 30. Mai 2011 Seite 34

Dr. Fang Wei 30. Mai 2011 Seite 35

Dr. Fang Wei 30. Mai 2011 Seite 36

Dr. Fang Wei 30. Mai 2011 Seite 37

Remarks Schema and query are assumed fixed. Database and size of the active domain are variable. Uniform families of gates: Total number of input gates uniquely determines size of active domain. Example:Schema: R(ABC), S(D), T (EF ) Number of input gates: n 3 + n + n 2 for some n (which is the size of the active domain). Dr. Fang Wei 30. Mai 2011 Seite 38