Abstract 1 Introduction 2 Preliminaries 3 Static Filtering: A General Algorithm 4 Lower and Upper Bounds for Termination 5 Tractable Static Filtering 6 Incorporating Nonmonotonic Negation 7 Related work 8 Conclusions References

Rule Rewriting Revisited: A Fresh Look at Static Filtering for Datalog and ASP

Philipp Hanisch ORCID Knowledge-Based Systems Group, TU Dresden, Germany Markus Krötzsch ORCID Knowledge-Based Systems Group, TU Dresden, Germany
Abstract

Static filtering is a data-independent optimisation method for Datalog, which generalises algebraic query rewriting techniques from relational databases. In spite of its early discovery by Kifer and Lozinskii in 1986, the method has been overlooked in recent research and system development, and special cases are being rediscovered independently. We therefore recall the original approach, using updated terminology and more general filter predicates that capture features of modern systems, and we show how to extend its applicability to answer set programming (ASP). The outcome is strictly more general but also more complex than the classical approach: double exponential in general and single exponential even for predicates of bounded arity. As a solution, we propose tractable approximations of the algorithm that can still yield much improved logic programs in typical cases, e.g., it can improve the performance of rule systems over real-world data in the order of magnitude.

Keywords and phrases:
Rule rewriting, static optimisation, static filtering, Datalog, Answer Set Programming
Copyright and License:
[Uncaptioned image] © Philipp Hanisch and Markus Krötzsch; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Logic and databases
; Theory of computation Constraint and logic programming ; Theory of computation Equational logic and rewriting
Related Version:
Full Version: https://doi.org/10.48550/arXiv.2601.05108 [16]
Funding:
This work is partly supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in project number 389792660 (TRR 248, Center for Perspicuous Systems) and 390696704 (CeTI Cluster of Excellence) and by the Bundesministerium für Forschung, Technologie und Raumfahrt (BMFTR, Federal Ministry of Research, Technology and Space) in the Center for Scalable Data Analytics and Artificial Intelligence (ScaDS.AI) and in DAAD project 57616814 (SECAI, School of Embedded Composite AI) as part of the program Konrad Zuse Schools of Excellence in Artificial Intelligence.
Editors:
Balder ten Cate and Maurice Funk

1 Introduction

Besides its many other advantages, the declarative nature of logic-based rule languages also enables effective optimisation through logically equivalent rewritings. Of course, already for plain Datalog, logical equivalence is undecidable, and highly complex in decidable special cases [6]. But many concrete transformations that guarantee logical equivalence have been proposed, ranging from the popular magic sets [3, 28, 29] to recent proposals [31, 32, 35, 36]. Like these examples, many rule rewritings are static optimisations, which do not depend on the concrete set of facts (data) that is to be processed.

One of the classical proposals of this kind is static filtering, the generalisation of selection pushing methods from relational databases to Datalog, introduced by Kifer and Lozinskii [22, 23, 24]. The underlying principle of enforcing restrictions (“filters”) on intermediate results as early as possible in the computation is a tried and tested paradigm in databases, and does – in contrast to, e.g., magic sets – not change the general structure of derivations fundamentally. Moreover, static filtering strongly increases the effectivity of the related method of projection pushing [24]. Static filtering can enable polynomial (data complexity) or exponential (combined complexity) performance improvements (see Examples 1 and 23).

Surprisingly, the journal paper of Kifer and Lozinskii has attracted less than 50 citations in the past 35 years.111Google Scholar, https://scholar.google.com/scholar?cites=13499523163799224695, retrieved 8 September 2025 Actual uses of the method are rarely reported [5, 11, 26], while most mentions consider it distantly related work. Is this basic optimisation approach maybe so fundamental that it is not even mentioned by implementers? Or is it known and used under another name?

Example 1.

We ran a small experiment to find out, using the following Datalog rules (see Section 2 for a formal introduction to Datalog, and the literature for more details [25, 27]):

p(0,,0,0,𝚊). p(1,,1,0,𝚋). (1)
p(x1,,xi,1,0,,0,y) p(x1,,xi,0,1,,1,y)for all i{1,,} (2)
out(y) p(x1,,x,y)y=𝚋 (3)

where p is an (+1)-ary predicate with 1, = denotes equality, y and xk are variables, and 0, 1, 𝚊, and 𝚋 are constants. Rules (2) implement a binary counter over bits, so exponentially many p-facts are inferred from the facts (1). Optimisation is possible if we are only interested in inferences for predicate out: then the precondition y=𝚋 can be added to the rules (2), so that just one new p-fact follows. Static filtering produces this rewriting.

Table 1: Runtimes for example program (1)–(3) with =19 (median of five runs, timeout at 5min, evaluation system: Linux, AMD Ryzen 7 PRO 5850U, 16 GiB RAM).

Soufflé v2.5 Nemo v0.8.1 Clingo v5.8.0 DLV v2.1.2 Original 1214ms >5min 1104ms 74579ms Rewritten 24ms 99ms 8ms 3ms

Many modern rule systems let users specify output predicates. For our experiment, we considered Datalog engines Soufflé [20] (syntax .output out) and Nemo [18] (syntax @export out :- csv{}.), and ASP engines Clingo [13] and DLV [2] (syntax #show out/1. for both). Table 1 shows runtimes for the original program and the optimised version. Evidently, each tool benefits from the optimisation, yet none implements it by default.

Why is such a natural optimisation, considered standard in relational query optimisation, ignored in modern rule systems? Research culture may be a reason. Typical benchmarks for comparing systems are already optimised, so static optimisations offer no benefits. They are likely more effective with less polished user inputs, especially during development and experimentation. Moreover, static filtering has not attained the popularity of other approaches, especially magic sets and semi-naive evaluation, and may not be known to many implementers. The original description relies on system graphs as an auxiliary concept that many readers may not know today, yet we are not aware of modern accounts or textbook explanations of the method.

Another reason might be practicality. Kifer and Lozinskii found the method to be exponential in the worst case – as hard as the Datalog reasoning task it aims to optimise – and did not suggest tractable variants. It is also left open how static filtering generalises to further filter expressions (Kifer and Lozinskii only consider binary relations like =, , and ), and to non-monotonic negation or ASP.

In this work, we therefore revisit static filtering and introduce a generalised rewriting that supports arbitrary filters (Section 3). Analysing the complexity of our method (Section 4), we find further exponential increases over the prior special case, which motivates our design of a tractable variant that is still reasonably general (Section 5). Finally, we show how static filtering can be extended to rules with negation and to ASP (Section 6), before comparing closely related works (Section 7). Detailed proofs for all claims are found online [16].

2 Preliminaries

We consider a signature based on mutually disjoint, countably infinite sets of constants 𝐂, variables 𝐕, and predicates 𝐏, where each predicate p𝐏 has arity ar(p)0. Terms are elements of 𝐕𝐂. We write bold symbols 𝒕 for lists t1,,t|𝒕| of terms (and for terms of special types, such as lists of variables 𝒙). Lists are treated like sets when order is not relevant, so we may write, e.g., 𝒙𝐕. By var(E) we generally denote the set of variables in an expression E. For a mapping σ:𝒙𝐂 and expression E, we obtain Eσ by simultaneously replacing all occurrences of x𝒙 by σ(x).

Rules and programs

An atom a¯ is an expression p(𝒕) with p𝐏, 𝒕 a list of terms, and ar(p)=|𝒕|. A (Datalog) rule ρ is a formula HB, where the head H is an atom, the body B is a conjunction of atoms, and all variables are implicitly universally quantified. We require that all variables in H also occur in B (safety). Conjunctions of atoms may be treated as sets of atoms. A (Datalog) program P is a finite set of rules. A predicate p is an EDB atom in P if it only occurs in rule bodies, and an IDB atom if it occurs in some rule head.222These terms originate from extensional/intentional database.

Semantics

A fact for predicate p is an atom p(𝒄) with 𝒄𝐂. A database 𝒟 for a program P is a potentially infinite set of facts for EDB predicates of P. We allow 𝒟 to be infinite, so as to accommodate conceptually infinite built-in relations, such as . Practical systems typically evaluate such built-ins on demand and syntactically ensure that infinite built-ins do not lead to infinite derivations, e.g., by requiring that variables in built-ins also occur in body atoms with finite predicates. Such concerns are unimportant to our results, so we can unify (given) input facts and (computed) built-in relations.

The (unique) model for program P and database 𝒟 is the least set of facts such that (1) 𝒟, and (2) for every rule ρP with variables 𝒙, and every mapping σ:𝒙𝐂, if σ(B) then σ(H). If σ(B), we also call σ a match of ρ on . Models can be equivalently defined through iterated rule applications, proof trees, or as least models of P viewed as a first-order logic theory [1].

For a rule HB with variables 𝒙, a mapping σ:𝒙𝐂 is applicable to a database 𝒟 if Bσ𝒟 and Hσ𝒟. A set of facts 𝒟 is closed under a program P, written 𝒟P, if there is no ρP with an applicable mapping σ. For a predicate p, let p𝒟={𝒄p(𝒄)𝒟} denote the tuples of p-facts in 𝒟.

Normal form

To simplify presentation, we require that rules contain only variables, no constants, and that atoms in rules do not contain repeated variables. This normal form can be established by defining auxiliary EDB predicates (=)𝒟={𝚌,𝚌𝚌𝐂} and (=𝚍)𝒟={𝚍} for every constant 𝚍𝐂. Now every occurrence of 𝚍𝐂 in a rule is replaced by a fresh variable x, and the atom x=𝚍 is added to the rule body. Similarly, every non-first occurrence of a variable x in a body atom is replaced by a fresh variable x, and the atom x=x is added to the rule body. Similar normalisations can be used for any built-in function that reasoners might support, e.g., arithmetic functions as in a rule p(x+y)q(x,y) can be rewritten as p(z)q(x,y)z=x+y with (=+)𝒟={𝚕,𝚖,𝚗𝐂3𝚕=𝚖+𝚗}. As before, the infinite EDB predicate is just a conceptual model for a real systems’ on-demand computation of its supported built-in functions.

Outputs and filters

Given a program P, we consider distinguished sets 𝐏out𝐏 of output predicates and 𝐅𝐏 of filter predicates, where all filter predicates must be EDB predicates in P. Outputs define which inferences are of interest to users, and are supported in many reasoners, including the ones in Table 1. Filters are used in our algorithms to reduce inferences for non-output predicates, and would be defined by the reasoner implementation: they should be easy to check and highly selective. For example, the above predicates for = are good filters, whereas an EDB predicate that is stored in a large file on disk most likely is not. However, specific predicates like “x is a string with letter e in third position” or pre-loaded data with fast index structures can also be suitable filters. Given a set of atoms B, we define B𝐅={p(𝒕)Bp𝐅} and B𝐅¯=BB𝐅 as the conjunction of atoms with filter predicates and, respectively, atoms with non-filter predicates.

Rules with generalised filters

A rule with generalised filter expressions has the form HB𝐅¯G𝐅 with H a head atom, B𝐅¯ a conjunction of non-filter atoms, and G𝐅𝐆 a positive boolean combination of filter atoms, defined recursively:

𝐆p(𝒕):p𝐅,|𝒕|=ar(p),𝒕𝐂𝐕(𝐆𝐆)(𝐆𝐆).

Positive boolean combinations of body atoms are normally syntactic sugar in Datalog: we can replace any (body) disjunction A[𝒙]B[𝒚] over (possibly overlapping) sets of variables 𝒙 and 𝒚 by a fresh atom D[𝒙𝒚], and add rules D[𝒙𝒚]A[𝒙] and D[𝒙𝒚]B[𝒚]. The fresh atom D avoids the exponential blow-up that would occur if we would instead create two copies of the rule, one with A and one with B. With potentially infinite filter predicates, however, this syntactic transformation is not natural, since the auxiliary D could be infinite, whereas it is easy for systems to evaluate nested expressions G𝐅 in place. Therefore, if not otherwise stated, all programs below may include generalised filters. Their normal form is defined as for Datalog.

3 Static Filtering: A General Algorithm

Next, we present a method for optimising Datalog programs by static rewriting. The optimised programs have smaller least models that are nonetheless guaranteed to contain the same facts for output predicates 𝐏out. A comparison with the work of Kifer and Lozinskii is given in Section 7.

We consider a fixed program P in normal form, a database 𝒟, filter predicates 𝐅, and output predicates 𝐏out. Facts for non-filter predicates in 𝒟 are irrelevant for static filtering.

Example 2.

As a running example, we consider a depth-bounded reachability check:

r(x,y,n) e(x,y)n= 0 (4)
r(x,z,m) r(x,y,n)e(y,z)m=n+1 (5)
out(y) r(x,y,n)x=𝚊n 5 (6)

where out is the output predicate. Notably, rule (5) can produce infinitely many inferences if the graph described by e is cyclic, but only finitely many nodes reachable from 𝚊 in 5 steps are relevant for the output.

The logic of filters

For a given arity k>0, let 𝐍k={𝟏,,𝒌} be a set of k positional markers. A filter atom (for arity k) is an expression f¯=p(𝒎𝟏,,𝒎) where p𝐅 with =ar(p) and 𝒎𝒊𝐍k for i=1,,. The semantics of f¯ is the relation f¯𝒟={𝒄𝐂kcm1,,cmp𝒟}. Let 𝐅[k] be the set of all filter atoms of arity k over 𝐅. The filter formulas k are the positive boolean formulas over 𝐅[k]:

k𝐅[k](kk)(kk) (7)

Their semantics is defined as expected: 𝒟=𝐂k, 𝒟=, (FG)𝒟=F𝒟G𝒟, and (FG)𝒟=F𝒟G𝒟. Given filter formulas F,Gk, we write FG if F𝒟G𝒟, and FG if FG and GF. We can assume that and are only used at the root level, using the usual simplifications: (F), (F)F, (F)F, and (F) (and their commutated versions). A filter formula is simplified if none of these rewritings applies to it.

Example 2 might use filter predicates =𝚊,  5, and =+1. Since filter formulas do not allow constants, we assume distinct predicates for every pattern of constant use. Implementations generally decide which filters to consider – those that occur syntactically are required, but others can be added.

Optimised filter computation

For every IDB predicate p𝐏, we seek a filter formula flt(p)ar(p), such that we only need to derive facts p(𝒄) if 𝒄flt(p)𝒟. To obtain an algorithm, some operations have to be concretely implemented for the chosen filters 𝐅 and every k1:

  1. 1.

    It must be possible to decide FG for any F,Gk.

  2. 2.

    There is a canonical representation function rep:kk, such that rep(F)F, and FG implies rep(F)=rep(G), for all F,Gk.

For an atom p(𝒙) with arity ar(p)=k, the mapping ιp(𝒙):𝒊xi maps the positional markers 𝟏,,𝒌 to 𝒙. We extend ιp(𝒙) to filter formulas F, i.e., we obtain ιp(𝒙)(F) by replacing each positional marker 𝒊 with ιp(𝒙)(𝒊)=xi. For r(x,y,n) of rule (5) and F=𝟑5, e.g., we get ιr(x,y,n)(F)=ιr(x,y,n)(𝟑5)=n5.

Algorithm 1 Static filter computation.

Algorithm 1 describes the iterative computation of optimised filters. Line L2 initialises filters to for output predicates (“compute all facts”), and to for all others. The formulas are then generalised by looping over all rules (L4) and their non-filter body atoms (L5). Matches to a rule can be restricted to those that satisfy both the head predicate’s filter flt(h) and the rule’s own filter expression G𝐅, which are combined into a filter formula G|var(ρ)| (L6); we map flt(h) to the variables used in the rule. To find the strongest filter formula M for body atom b(𝒚), we take a conjunction of all filters Far(b) that follow from G when mapping F to variables 𝒚 as used in b(𝒚) (L7). Finally, we generalise the current filter for b by including the new M disjunctively, and taking the canonical representation (L8).

Example 3.

We apply Algorithm 1 to Example 2, with a semantically minimised canonical representation in disjunctive normal form. Initially, we have flt(out)= and flt(r)=. Processing body atom r(x,y,n) of rule (6), we get G=x=𝚊n 5. Therefore, we have Gx=𝚊=ιr(x,y,n)(𝟏=𝚊) and Gn 5=ιr(x,y,n)(𝟑 5), and M is equivalent to the conjunction 𝟏=𝚊𝟑 5. This is also the new filter condition flt(r).

In the next iteration, for body atom r(x,y,n) in rule (5), we get G=x=𝚊m 5m=n+1. The only relevant entailments are Gx=𝚊=ιr(x,y,n)(𝟏=𝚊) and Gn 5=ιr(x,y,n)(𝟑 5), so we obtain the same M and flt(r) as before. The algorithm then terminates.

Correctness and use in optimisation

Algorithm 1 is correct in the sense that rule applications can be safely restricted to applying rules only when the conclusion p(𝒄) satisfies the computed filter formula flt(p), as there is no risk of changing derivations for outputs. However, adding body atoms for flt(p) to all rules is often redundant. The next definition characterises choices for equivalent filter conditions.

Definition 4.

Consider a rule ρ=h(𝐱)B𝐅¯G𝐅P. Let F+=ιh(𝐱)(flt(h))G𝐅 denote the formula that combines the given filters G𝐅 with the computed filter for h(𝐱), let 𝐏IDB denote the IDB predicates of P, and let F={ιq(𝐲)(flt(q))q(𝐲)B𝐅¯,q𝐏IDB} denote the filter formula that combines the computed filters for IDB atoms in B𝐅¯. Then a formula ψ is admissible for ρ if

F+ψ and ψFF+.

Then the rule h(𝐱)B𝐅¯ψ is an admissible rewriting of ρ.333Technically, we simplify ψ: if ψ=, the rewritten rule is deleted instead; if ψ=, then ψ is omitted. An admissible rewriting of P is a set that contains an admissible rewriting of each rule of P.

The conditions of Definition 4 ensure that admissible filters are equivalent to the canonically extended body filter F+ under the assumption that body atoms are also restricted to their computed filters F. We obtain the following.

Theorem 5.

If P is an admissible rewriting of P, and p(𝐜) is a fact with p𝐏out, then P,𝒟p(𝐜) iff P,𝒟p(𝐜).

Example 6.

Using the filters computed in Example 3, we can get this admissible rewriting:

r(x,y,n) e(x,y)n= 0x=𝚊 (8)
r(x,z,m) r(x,y,n)e(y,z)m=n+1m 5 (9)
out(y) r(x,y,n) (10)

For rule (8), n= 0x=𝚊 is admissible, as n= 0n 5. For rule (9), body atom r(x,y,n) yields F=x=𝚊n 5, while F+=x=𝚊m 5m=n+1; so m=n+1m 5 is indeed admissible. Finally, for rule (10), an empty () filter is admissible, since F already entails all necessary conditions. Importantly, the final rewriting (and any other admissible rewriting) will always terminate, even when Example 2 fails to do so.

Algorithm 2 Computing admissible filters.

Note that F+ as given in Definition 4 is always admissible, but there can be much simpler expressions. Algorithm 2 shows a practical way to find good admissible filters, which would also find the rewriting of Example 6. An occurrence o of an atom in ψ refers to a single position in ψ where some atom is found (even if the same atom occurs more than once), and ψ[o] denotes the result of replacing this occurrence by . Each iteration in line L12 preserves admissibility of ψ, and the algorithm terminates after linearly many iterations.

Cost and benefits of static filtering

While the concrete performance impact of the rewriting depends on P and 𝒟, static filtering is guaranteed to only reduce but never increase the number of logical entailments. The next result is a direct consequence of the proof of Theorem 5, where we showed that ={q(𝒅)𝒅flt(q)𝒟}𝒟:

Theorem 7.

Let P be an admissible rewriting of P, and let (resp. ) be the model of 𝒟 and P (resp. of 𝒟 and P). Then , and every match of a rule ρP on is also a match of the corresponding rule ρP on .

In particular, every derivation (proof tree) over 𝒟 and P corresponds to a analogous derivation over 𝒟 and P, and the bottom-up computation of requires at most as many rule applications as the bottom-up computation of . The additional cost associated with the use of P is limited to the cost of checking, for each rule match, if the rewritten filters rather than the original filters are satisfied. This cost can be controlled by system designers through the choice of filter predicates to push. The potential savings, on the other hand, can be in the order of ||.

The fact that static filtering preserves the structure of rules, programs, and derivations also improves understandability by human users and compatibility with other optimisations, be it logical (e.g., magic sets) or operational (e.g., join-order optimisation). The rewriting is even idempotent, i.e., already optimised programs will not be modified further when applying static filtering again. None of these advantages is common to all logic program optimisation methods, a prominent counterexample being magic sets.

4 Lower and Upper Bounds for Termination

Table 2: Worst-case number of computing steps of Algorithm 1 in several scenarios, with details on upper and lower bounds depending on the filter size and head arity.
Filter arity Filter size Head arity #Steps
variable infinite variable doubly exponential Thm 11
doubly exponential constant 2 Prop 12
constant 2 infinite variable exponential Thm 11
polynomial Ex 9
variable infinite constant =1 exponential Thm 11
constant 2 exponential Prop 13
variable exponential variable exponential Thm 14
constant 2 polynomial variable Ex 9
variable polynomial constant 2 polynomial Thm 14

Next, we analyse the time complexity of Algorithm 1 in terms of the number of iterations. For now, we abstract from the complexity of checking and computing representatives rep, which are discussed in more detail in Section 5. Our results are summarised in Table 2, depending on given bounds on predicate arity and size of filter relations, where variable arity and infinite size are least restrictive.

Example 8.

Kifer and Lozinskii [24] find that static filtering is exponential, and they give the following example:

r(𝒙,y) p(𝒙,y) (11)
r(𝒙ij,y) r(𝒙,y)for all 1i<j|𝒙| (12)
out(y) r(𝒙,y)i=1|𝒙|xi=𝚊i (13)

where 𝐱ij denotes 𝐱 with variables xi and xj swapped, and all 𝚊i are constants. Rules (12) derive all (exponentially many) permutations of the tuples in r, and the filter computed for r must allow all permutations of 𝐚. Rewriting to plain Datalog, we get rules r(𝐱,y)p(𝐱,y)i=1|𝐱|xi=𝚊ν(i) for exponentially many permutation functions ν.

Example 8 seems to establish an exponential lower bound for Algorithm 1, but the exponential complexity in this case stems merely from the representation of filter formulas. All permutations are obtained in linearly many pairwise swaps, and Algorithm 1 therefore terminates after linearly many iterations of loop L3. Restricting to the filter predicates in the example, the result does require an exponential filter formula, but there are also filter logics that support polynomial representations, e.g., by simply introducing filter predicates for statements like “𝒃 is a permutation of 𝒂”. Example 8 therefore is not illustrating exponential behaviour in general, but we can find other examples that do:

Example 9.

Let p be a non-filter predicate of arity +1. For readability, we do not normalise the rules:

p(𝒙,y) e(𝒙,y) (14)
p(x1,,xi,1,0,,0,y) p(x1,,xi,0,1,,1,y)for all i{1,,} (15)
out(y) p(1,,1,y) (16)

Rule (14) can be rewritten to require each variable in 𝐱 to map to a constant from {0,1}, which can be expressed in a compact generalised filter formula (with nested ). However, the exponentially many admissible combinations of lists from {0,1} are computed in Algorithm 1 by iterating over the successor relation for binary numbers, realised by rules (15). This requires exponentially many steps. Note that normalisation and static filtering in this case would only use filter predicates = , = 0, and = 1, as defined in Section 2.

In fact, as we will see below, Algorithm 1 may even require a doubly exponential number of iterations, and still exponentially many for predicates of bounded arity. The key to showing corresponding upper bounds is the following lemma.

Lemma 10.

Given nh distinct head predicates, if Algorithm 1 performs nhs iterations of loop L3, then there is a head predicate p, and a chain F1Fs of non-equivalent filter formulas Fiar(p).

In other words, (doubly) exponentially long runs require (doubly) exponentially “deep” filter logics. The number of available filter formulas yields a first major upper bound.

Theorem 11.

Let there be n𝐅 filter predicates of arity a𝐅, and nh head predicates of arity ah. Then Algorithm 1 terminates after at most nh2n𝐅aha𝐅 many iterations.

The doubly exponential worst case of Theorem 11 can be reached. As the theorem suggests, the arity of head predicates can even be constant, as long as it is >1.

Proposition 12.

There are programs with filter arity a𝐅= for which Algorithm 1 requires 22 many iterations, even if the head arity is fixed and the size of the filter relations is at most doubly exponential.

Theorem 11 shows that the upper bound drops to single exponential if either (1) we impose a constant bound on the arity a𝐅 of filter predicates, or (2) we fix the arity ah of the head predicates to ah=1. Example 9 showed exponential behaviour in case (1). We can also reach this upper bound in case (2).

Proposition 13.

There are programs with head arity ah=1 and filter arity a𝐅= for which Algorithm 1 requires 2 many iterations, even if the size of the filter relations is at most exponential.

Proposition 12 and 13 consider filter relations that are of a size that is proportional to the double and single exponential length of the runs, whereas Example 9 only requires polynomially sized filter relations. The following result clarifies how filter relation cardinality may affect upper bounds.

Theorem 14.

Let there be n𝐅 filter predicates that correspond to relations in 𝒟 of cardinality c𝐅, and let there be nh head predicates of arity ah. Then Algorithm 1 terminates after at most nh((n𝐅c𝐅)ah+2) iterations.

Theorem 14 yields a polynomial upper bound for the case that filter relations are polynomially bounded and non-filter predicates have a fixed arity. However, many filters in existing systems correspond to infinite relations, so further approaches are required to make static filtering tractable in practice.

5 Tractable Static Filtering

In this section, we further analyse the complexity of Algorithm 1, and propose simplifications for making it tractable. Section 4 showed that runtimes can be prohibitive, even without considering the cost of individual operations. For a full analysis, we must also analyse the cost of lines L7 and L8. Since the result of L8 remains the same when replacing M by any MM, implementations can optimise L7 by computing a potentially smaller M. Nevertheless, Example 8 shows a case where every such M still grows exponentially during polynomially many iterations. Our proposed solution is to restrict flt(p) to special forms of filter formulas that merely approximate those in Algorithm 1.

First, however, we need to address the problem that even the entailment of individual filter formulas is generally undecidable, even for common filters.

Proposition 15.

If 𝐅 contains predicates that can express arithmetic equalities x=y+z and x=yz over natural numbers, and x=n for all n, then there is no algorithm that decides FG for arbitrary k>0 and F,Gk.

It is well-known that arithmetic predicates are challenging to reason with, and Datalog engines commonly restrict to safe arithmetics, where all numeric variables are bound to finite extensions of other predicates. However, this restriction does not simplify static filtering, where abstract filter formulas are considered without such concrete bindings.

We therefore consider entailment relations that are sound but not necessarily complete, except for the basic semantics of the propositional operators in filter formulas.

Definition 16.

Every filter formula F can be considered as a propositional logic formula over its filter atoms. Let prop denote the usual propositional logic entailment relation over these formulas. A binary relation |≈ on filter formulas is an approximate entailment if prop|≈. We write FG if F|≈G and G|≈F.

We generalise Algorithm 1 to approximate entailments by replacing any use of by |≈, and by allowing any representation function rep:kk where Frep(F) and FG implies rep(F)=rep(G). Definition 4 and Algorithm 2 can likewise be generalised by using filters computed by the approximate algorithm. The main results of Sections 3 and 4 still hold in this generalised setting.

Lemma 17.

For any approximate entailment |≈, Algorithm 1 terminates within the bounds of Theorem 11. If P is an admissible rewriting of P based on |≈, and p(𝐜) is a fact with p𝐏out, then P,𝒟p(𝐜) iff P,𝒟p(𝐜).

If |≈ is decidable, Algorithm 1 can be implemented, but may still be intractable. In fact, deciding prop is still hard for coNP. However, weakening |≈ further to omit entailments of prop may impair termination, since propositionally equivalent formulas may have distinct representatives. To obtain a tractable procedure, we further modify Algorithm 1 so that the formulas flt(p) can only be conjunctions of filter atoms, , or . Lines L7 and L8 in the algorithm are now replaced by

flt(b):={A𝒜ιb(𝒚)(flt(b))G|≈ιb(𝒚)(A)} (17)

where 𝒜={}𝐅[ar(b)], and we assume that conjunctions are represented as subsets of 𝒜 with =. We refer to the modified algorithm as conjunctive approximate static filtering (CASF). The complexity depends on the choice of |≈ and the size of 𝐅[ar(b)], but the algorithm is correct in all cases. This follows from the observation that the formulas flt(b) as computed in CASF are logical consequences (w.r.t. ) of those computed in Algorithm 1, i.e., filters are more permissive.

Theorem 18.

If P is an admissible rewriting of P for the filter formulas computed in CASF, and p(𝐜) is a fact with p𝐏out, then P,𝒟p(𝐜) iff P,𝒟p(𝐜).

For polynomial runtime, we need to restrict |≈ so that the entailment in (17) can be decided in P. We consider a finite set 𝒯 of Datalog rules that use only filter predicates in head and body. 𝒯 is a Horn axiomatisation for |≈ if F|≈G holds for filter formulas F,Gk exactly if G is a logical consequence of F𝒯 (considered as a predicate logic theory over the domain of positional markers 𝐍k). Moreover, 𝒯 is a linear axiomatisation if rules in 𝒯 have exactly one body atom.

Theorem 19.

Let 𝐅 be a set of filter predicates with bounded arity, and let 𝒯 be a (fixed) Horn approximation of |≈. Then CASF can be executed in polynomial time over a program P in either of the following cases:

  1. 1.

    𝒯 is a linear approximation, or

  2. 2.

    the filter expressions G𝐅 in P do not contain .

Linear rules as in the first case in Theorem 19 suffice to model basic hierarchies of filter conditions, but the power of Horn logic is required to axiomatise typical binary filters such as order relations [33].

Example 20.

For a set of natural numbers N, consider the (possibly infinite) theory

x𝚌 x=𝚌 𝚌N (18)
x𝚌 y𝚌y=x+𝚍 𝚌,𝚍N (19)
x𝚌 x𝚍 𝚌,𝚍N,𝚌>𝚍 (20)

with rules instantiated for all values of 𝚌 and d as specified. The finite instantiation with N={0,1,5} axiomatises all filter entailments necessary for Examples 3 and 6. The relevant constants N are syntactically given in the input filters.

We observe that the cases in Theorem 19 cannot be combined without loosing tractability:

Proposition 21.

There is a Horn approximation 𝒯 of |≈, such that deciding G|≈A for a filter formula G and an atom A is hard for coNP.

Tractable static filtering for real-world data

Finally, we investigate the impact of (tractable) static filtering for reasoning over real-world data. We implement conjunctive approximate static filtering (CASF) for linear orders and instantiations of the rules of Example 20 for all natural numbers in a program P. Moreover, we treat EDB predicates as filter predicates. We rewrite programs for transitive closure over Wikidata properties via CASF, and we compare the runtime of the original programs with the rewritten ones as well as the runtime for static filtering. In particular, we show that

  1. 1.

    static filtering can improve the performance of modern rule systems by orders of magnitude,

  2. 2.

    the simplifications in Section 5 are general enough to obtain these improvements, and

  3. 3.

    the time necessary for applying tractable static filtering is negligible.

As a typical examples for recursive programs, we use programs for computing the transitive closure of a predicate, and we add an output predicate out and a filter x=𝚊 for a constant 𝚊. We use a template for transitive closure (see Figure 1), which we instantiated for different EDB predicates p(x,y). We extract these predicates from Wikidata properties (see Figure 2). As rule systems, we considered Soufflé v2.5 [20], Nemo v0.8.1 [18], Clingo v5.8.0 [13], and DLV v2.1.2 [2]. We have adopted the programs and inputs to the capabilities of the rule systems: Soufflé and Nemo received facts as CSV files, while Gringo and DLV received them as a list of facts. We applied a timeout at 5min. Our measurements are performed on a regular notebook (Linux; AMD Ryzen 7 PRO 5850U; 16 GiB RAM).

tc(x,y) p(x,y)
tc(x,z) tc(x,y)p(y,z)
out(y) tc(x,y)x=𝚊
tc(x,y) p(x,y)x=𝚊
tc(x,z) tc(x,y)p(y,z)
out(y) tc(x,y)
Figure 1: Template programs for transitive closure over some EDB predicate p𝐏; some filter predicate x=a𝐅 with constant 𝚊 is applied to compute the output predicate out𝐏out; original program (left) and rewritten program by tractable static filtering (right).
Property p Property name #Facts Entity 𝚊
P2652 partnership with 6,638 Q180 (Wikimedia Foundation)
P530 diplomatic relation 7,290 Q33 (Finland)
P1327 partner in business or sport 27,716 Q1203 (John Lennon)
P197 adjacent station 266,608 Q219867 (London King’s Cross)
P47 shares border with 927,553 Q33 (Finland)
Figure 2: Table of used Wikidata properties used in the evaluation, i.e., the programs in Figure 1 are instantiated with properties p and entities 𝚊; #Facts is the number of facts for property p.

Figure 3 shows the runtimes for Programs 1 instantiated with the properties of Table 2. For each property, we run each system with the original program and the rewritten one. In all cases, the rewritten programs require significantly less time – note the log-scale of the plot. For the properties where the systems could finish for the original program, static filtering provides a speed-up in the order of magnitude (from 6.6 times for P1203 and Clingo to 30 times for P2652 and DLV). Moreover, static filtering enables all systems to finish for huge properties with up to 1,000,000 facts within seconds, while all system reached the timeout for the original program there. Finally, we observe that static filtering can be done in a few milliseconds, and it is independent of the number of facts for the underlying property.

Refer to caption
Figure 3: Runtimes (median of five runs) for transitive closure programs for different properties and rule systems; solid bars show runtime for original programs; hatched bars show runtime for rewritten programs; runtime of static filtering (black, solid lines); timeout (red, dotted lines) at 5min.

Our experiments show that (tractable) static filtering can improve the performance of rule systems significantly. However, evaluating a static optimisation method empirically has its limitations. Static optimization, by design, works on inputs that are not manually optimized yet. While such programs are common in practice, there is no grounds for assuming anything about how common this is. Existing public program collections are not representative here either, since most of these published programs have been carefully optimised by experts – exactly the type of manual work that static optimisations try to automate.

6 Incorporating Nonmonotonic Negation

In this section, we extend static filtering for rules with negation. Datalog is often extended with stratified negation [1]. The stable model semantics as used in Answer Set Programming (ASP) [7, 14] is a popular way to generalise this semantics to arbitrary rules with negation. Both cases can benefit from static filtering; especially for ASP, where a polynomial reduction in the grounding size can lead to an exponential performance advantage in solving.

Indeed, static optimisation in ASP is an important active topic of research. Existing approaches include rewritings based on tree decompositions [4, 8], projection [17], rule subsumption and shifting [10], and magic sets [9, 15] – but we are not aware of any work that resembles static filtering. Indeed, Table 1 indicates that leading ASP engines do not implement such optimisations even for basic filters of the form =𝚌. The recent tool ngo, maintained by the Clingo developers, likewise implements many known optimisations, but no static filtering.444https://potassco.org/ngo/ngo.html When running ngo with all optimisations enabled on Example 1, it merely rewrites Rule 3 to out(𝚋)p(x1,,x,𝚋), which, expectably, does not have a notable impact on the runtime of any of the systems tested.

Rules with negation

A negated atom is an expression 𝑛𝑜𝑡p(𝒕) with p𝐏 and |𝒕|=ar(p). A normal rule ρ is a formula HBB, where the head H is an atom, B is a conjunction of atoms, and B is a conjunction of negated non-filter atoms, such that every vvar(ρ) occurs in some atom p(𝒙)B (safety). Negated filter atoms are not needed: we can express them by introducing fresh filter predicates that are interpreted by the complemented relation. Analogously to Datalog, a normal rule with generalised filter expressions has the form HB𝐅¯B𝐅¯G𝐅 with H a head atom, B𝐅¯ a conjunction of non-filter atoms, and G𝐅𝐆 a positive boolean combination of filter atoms. In this section, all rules and programs may include negated atoms and generalised filters (we omit normal). The normal form without repeated variables per (negated or non-negated) atom is defined as for Datalog.

Stable models

For a program P and database 𝒟, let gr(P)={ρσρP,σ:𝐕𝐂} be its grounding. For a set of facts 𝒜, the Datalog program gr(P)𝒜={HBHBBgr(P),B𝒜=} is the reduct. 𝒜 is a stable model of P and 𝒟 if 𝒜 is the model of gr(P)𝒜 and 𝒟. We write sm(P,𝒟) for the set of all such stable models.

Stratified negation

Even when using stable models, we check if programs are (partly) stratified, so as to tighten some filters. Let GP be the graph with the IDB predicates of P as its vertices, and, for every rule q(𝒙)B𝐅¯B𝐅¯G𝐅P, a positive edge p+q for all IDBs p in B𝐅¯, and a negative edge pq for all IDBs p in B𝐅¯. The stratifiable predicates 𝐏str are the vertices p of GP such that there is no cycle C in GP such that C a negative edge and p is reachable from C.

Static filtering for stable models

Importantly, facts that do not contribute directly to the output can still have an impact on stable models. For example, consider a program P with a stable model 𝒜 that contains some q(𝒄)𝒜; then adding a rule p(𝒙)q(𝒙)𝑛𝑜𝑡p(𝒙) for a fresh p means that 𝒜 is no longer stable. Hence, static filtering must not filter facts p(𝒄) relevant to some 𝑛𝑜𝑡p(𝒙).

We therefore define more general initial filters for negated predicates. For a rule ρ=h(𝒙)B𝐅¯B𝐅¯G𝐅 with b(𝒚)B𝐅¯, let Mb(𝒚)={Far(b)G𝐅ιb(𝒚)(F)}, and let Nρp={Mp(𝒚)p(𝒚)B𝐅¯} with =. To obtain a procedure for a program P, we can now modify Algorithm 1 so that the formulas flt(p) are initialised in line L2 with

flt(p){rep()if p𝐏outrep({NρpρP})if p𝐏strrep()otherwise. (21)

Note that flt(p) for p𝐏str if p never occurs in a negated atom. Predicates p𝐏str can be initialised with rep() as before, but we have to consider them in the iterative generalisation: we modify line L5 to loop over all b(𝒚) with b(𝒚)B𝐅¯ or 𝑛𝑜𝑡b(𝒚)B𝐅¯ for IDB predicate b.

Our remaining definitions require only minimal adaptations. For a rule ρ=h(𝒙)B𝐅¯B𝐅¯G𝐅, a filter formula ψ is admissible for ρ if ψ is admissible for h(𝒙)B𝐅¯G𝐅, and h(𝒙)B𝐅¯B𝐅¯ψ is an admissible rewriting of ρ. An admissible rewriting of a program P is a set that contains an admissible rewriting of each rule of P. We can use Algorithm 2 unchanged as a practical way to find good admissible filters. Our main correctness results shows visible equivalence [19] between P and P:

Theorem 22.

If P is an admissible rewriting of program P for database 𝒟, then μ:𝒜{p(𝐜)𝒜𝐜flt(p)𝒟} is a bijection between sm(P,𝒟) and sm(P,𝒟).

In particular, since flt(p) for output predicates p, the restrictions of sm(P,𝒟) and sm(P,𝒟) to facts over output predicates coincide.

One can easily incorporate the ideas of Section 5 to obtain a tractable optimisation procedure for normal logic programs.

7 Related work

Comparison with the original algorithm

The filter computation of Kifer and Lozinskii [24] can be seen as a special case of our approach for a fixed choice of filter predicates (binary equalities and inequalities, possibly involving constants) and representation of filter formulas (in disjunctive normal form). Predicates such as =+1 in Example 2 are not considered as filters. The significance of our generalisation is witnessed by exponential increases in complexity (Section 4), but also by the ability to introduce tractable simplifications (Section 5). The general notion of admissibility and Algorithm 2 are also new.

Kifer and Lozinskii further include a similar method to propagate projections and remove unused predicate parameters. This rewriting is simpler than filter propagation. We have nothing to add to it but note that it is particularly effective if static filtering is applied first.

Example 23.

Propagation of projections does not lead to any simplification for Example 2, but leads to the following rules with reduced arities for the rewriting of Example 6:

r(y,n) e(x,y)n= 0x=𝚊 (22)
r(z,m) r(y,n)e(y,z)m=n+1m 5 (23)
out(y) r(y,n) (24)

Instead of computing the distance of quadratically many pairs x and y, only the distance from a to linearly many y is needed. In general, reducing predicate arities can have big performance advantages, as it may simplify data structures and execution plans.

Comparison with static optimization techniques

Kifer and Lozinskii have already compared their special case of static filtering to existing methods including magic sets [3, 28, 29], and they have have already observed that the approaches by Walker [34] and Gardarin et al. [12] are similar, yet less general. Subsequently, Chang et al. extended the original method of Kifer and Lozinskii to programs with stratified negation, which is less general than our extension to ASP.

Constraint pushing [21, 30] considers rules with constraint atoms, with a propagation scheme similar to Algorithm 1. However, the method might not terminate, as there can be infinitely many constraint atoms.

Zaniolo et al. introduce pre-mappability (PreM) as a sufficient condition for pushing filters into recursive rules, identify some classes of PreM filters, and use such filters to rewrite recursive programs with aggregates [36]. Our Algorithm 1 can be seen as a systematic method for producing pre-mappable filters (flt(p) are pre-mappable).

The FGH-rule by Wang et al. [35] defines a sufficient condition for rewriting a program using given output predicates (or queries), and our admissile rewritings satisfy this condition (which is true for any rewriting that produces the same output facts). Hence, static filtering offers a tractable method to find FGH-rule conforming rewritings.

In general, static filtering promises to work well with some rewriting techniques such as projection propagation and pre-mappability [36], and it is unlikely that it interferes negatively with static optimisations techniques, since static filtering preserves the program structure.

Comparison to magic sets and demand transformation

Magic sets [3, 28, 29] and the closely related demand transformation [31, 32] are static optimisation methods that also aim at reducing inferences by making some rule bodies more selective, and which may seem similar to static filtering on an intuitive level. However, in almost all cases, their outputs are very different from ours, for the following reasons:

  1. 1.

    Static filtering preserves the number of rules and the structure of their non-filter atoms. Magic sets and demand transformation always increase the number of rules and add rules that contain partial body joins.

  2. 2.

    Static filtering cannot optimise programs that do not contain filter predicates. Demand transformation can be used on purely abstract programs.

  3. 3.

    Static filtering uses symbolic reasoning over filters to simplify and summarise expressions, so rewritten rules may contain new derived filters. Magic sets and demand transformation foresee no mechanism for integrating any symbolic knowledge about existing EDB predicates, so rewritten rules are always based on copies of EDB atoms that are syntactic parts of the program.

  4. 4.

    Static filtering is idempotent (optimised programs are not rewritten further). The transformation by magic sets and demand transformation always changes the program, even if applied to its own output.

  5. 5.

    Static filtering makes use of recursive rules for recursively generalising filter expressions. Demand transformation in turn supports rewritings of IDB predicates that are defined by recursive rules.

  6. 6.

    Static filtering includes a simplification step that removes filters that have become redundant after pushing (via admissibility, Def. 4). Magic sets and demand transformation have no mechanism to detect possible simplifications.

Therefore, we do not see any general principle to obtain the benefits of static filtering from magic sets or demand transformation, even in special cases or with further adjustments. Rather, the methods are complementary and can be used together, where static filtering should go first since any reduction in body atoms can reduce the cost of the other transformation.

8 Conclusions

“It is folk wisdom that the right concepts are rediscovered several times” is how Kifer and Lozinskii started their conclusions [24]. In our work, we have revisited and generalised their original approach to static filtering, presented a tractable simplification, and shown how to extend its use to Datalog with stratified negation and ASP. Our framework lets implementers control which filters to push and which logical interactions to consider, and thus to avoid cases where the optimisation might cost more than it saves. Since static filtering also preserves rule and proof structures, it plays well with other optimisations and may even boost them (as in Example 23). It truly seems the “right concept” for many uses, in particular for data-oriented applications where logic programs play the role of queries over potentially large datasets. Thanks to the generality of our framework and the presented simplifications, we are confident that any rule-based system can find a sweet spot where a small amount of effort can yield decisive advantages at least in some cases.

Besides speeding up today’s programs, however, we should also look for new uses ahead. One is modularisation, since re-usable logic programming libraries cannot be optimised manually for (yet unknown) usage contexts. Another is termination, for arithmetic features as shown in Example 6, but also for rule languages with function symbols or existential quantifiers. These and other directions merit further research.

References

  • [1] Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison-Wesley, 1995. URL: http://webdam.inria.fr/Alice/.
  • [2] Mario Alviano, Francesco Calimeri, Carmine Dodaro, Davide Fuscà, Nicola Leone, Simona Perri, Francesco Ricca, Pierfrancesco Veltri, and Jessica Zangari. The ASP system DLV2. In Marcello Balduccini and Tomi Janhunen, editors, Proc. 14th Int. Conf. on Logic Programming and Nonmonotonic Reasoning (LPNMR’17), volume 10377 of LNCS, pages 215–221. Springer, 2017. doi:10.1007/978-3-319-61660-5_19.
  • [3] François Bancilhon, David Maier, Yehoshua Sagiv, and Jeffrey D. Ullman. Magic sets and other strange ways to implement logic programs. In Avi Silberschatz, editor, Proc. 5th ACM SIGACT-SIGMOD Symposium on Principles of Database Systems, pages 1–15. ACM, 1986. doi:10.1145/6012.15399.
  • [4] Manuel Bichler, Michael Morak, and Stefan Woltran. lpopt: A rule optimization tool for answer set programming. Fundam. Informaticae, 177(3-4):275–296, 2020. doi:10.3233/FI-2020-1990.
  • [5] Andreas Billig. A TRIPLE-oriented approach for integrating higher-order rules and external contexts. In Diego Calvanese and Georg Lausen, editors, Proc. 2nd Int. Conf. on Web Reasoning and Rule Systems (RR’08, volume 5341 of LNCS, pages 214–221. Springer, 2008. doi:10.1007/978-3-540-88737-9_17.
  • [6] Pierre Bourhis, Markus Krötzsch, and Sebastian Rudolph. Reasonable highly expressive query languages. In Qiang Yang and Michael Wooldridge, editors, Proc. 24th Int. Joint Conf. on Artificial Intelligence (IJCAI’15), pages 2826–2832. AAAI Press, 2015. URL: http://ijcai.org/Abstract/15/400.
  • [7] Gerhard Brewka, Thomas Eiter, and Miroslaw Truszczynski. Answer set programming at a glance. Commun. ACM, 54(12):92–103, 2011. doi:10.1145/2043174.2043195.
  • [8] Francesco Calimeri, Simona Perri, and Jessica Zangari. Optimizing answer set computation via heuristic-based decomposition. Theory Pract. Log. Program., 19(4):603–628, 2019. doi:10.1017/S1471068419000036.
  • [9] Chiara Cumbo, Wolfgang Faber, Gianluigi Greco, and Nicola Leone. Enhancing the magic-set method for disjunctive Datalog programs. In Bart Demoen and Vladimir Lifschitz, editors, Proc. 20th Int. Conf. on Logic Programming (ICLP’04), volume 3132 of LNCS, pages 371–385. Springer, 2004. doi:10.1007/978-3-540-27775-0_26.
  • [10] Thomas Eiter, Michael Fink, Hans Tompits, Patrick Traxler, and Stefan Woltran. Replacements in non-ground answer-set programming. In Patrick Doherty, John Mylopoulos, and Christopher A. Welty, editors, Proc. 10th Int. Conf. on Principles of Knowledge Representation and Reasoning (KR’06), pages 340–351. AAAI Press, 2006. URL: http://www.aaai.org/Library/KR/2006/kr06-036.php.
  • [11] Alvaro A. A. Fernandes, Maria L. Barja, Norman W. Paton, and M. Howard Williams. The formalisation of ROCK & ROLL: A deductive object-oriented database system. Inf. Softw. Technol., 39(6):379–389, 1997. doi:10.1016/S0950-5849(96)00007-9.
  • [12] Georges Gardarin, Christophe de Maindreville, and Eric Simon. Extending a relational DBMS towards a rule-based system: An approach using predicate transition nets. In Joachim W. Schmidt and Costantino Thanos, editors, Foundations of Knowledge Base Management: Contributions from Logic, Databases, and Artificial Intelligence, Book resulting from the Xania Workshop 1985, Topics in Information Systems, pages 131–152. Springer, 1985.
  • [13] Martin Gebser, Roland Kaminski, Benjamin Kaufmann, and Torsten Schaub. Multi-shot ASP solving with clingo. Theory Pract. Log. Program., 19(1):27–82, 2019. doi:10.1017/S1471068418000054.
  • [14] Michael Gelfond and Vladimir Lifschitz. Classical negation in logic programs and disjunctive databases. New Gener. Comput., 9(3/4):365–386, 1991. doi:10.1007/BF03037169.
  • [15] Sergio Greco. Binding propagation techniques for the optimization of bound disjunctive queries. IEEE Trans. Knowl. Data Eng., 15(2):368–385, 2003. doi:10.1109/TKDE.2003.1185840.
  • [16] Philipp Hanisch and Markus Krötzsch. Rule rewriting revisited: A fresh look at static filtering for Datalog and ASP, 2026. arXiv:2601.05108.
  • [17] Nicholas Hippen and Yuliya Lierler. Automatic program rewriting in non-ground answer set programs. In José Júlio Alferes and Moa Johansson, editors, Proc. 21st Int. Symposium on Practical Aspects of Declarative Languages (PADL’19), volume 11372 of LNCS, pages 19–36. Springer, 2019. doi:10.1007/978-3-030-05998-9_2.
  • [18] Alex Ivliev, Lukas Gerlach, Simon Meusel, Jakob Steinberg, and Markus Krötzsch. Nemo: Your friendly and versatile rule reasoning toolkit. In Pierre Marquis, Magdalena Ortiz, and Maurice Pagnucco, editors, Proc. 21st Int. Conf. on Principles of Knowledge Representation and Reasoning (KR’24), pages 743–754. IJCAI Organization, 2024. doi:10.24963/kr.2024/70.
  • [19] Tomi Janhunen. Some (in)translatability results for normal logic programs and propositional theories. J. Appl. Non Class. Logics, 16(1-2):35–86, 2006. doi:10.3166/jancl.16.35-86.
  • [20] Herbert Jordan, Bernhard Scholz, and Pavle Subotic. Soufflé: On synthesis of program analyzers. In Swarat Chaudhuri and Azadeh Farzan, editors, Proc. 28th Int. Conf. on Computer Aided Verification (CAV’16), Part II, volume 9780 of LNCS, pages 422–430. Springer, 2016. doi:10.1007/978-3-319-41540-6_23.
  • [21] David B. Kemp, Kotagiri Ramamohanarao, Isaac Balbin, and Krishnamurthy Meenakshi. Propagating constraints in recusive deduction databases. In Ewing L. Lusk and Ross A. Overbeek, editors, Proc. North American Conference on Logic Programming, pages 981–998. Citeseer, MIT Press, 1989.
  • [22] Michael Kifer and Eliezer L. Lozinskii. Filtering data flow in deductive databases. In Giorgio Ausiello and Paolo Atzeni, editors, Proc. 1st Int. Conf. on Database Theory (ICDT’86), volume 243 of LNCS, pages 186–202. Springer, 1986. doi:10.1007/3-540-17187-8_37.
  • [23] Michael Kifer and Eliezer L. Lozinskii. Implementing logic programs as a database system. In Proc. 3rd Int. Conf. on Data Engineering (ICDE’87), pages 375–385. IEEE Computer Society, 1987. doi:10.1109/ICDE.1987.7272403.
  • [24] Michael Kifer and Eliezer L. Lozinskii. On compile-time query optimization in deductive databases by means of static filtering. ACM Trans. Database Syst., 15(3):385–426, 1990. doi:10.1145/88636.87121.
  • [25] Markus Krötzsch. Modern datalog: Concepts, methods, applications. In Alessandro Artale, Meghyn Bienvenu, Yazmín Ibáñez García, and Filip Murlak, editors, Joint Proceedings of the 20th and 21st Reasoning Web Summer Schools (RW 2024 & RW 2025), volume 138 of OASIcs. Dagstuhl Publishing, 2025. doi:10.4230/OASIcs.RW.2024/2025.7.
  • [26] Jie Liu, Senlin Liang, Dan Ye, Jun Wei, and Tao Huang. ETL workflow analysis and verification using backwards constraint propagation. In Pascal van Eck, Jaap Gordijn, and Roel J. Wieringa, editors, Proc. 21st Int. Conf. on Advanced Information Systems Engineering, volume 5565 of LNCS, pages 455–469. Springer, 2009. doi:10.1007/978-3-642-02144-2_36.
  • [27] David Maier, K. Tuncay Tekle, Michael Kifer, and David Scott Warren. Datalog: concepts, history, and outlook. In Michael Kifer and Yanhong Annie Liu, editors, Declarative Logic Programming: Theory, Systems, and Applications, volume 20 of ACM Books, pages 3–100. ACM / Morgan & Claypool, 2018. doi:10.1145/3191315.3191317.
  • [28] Inderpal Singh Mumick, Sheldon J. Finkelstein, Hamid Pirahesh, and Raghu Ramakrishnan. Magic is relevant. In Hector Garcia-Molina and H. V. Jagadish, editors, Proc. 1990 Int. Conf. on Management of Data (SIGMOD’90), pages 247–258. ACM Press, 1990. doi:10.1145/93597.98734.
  • [29] Inderpal Singh Mumick and Hamid Pirahesh. Implementation of magic-sets in a relational database system. In Richard T. Snodgrass and Marianne Winslett, editors, Proc. 1994 Int. Conf. on Management of Data (SIGMOD’94), pages 103–114. ACM Press, 1994. doi:10.1145/191839.191860.
  • [30] Divesh Srivastava and Raghu Ramakrishnan. Pushing constraint selections. J. Log. Program., 16(3):361–414, 1993. doi:10.1016/0743-1066(93)90048-L.
  • [31] K. Tuncay Tekle and Yanhong A. Liu. Precise complexity analysis for efficient Datalog queries. In Temur Kutsia, Wolfgang Schreiner, and Maribel Fernández, editors, Proc. 12th Int. ACM SIGPLAN Conf. on Principles and Practice of Declarative Programming, July 26-28, 2010, Hagenberg, Austria, pages 35–44. ACM, 2010. doi:10.1145/1836089.1836094.
  • [32] K. Tuncay Tekle and Yanhong A. Liu. Extended magic for negation: Efficient demand-driven evaluation of stratified Datalog with precise complexity guarantees. In Bart Bogaerts, Esra Erdem, Paul Fodor, Andrea Formisano, Giovambattista Ianni, Daniela Inclezan, Germán Vidal, Alicia Villanueva, Marina De Vos, and Fangkai Yang, editors, Proc. 35 Int. Conf. on Logic Programming (Technical Communications), ICLP 2019 Technical Communications, volume 306 of EPTCS, pages 241–254, 2019. doi:10.4204/EPTCS.306.28.
  • [33] Jeffrey D. Ullman and Allen Van Gelder. Efficient tests for top-down termination of logical rules. J. ACM, 35(2):345–373, 1988. doi:10.1145/42282.42285.
  • [34] Adrian David Walker. SYLLOG: A knowledge based data management system. Department of Computer Science Courant Institute of Mathematical Sciences, 1981.
  • [35] Yisu Remy Wang, Mahmoud Abo Khamis, Hung Q. Ngo, Reinhard Pichler, and Dan Suciu. Optimizing recursive queries with progam synthesis. In Zachary G. Ives, Angela Bonifati, and Amr El Abbadi, editors, Proc. 2022 Int. Conf. on Management of Data (SIGMOD’22), pages 79–93. ACM, 2022. doi:10.1145/3514221.3517827.
  • [36] Carlo Zaniolo, Mohan Yang, Ariyam Das, Alexander Shkapsky, Tyson Condie, and Matteo Interlandi. Fixpoint semantics and optimization of recursive Datalog programs with aggregates. Theory Pract. Log. Program., 17(5-6):1048–1065, 2017. doi:10.1017/S1471068417000436.