Memoization for Unary Logic Programming: Characterizing Ptime

Memoization for Unary Logic Programming: Characterizing Ptime


We give a characterization of deterministic polynomial time computation based on an algebraic structure called the resolution semiring, whose elements can be understood as logic programs or sets of rewriting rules over first-order terms.

More precisely, we study the restriction of this framework to terms (and logic programs, rewriting rules) using only unary symbols. We prove it is complete for polynomial time computation, using an encoding of pushdown automata. We then introduce an algebraic counterpart of the memoization technique in order to show its Ptime soundness.

We finally relate our approach and complexity results to complexity of logic programming. As an application of our techniques, we show a Ptime-completeness result for a class of logic programming queries which use only unary function symbols.

Implicit Complexity, Resolution, Logic Programming, Polynomial Time, Proof Theory, Pushdown Automata, Geometry of Interaction.

itemsep=0pt \setenumerateitemsep=0pt \setitemizeleftmargin= \setenumerateleftmargin= \AfterEndEnvironmentitemize\noindentnext \AfterEndEnvironmentenumerate\noindentnext \newtogglenewpage \togglefalsenewpage \bbl@opt@hyphenmap

I Introduction

Complexity theory focuses on questions related to resource usage of computer programs, such as the amount of time or memory a given program will need to solve a problem.

Complexity classes are defined as sets of problems that can be solved by algorithms whose executions need comparable amounts of resources. For instance, the class Ptime is the set of predicates over binary words that can be decided by a Turing machine implementing an algorithm whose execution time is bounded by a polynomial in the size of its input.

However, these definitions depend on the notion of machine and cost-model considered, for the efficiency of an algorithm is sensible to these. The \enquoteinvariance thesis [Boas1990] is a way to bypass this limitation by defining what \enquotea reasonable model is: all the \enquotereasonable models (endowed with cost models) can simulate each other with a \enquotereasonable overhead. The bootstrap for this notion to apply largely was to remark that polynomial bounds on execution time are robust, as the class of problems captured by different models where this bound coincide. The definition is still machine-dependent, but not dependent of a particular model of computation.

One of the main motivations for an implicit computational complexity (ICC) theory is to find completely machine-independent characterizations of complexity classes. The aim is to characterize classes not \enquoteby constraining the amount of resources a machine is allowed to use, but rather by imposing linguistic constraints on the way algorithms are formulated. [DalLago2012a, p. 90] This has been already achieved via different approaches, one of which is based on considering restricted programming languages or computational principles [Bellantoni1992a, Leivant1993, Neergaard2004].

A number of results also arose from proof theory through the study of subsystems of linear logic [Girard1987]. More precisely, the Curry-Howard — or proofs as programs — correspondence expresses a deep relation between formal proofs and typed programs. For instance, one can define a formula Nat which corresponds to the type of binary integers, in the sense that a given (cut-free, i.e. normal, already evaluated) proof of this type represents a given natural number. A proof of the formula then corresponds to an algorithm computing a function from integers to integers, where the computation itself amounts to a rewriting on proofs: the cut-elimination procedure.

By restricting the rules of the logical system, one obtains a subsystem where less proofs of type can be written, hence less algorithms can be represented. In a number of such restricted systems the class of accepted proofs, i.e. of programs, corresponds1 to some complexity class: elementary complexity [Girard1995, Danos2003], polynomial time [Lafont2004, Baillot2004], logarithmic [Lago2010d] and polynomial [Gaboardi2012] space.

More recently, new methods for obtaining implicit characterizations of complexity classes based on the geometry of interaction (GoI) research program [Girard1989b] have been developed. The GoI approach offers a more abstract and algebraic point of view on the cut-elimination procedure of linear logic. One works with a set of untyped programs represented as some geometric objects, e.g. graphs [Danos1990, Seiller2012] or generalizations of graphs [Seiller2014a], bounded linear maps between Hilbert spaces (operators) [Girard1989a, Girard2011a, Seiller2014b], clauses (or \enquoteflows) [Girard1995a, Bagnol2014]. This set of objects is then considered together with an abstract notion of execution, seen as an interactive process: a function does not process a static input, but rather communicate with it, asking for values, reading its answers, asking for another value, etc.

Types can then be defined as sets of program representations sharing comparable behaviors. For instance the type is the set of untyped programs which, given an integer as input, produce an integer as output.

This approach based on the GoI differs from previous ICC works using linear logic in that they do not rely on a restriction of some type system, but rather on a restriction on the set of program representations considered. Still, they benefit from previous works in type theory: for instance the representation of integers used here comes from their representation in linear logic, translated in the GoI setting, whose interactive point of view on computation has proven crucial in characterizing logarithmic space computation [Lago2010d].

The first results that used those innovative considerations were based on operator algebras [Girard2012, Aubert2014ctemp, Aubert2015temp]. Here we consider a more syntactic flavor of the GoI where untyped programs are represented in the so-called resolution semiring [Bagnol2014], a semiring based on the resolution rule [Robinson1965] and a specific class of logic programs. This setting presents some advantages: it avoids the involvement of operator algebras theory, it eases the discussions in terms of complexity (we manipulate first-order terms, which have natural notions of size, height, etc.) and it offers a straightforward connection with complexity of logic programming [Dantsin2001].

Previous works in this direction led to characterizations of logarithmic space predicates Logspace and co-NLogspace [Aubert2014, Aubert2014b], by considering for instance restrictions on the height of variables.

Our main contribution here is a characterization of the class Ptime by studying a natural restriction, namely that one is allowed to use exclusively unary function symbols. Pushdown automata2 are easily related to this simple restriction, for they can be represented as logical programs satisfying this \enquoteunarity restriction. This will imply the completeness of the model under consideration for polynomial time predicates.

We then complete the characterization by showing that any such unary logic program can be decided in polynomial time. This part of the proof consists in an adaptation of S. Cook’s memoization technique [Cook1971a] to the context of logic programs.

The last part of the paper presents consequences of these results in terms of complexity of logic programming, namely that the corresponding class of queries are Ptime-complete, when considering combined complexity [Dantsin2001, p. 380].

Compared to other ICC characterizations of Ptime, and in particular those coming from proof theory, our results have a simple formulation and provide an original point of view on complexity classes.

A byproduct of this work is to provide a method to test membership in Ptime: if one can rephrase a problem with clauses using only unary function symbols, then our result ensures that the problem lies in Ptime. Conversely if a problem cannot be rephrased that way, it lies outside of Ptime.

I-a Outline of the paper

We begin by giving in LABEL:semiring the formal definition of the resolution semiring; then briefly explain how words can be represented in this structure (LABEL:sec_rep) and recall the characterization of logarithmic space obtained in earlier work (LABEL:sec_logspace). In LABEL:sec_stack we introduce the restricted semiring that will be under study in this paper: the semiring.

The next two sections are respectively devoted to the completeness and soundness results for Ptime. For completeness, we first review the fact that multi-head finite automata with pushdown stack characterize Ptime and review the memoization technique in this case (LABEL:sec_cook), and then show how to represent them as elements built from the semiring (LABEL:sec_completeness). The soundness result is then obtained by adapting memoization to the semiring. This adaptation, which we call the saturation technique, is introduced in LABEL:saturation-section.

In the last section, we formulate our results in terms of complexity of logic programming. In particular, we explain how elements of the semiring can be seen as a particular kind of unary logic programs to which the saturation technique can be applied. This allows us to show that the combined complexity problem for unary logic program is Ptime-complete.

As an illustration, we show in LABEL:sec_cvp that the circuit value problem can be solved with this method.


  1. We mean extensional correspondence: they compute the same functions.
  2. More precisely, -way -head non-deterministic finite automata with pushdown stack. See LABEL:def-automata.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description