Skip to main content
QUICK REVIEW

[Paper Review] A Productivity Checker for Logic Programming

Ekaterina Komendantskaya, Patricia Johann|arXiv (Cornell University)|Aug 15, 2016
Logic, programming, and type systemsComputer Science13 references4 citations
TL;DR

This paper introduces an observational productivity checker for logic programs that semi-decides whether a program produces infinite terms through coinductive reasoning. By combining universal observability and existential liveness checks via rewriting trees and coinductive invariants, it certifies productive behavior even in non-linear, existentially quantified programs, enabling sound coinductive reasoning in Prolog and related systems.

ABSTRACT

Automated analysis of recursive derivations in logic programming is known to be a hard problem. Both termination and non-termination are undecidable problems in Turing-complete languages. However, some declarative languages offer a practical work-around for this problem, by making a clear distinction between whether a program is meant to be understood inductively or coinductively. For programs meant to be understood inductively, termination must be guaranteed, whereas for programs meant to be understood coinductively, productive non-termination (or "productivity") must be ensured. In practice, such classification helps to better understand and implement some non-terminating computations. Logic programming was one of the first declarative languages to make this distinction: in the 1980's, Lloyd and van Emden's "computations at infinity" captured the big-step operational semantics of derivations that produce infinite terms as answers. In modern terms, computations at infinity describe "global productivity" of computations in logic programming. Most programming languages featuring coinduction also provide an observational, or small-step, notion of productivity as a computational counterpart to global productivity. This kind of productivity is ensured by checking that finite initial fragments of infinite computations can always be observed to produce finite portions of their infinite answer terms. In this paper we introduce a notion of observational productivity for logic programming as an algorithmic approximation of global productivity, give an effective procedure for semi-deciding observational productivity, and offer an implemented automated observational productivity checker for logic programs.

Motivation & Objective

  • To address the challenge of reasoning about non-terminating logic program derivations, especially those producing infinite terms.
  • To formalize a notion of observational productivity as a practical alternative to global productivity in logic programming.
  • To develop an algorithm that semi-decides observational productivity without syntactic restrictions, including for programs with existential variables and non-linear recursion.
  • To provide a practical tool for verifying coinductive semantics and ensuring soundness in coinductive Prolog dialects like CoLP and S-resolution.
  • To enable automated certification of productive behavior for use in program verification, type systems, and lazy evaluation of infinite data structures.

Proposed method

  • The method introduces observational productivity as a combination of universal observability (all derivation steps produce observable terms) and existential liveness (infinite terms can be approximated step-by-step).
  • It uses rewriting trees to model term reductions and transitions between derivation steps, tracking how terms evolve under SLD-resolution.
  • A key innovation is the use of coinductive invariants to record patterns that reduce in loops and are reintroduced in transitions, capturing the 'producer/consumer' dynamics of infinite derivations.
  • The algorithm performs a semi-decision procedure by analyzing whether rewriting trees exhibit term reduction toward leaves and structural regeneration via most general unifiers (mgus).
  • It integrates with existing termination checkers for term rewriting systems (TRS) to verify contraction ordering, enabling modular analysis.
  • The checker is implemented in Go and supports parallel proof search, enabling scalable analysis of complex logic programs.

Experimental results

Research questions

  • RQ1Can observational productivity be defined as a decidable or semi-decidable property for general logic programs, independent of specific dialects?
  • RQ2How can global productivity—i.e., the ability to compute infinite terms at infinity—be algorithmically approximated via small-step, observable behavior?
  • RQ3What formal conditions ensure that a logic program’s infinite derivation can be lazily approximated through finite steps, even when the answer is not a regular term?
  • RQ4How can coinductive invariants be automatically discovered and validated to certify productive behavior in programs with existential variables and non-linear recursion?
  • RQ5Can the productivity checker be used as a pre-check to guarantee soundness in coinductive Prolog systems like CoLP or S-resolution?

Key findings

  • The observational productivity checker successfully identifies productive programs such as P5 and P2, which compute infinite terms like p(f(f(...))) at infinity, while correctly rejecting non-productive loops like P3 and P4.
  • The method semi-decides observational productivity for any logic program, including those with existential variables and non-linear recursion, without syntactic restrictions.
  • Coinductive invariants are effective in capturing the structural dynamics of infinite derivations, enabling detection of both term reduction and regeneration across rewriting trees.
  • The checker can be used to type predicates as coinductive, enabling static classification of inductive vs. coinductive semantics in logic programming.
  • The implementation in Go supports parallel proof search and can be integrated into tools like CoLP to pre-validate programs for sound coinductive reasoning.
  • The checker provides a general certificate for lazy approximation of irregular infinite terms (e.g., in program P6), even when closed-term answers are unattainable.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.