AND Parallelism in Logic Programs

John S. Conery, Dennis F. Kibler

Abstract

This paper introduces a novel model for the parallel execution of logic programs, specifically focusing on AND parallelism—the simultaneous solution of multiple goals within a single clause. By combining this with existing OR parallelism, the authors propose a framework capable of accelerating both deterministic "divide and conquer" algorithms and complex nondeterministic search problems. The system automatically manages variable dependencies through a dataflow-driven approach, requiring no manual annotations from the programmer.

Introduction

In the early 1980s, logic programming languages like Prolog were primarily sequential, relying on a depth-first search strategy. While researchers had successfully explored OR parallelism to search different branches of a choice point simultaneously, this approach offered little benefit for deterministic functions, such as mathematical calculations. The challenge of AND parallelism—running multiple goals in a clause body at once—lies in variable dependency. If two goals share a variable, they cannot always run independently; one must often wait for the other to produce a value. This paper addresses this by automating dependency management through an interpreter that exploits parallelism wherever dataflow allows.

The AND/OR Process Model

The proposed model treats a logic program as a hierarchy of independent processes that communicate via messages (e.g., success, fail, redo, reset). The system is governed by three core components:

  1. Ordering Algorithm: This component analyzes the goals in a clause to identify shared variables. It designates one goal as a generator for a variable and others as consumers. It then constructs a dataflow graph where arcs represent the flow from generators to consumers.
  2. Forward Execution: Goals are scheduled for execution only after all their "parent" generators in the dataflow graph have successfully produced values.
  3. Backward Execution: When a goal fails, the system performs intelligent backtracking. Instead of simply returning to the previous literal in the text, it uses the dataflow graph to send a redo message specifically to the generator that provided the problematic variable binding.

Benchmark Analysis

The model was evaluated using two primary benchmarks that represent different classes of logic programming problems.

Fast Factorial

The "Fast Factorial" benchmark demonstrates a deterministic "divide and conquer" implementation. The dataflow graph for this function reveals how the problem is split into independent sub-problems that can be solved in parallel.

Figure 1: Dataflow graph for the Fast Factorial function ff(L, H, F), illustrating how sub-goals can be executed in parallel once midpoints are calculated.

In this example, the system identifies that ff(L, M1, F1) and ff(M2, H, F2) can run concurrently because they do not share any uninstantiated variables once the midpoints M1 and M2 are determined.

Map Coloring

The Map Coloring problem serves as a classic nondeterministic constraint satisfaction benchmark. It illustrates how the system handles complex dependencies and backtracking across multiple goals.

Figure 4: Logic program and map for the Map Coloring benchmark, showing the constraints (next) between adjacent regions.

The AND process for map coloring behaves as efficiently as specialized "intelligent backtracking" interpreters. By following the dataflow dependencies, it can skip irrelevant branches of the search tree during a failure, significantly reducing the search space compared to standard sequential Prolog.

Key Results and Discussion

The authors demonstrate that for deterministic functions like Fast Factorial, time complexity on a multiprocessor can be reduced from $O(T)$ to $O(\log_2 T)$, where $T$ is the number of steps in a sequential interpreter. Furthermore, the model successfully abstracts physical hardware, assuming a system of Processing Elements (PEs) with local memory.

However, several challenges remain for future work. The coordination of nondeterministic generators is computationally expensive, as managing the combinations of values across parallel processes is complex. Additionally, the paper notes that real-world performance will depend heavily on managing communication costs and the "granularity" problem—ensuring the overhead of process management does not outweigh the gains from parallel execution.

Summary updated

BibTeX
@inproceedings{conery1983parallelism,
  author = {John S. Conery and Dennis F. Kibler},
  title = {{AND Parallelism in Logic Programs}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1983},
}
Figure