Algorithm Search⌘K

Theoremadvanced

Weak acyclicity and chase termination

Also called weakly acyclic dependencies.

If the dependency graph of the tgds has no cycle through a special edge, each chase stops in polynomially many steps, for a fixed set of dependencies, in the size of the instance (data complexity).

Weak acyclicity is a syntactic condition on a set of tuple-generating dependencies (tgds) that makes the chase stop. If no cycle of the dependency graph goes through a special edge, then every chase sequence with these tgds and any set of equality-generating dependencies (egds) has a length bounded by a polynomial in the size of the instance. The bound is in data complexity: the polynomial depends on the fixed set of dependencies. The condition is sufficient for termination but not necessary. This page proves the termination theorem; the data exchange problem page uses it as its standard assumption on target dependencies, and the universal solution page uses the chase result it guarantees.

Statement

A tgd has the form ∀x ∀u (φ(x,u)→∃y ψ(x,y))\forall x\, \forall u\, (\varphi(x, u) \to \exists y\, \psi(x, y)). The variables xx occur in the body and in the head and are the frontier variables. The variables yy are the existential variables. An egd has the form ∀x (φ(x)→xi=xj)\forall x\, (\varphi(x) \to x_i = x_j). Values are constants or labeled nulls ⊥1,⊥2,…\bot_1, \bot_2, \ldots, and instances are sets of facts.

Positions and the dependency graph. A position is a pair (R,i)(R, i) of a relation RR and an argument number ii. The dependency graph of a set Σ\Sigma of tgds has the positions as nodes. For each tgd of Σ\Sigma, each frontier variable xx and each position pp where xx occurs in the body:

  • there is a regular edge from pp to each position where xx occurs in the head;
  • there is a special edge from pp to each position where an existential variable occurs in the head.

Σ\Sigma is weakly acyclic if no cycle of the dependency graph goes through a special edge.

Chase steps. Let KK be an instance. A tgd step uses a tgd and a map hh of its body into KK such that no extension of hh maps the head into KK. It adds the facts ψ(h(x),N)\psi(h(x), N), with fresh nulls NN for the existential variables. An egd step uses an egd and a map hh of its body into KK with h(xi)≠h(xj)h(x_i) \neq h(x_j). If both values are constants, the chase fails. Otherwise it replaces a null among the two by the other value everywhere in KK. A chase sequence of II with Σ\Sigma starts at K0=IK_0 = I and makes one step at a time.

Theorem. Let Σ\Sigma be a finite set of tgds and egds whose tgds are weakly acyclic. There is a polynomial pΣp_\Sigma such that, for each instance II, each chase sequence of II with Σ\Sigma has at most pΣ(∣I∣)p_\Sigma(|I|) steps. So for a fixed Σ\Sigma, each chase stops, with a result or with a failure, after a number of steps polynomial in the size of II (data complexity).

In plain words

The chase repairs an instance by adding missing facts. Some rules invent new unknown values, and an invented value can trigger a rule that invents another one, and so on forever.

Draw a graph whose nodes are the columns of the relations. Draw an arrow when a rule copies a value from one column to another, and a marked arrow when a rule invents a value in a column because of a value in another column. If no loop of arrows contains a marked arrow, invented values cannot keep making new invented values: the depth of invention has a limit. So the number of invented values is bounded by a polynomial in the size of the data, and the chase must stop. The rules that make two values equal only remove values, so they do not break this.

Proof

Let nn be the number of values of II, let PP be the number of positions, let kk be the largest number of frontier variables and ww the largest number of existential variables of a tgd of Σ\Sigma.

Rank. The rank of a position pp is the largest number of special edges on a walk that ends at pp. If a walk had P+1P + 1 special edges, two of their end positions would be equal. The part of the walk between them is a closed walk that contains a special edge u→vu \to v. The rest of that closed walk goes from vv back to uu and contains a simple path from vv to uu, so the edge and the path form a cycle through a special edge. This is false for a weakly acyclic set, so each rank is at most PP. A regular edge q→pq \to p gives rank(q)≤rank(p)\mathrm{rank}(q) \le \mathrm{rank}(p), and a special edge q→pq \to p gives rank(q)<rank(p)\mathrm{rank}(q) < \mathrm{rank}(p). Let P≤jP_{\le j} be the set of positions of rank at most jj.

Three facts about steps.

  1. A tgd step puts at a head position pp either a value h(x)h(x) of a frontier variable, which already occurs at a body position qq with a regular edge q→pq \to p, so q∈P≤rank(p)q \in P_{\le \mathrm{rank}(p)}; or a fresh null. In the second case each frontier variable occurs only at body positions with a special edge to pp, so all frontier values come from P≤rank(p)−1P_{\le \mathrm{rank}(p) - 1}.
  2. An egd step that does not fail replaces one null aa by a value bb everywhere. After it, aa never occurs again, because each later null is fresh.
  3. For times t<t′t < t', let st,t′s_{t,t'} be the composition of the replacements of the egd steps between tt and t′t'. Then st,t′(Kt)⊆Kt′s_{t,t'}(K_t) \subseteq K_{t'}, because a tgd step only adds facts and an egd step applies its replacement to all facts.

Tokens. Fix jj. We hand out tokens to the values that occur at positions of P≤jP_{\le j}. At time 0, each such value of II gets a new token. When a tgd step puts a fresh null at a position of P≤jP_{\le j}, the null gets a new token. When an egd step replaces aa by bb, and aa holds a token and bb holds none, then bb takes the token of aa; otherwise the token of aa, if any, is dropped. By induction on the steps, using fact 1 for copied values and fact 2 for egd steps, two statements hold at each time tt.

  • (T1) Each value that occurs at a position of P≤jP_{\le j} holds exactly one token, and no two values hold the same token.
  • (T2) If a token is held by uu at time tt and by u′u' at a later time t′t', then u′=st,t′(u)u' = s_{t,t'}(u).

Let NjN_j be the number of tokens created at level jj over the whole sequence. Then Nj≤n+(the number of fresh nulls placed at positions of P≤j)N_j \le n + (\text{the number of fresh nulls placed at positions of } P_{\le j}).

One tgd fires a bounded number of times. Let dd be a tgd whose frontier variables x1,…,xkx_1, \ldots, x_k all occur at body positions of P≤iP_{\le i}. Map each step that applies dd at time tt, with the map hh, to the tuple of tokens at level ii held by h(x1),…,h(xk)h(x_1), \ldots, h(x_k) at time tt. Assume that two steps at times t<t′t < t', with maps hh and h′h', give the same tuple. The step at tt adds ψ(h(x),N)\psi(h(x), N), so by fact 3, Kt′K_{t'} contains ψ(s(h(x)),s(N))\psi(s(h(x)), s(N)) for s=st+1,t′s = s_{t+1,t'}. By (T1) and (T2), h′(xl)=s(h(xl))h'(x_l) = s(h(x_l)) for each ll. Then h′h' extends to the head by y↦s(N)y \mapsto s(N), so the step at t′t' is not a tgd step, which is a contradiction. So dd fires at most NikN_i^k times if k≥1k \ge 1, and at most once if k=0k = 0, as its head then holds forever. In both cases the count is at most (Ni+1)k(N_i + 1)^k.

The recursion. By fact 1, a fresh null at a position of rank at most jj comes from a tgd whose frontier variables all occur at positions of rank at most j−1j - 1. Each step makes at most ww nulls. So, with N−1=0N_{-1} = 0,

Nj≤n+∣Σ∣ w (Nj−1+1)k.N_j \le n + |\Sigma| \, w \, (N_{j-1} + 1)^k.

By induction on jj, NjN_j is at most a polynomial in nn of degree at most max⁡(1,k)j\max(1, k)^j, with coefficients that depend only on Σ\Sigma. Each position has rank at most PP, so NPN_P bounds the number of all values that ever occur.

The length. Each tgd has its frontier variables at positions of rank at most PP, so by the bound above there are at most ∣Σ∣(NP+1)k|\Sigma| (N_P + 1)^k tgd steps. By fact 2, each egd step that does not fail removes a null for good, so there are at most NPN_P of them, and at most one step fails. So each chase sequence has at most

pΣ=∣Σ∣(NP+1)k+NP+1p_\Sigma = |\Sigma| (N_P + 1)^k + N_P + 1

steps. Since nn is at most the largest arity times ∣I∣|I|, this is a polynomial in ∣I∣|I| for a fixed Σ\Sigma. ■\blacksquare

Consequences

  • Existence of solutions. Let a schema mapping have source-to-target tgds and target dependencies that are egds and weakly acyclic tgds. Then run a chase. If it fails, no solution exists. If it succeeds, the result is a universal solution. So the existence of a solution is decidable in polynomial time in data complexity. Without a condition of this kind the problem is undecidable in general.
  • Query answering. The certain answers of a union of conjunctive queries are the null-free answers of naive evaluation on the chase result, so they take polynomial time in data complexity.
  • The core. Gottlob and Nash showed that the core of the universal solutions can then also be computed in polynomial time in data complexity (see core computation for data exchange).
  • Any order of steps. The bound holds for each chase sequence, so an implementation may choose the order of the steps freely.

Tightness

  • Sufficient, not necessary. Take the single tgd ∀x,y (R(x,y)∧S(y)→∃z R(y,z))\forall x, y\, (R(x, y) \wedge S(y) \to \exists z\, R(y, z)). The variable yy occurs at (R,2)(R, 2) in the body and zz occurs at (R,2)(R, 2) in the head, so there is a special edge from (R,2)(R, 2) to itself, and the set is not weakly acyclic. But each chase stops: a step needs S(y)S(y), no step adds to SS, and after one step with a given yy the head holds for yy. So there are at most ∣SI∣|S^I| steps.
  • Without the condition, the chase may not stop. With ∀x,y (E(x,y)→∃z E(y,z))\forall x, y\, (E(x, y) \to \exists z\, E(y, z)) and I={E(a,b)}I = \{E(a, b)\}, each step adds a fact E(⊥i,⊥i+1)E(\bot_i, \bot_{i+1}) whose new null starts a new step. The special edge from (E,2)(E, 2) to itself is a cycle.
  • The bound is not polynomial in combined complexity. Take the tgds R(x)∧R(y)→∃z S1(x,y,z)R(x) \wedge R(y) \to \exists z\, S_1(x, y, z) and, for 1≤i<r1 \le i < r, Si(x,y,z)∧Si(x′,y′,z′)→∃v Si+1(z,z′,v)S_i(x, y, z) \wedge S_i(x', y', z') \to \exists v\, S_{i+1}(z, z', v), each with all its variables universally quantified. All edges go from SiS_i to Si+1S_{i+1}, so the set is weakly acyclic, and (Si,3)(S_i, 3) has rank ii. Each pair of nulls of SiS_i gives a new fact, so ∣Si∣=n2i|S_i| = n^{2^i} for nn values in RR. With n=2n = 2 and r=3r = 3, the chase makes facts in the counts 4, 16 and 256. The number of steps is doubly exponential in the number of tgds, so the degree of pΣp_\Sigma must grow with Σ\Sigma.

History

Fagin, Kolaitis, Miller and Popa defined weakly acyclic sets of tgds and proved the polynomial bound on chase sequences in their paper on data exchange, presented at ICDT 2003 and published in Theoretical Computer Science in 2005. Before that, the chase was mostly used with full dependencies, which make no new values and so always stop. Weak acyclicity became the usual assumption on target dependencies in data exchange, and later work found larger classes of tgds with a terminating chase.

References

  1. Ronald Fagin, Phokion G. Kolaitis, Renée J. Miller and Lucian Popa, Data exchange: semantics and query answering, Theoretical Computer Science 336(1), 2005, weakly acyclic sets of tgds and the polynomial bound on the length of chase sequences
  2. Marcelo Arenas, Pablo Barceló, Leonid Libkin and Filip Murlak, Foundations of Data Exchange, Cambridge University Press, 2014, Chapter 5, Existence of solutions

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/41NFV7/text.yaml