Skip to main content
QUICK REVIEW

[Paper Review] Programming in Alma-0, or Imperative and Declarative Programming Reconciled

Krzysztof R. Apt, Andrea Schaerf|ArXiv.org|Apr 5, 2000
Scheduling and Timetabling Solutions8 references3 citations
TL;DR

This paper presents Alma-0, a hybrid imperative-declarative programming language that integrates 'don't know' nondeterminism with assignment, enabling natural coding of logic programming-style problems like the Eight Queens and Knapsack problems. The key contribution is demonstrating that Alma-0 supports a unified programming style where imperative constructs and declarative logic programming techniques coexist effectively, resulting in more readable and concise programs than pure imperative or logic programming approaches.

ABSTRACT

In (Apt et al, TOPLAS 1998) we introduced the imperative programming language Alma-0 that supports declarative programming. In this paper we illustrate the hybrid programming style of Alma-0 by means of various examples that complement those presented in (Apt et al, TOPLAS 1998). The presented Alma-0 programs illustrate the versatility of the language and show that ``don't know'' nondeterminism can be naturally combined with assignment.

Motivation & Objective

  • To demonstrate that imperative and declarative programming paradigms can be effectively reconciled in a single language.
  • To show that 'don't know' nondeterminism combined with assignment enables more natural solutions to classical problems than pure logic programming.
  • To illustrate the versatility of Alma-0 through practical examples, including graph traversal, negation as failure, executable specifications, and scheduling.
  • To explore new programming techniques enabled by the hybrid style of Alma-0, particularly in constraint satisfaction and search problems.

Proposed method

  • Extends a subset of Modula-2 with nine logic-programming-inspired features, including boolean expressions as statements and failure semantics.
  • Introduces ORELSE and SOME for creating choice points supporting 'don't know' nondeterminism, enabling backtracking over alternative computations.
  • Uses COMMIT and FORALL to manage choice points—COMMIT discards them, FORALL iterates over all successful branches.
  • Employs a mixed parameter passing mechanism (MIX) that supports both values and uninitialized variables as actual parameters.
  • Leverages the KNOWN relation to test variable initialization, enabling conditional logic based on whether a variable has been assigned.
  • Employs a hybrid execution model where programs without assignment can be read as logic formulas, enabling declarative interpretation.

Experimental results

Research questions

  • RQ1Can imperative programming constructs be extended to naturally support logic programming techniques such as nondeterminism and unification?
  • RQ2How can 'don't know' nondeterminism be effectively combined with assignment in a practical programming language?
  • RQ3To what extent can classical logic programming problems be solved more naturally in an imperative language with declarative features?
  • RQ4What new programming techniques emerge from the hybrid imperative-declarative style supported by Alma-0?
  • RQ5How can constraint relaxation and solution enumeration be implemented efficiently in such a language?

Key findings

  • The solution to the Eight Queens problem in Alma-0 is more natural than in pure logic programming due to the integration of assignment and backtracking.
  • The Knapsack problem is naturally expressed in Alma-0 using both nondeterminism and assignment, demonstrating the language's expressive power.
  • The use of FORALL and COMMIT allows systematic exploration and management of multiple solutions, as shown in the timetabling example.
  • The KNOWN test enables conditional logic based on variable initialization, crucial for detecting relaxed constraints in solution enumeration.
  • Executable specifications can be written directly in Alma-0, as demonstrated by the timetabling problem, where the program itself acts as a specification.
  • The hybrid style results in programs that are shorter and more readable than equivalent implementations in pure imperative or logic programming paradigms.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.