Krzysztof R. Apt,Marc Bezem
Abstract:We provide here a computational interpretation of first-order logic based on a constructive interpretation of satisfiability w.r.t. a fixed but arbitrary interpretation. In this approach the formulas themselves are programs. This contrasts with the so-called formulas as types approach in which the proofs of the formulas are typed terms that can be taken as programs. This view of computing is inspired by logic programming and constraint logic programming but differs from them in a number of crucial aspects.
Formulas as programs is argued to yield a realistic approach to programming that has been realized in the implemented programming language ALMA-0 (Apt et al.) that combines the advantages of imperative and logic programming. The work here reported can also be used to reason about the correctness of non-recursive ALMA-0 programs that do not include destructive assignment.
What problem does this paper attempt to address?
The problem that this paper attempts to solve is: **How to provide a computational interpretation based on first - order logic formulas so that these formulas themselves can be executed as programs**. Specifically, the author proposes a method of directly interpreting logic formulas as programs, rather than interpreting the proofs of formulas as programs as in the traditional "formulas - as - types" approach.
### Problem Background
Traditionally, logic programming (such as Prolog) and constraint logic programming have limitations when dealing with certain complex problems, especially in dealing with recursion, negation, and termination. In addition, formulas in logic programming are usually interpreted as Horn clauses, which limits their expressive power. To overcome these limitations, the author proposes a new "formulas - as - programs" approach.
### Main Contributions
1. **Non - recursive declarative programming framework**:
- A generalized framework based on first - order logic is proposed, which does not rely on recursion but realizes iteration through bounded quantification.
- This method combines the advantages of imperative programming and logic programming and is suitable for verifying the correctness of non - recursive programs.
2. **Design of computational mechanism**:
- A constructive satisfiability testing mechanism is designed, which can evaluate the truth value of first - order formulas under a given interpretation.
- This mechanism can systematically search for variable assignments that make the formula hold and report failure when it cannot be found.
3. **Extensions and applications**:
- Several extensions to the first - order logic language are proposed, including types (sorts), arrays, and bounded quantifiers, to enhance its expressive power.
- This method is applied to the programming language Alma - 0, demonstrating its feasibility in actual programming.
### Formula Example
Consider the formula:
\[
(x = 2 \lor x = 3) \land (y = x + 1 \lor 2 = y) \land (2 \times x = 3 \times y)
\]
The interpretation is as follows:
- First, try \(x = 2\) and \(y = x + 1\), that is, \(y = 3\), but \(2\times2\neq3\times3\), so it fails.
- Then try \(x = 2\) and \(y = 2\), also \(2\times2\neq3\times2\), and it fails again.
- Finally, try \(x = 3\) and \(y = 2\), at this time \(2\times3 = 3\times2\) holds, so it is successful.
### Conclusion
This paper provides a realist computational framework based on first - order logic, which can be combined with imperative programming and has advantages in dealing with the correctness verification of non - recursive programs.