• Aucun résultat trouvé

A Framework for Incorporating Abstraction Mechanisms into the Logic Programming Paradigm

N/A
N/A
Protected

Academic year: 2022

Partager "A Framework for Incorporating Abstraction Mechanisms into the Logic Programming Paradigm"

Copied!
173
0
0

Texte intégral

(1)

A Framework for Incorporating Abstraction Mechanisms

into the

Logic Programming Paradigm

by

Joseph Lawrence Zachary

c

Massachusetts Institute of Technology, 1987

This research was supported in part by the National Science Foundation under grant DCR-8411639, and in part by the Advanced Research Projects Agency of the Department of Defense, monitored by the Oce of Naval Research under contract N00014-83-K-0125.

Massachusetts Institute of Technology Laboratory for Computer Science

Cambridge, Massachusetts

(2)
(3)

A Framework for Incorporating Abstraction Mechanisms

into the

Logic Programming Paradigm

by

Joseph Lawrence Zachary

Abstract

To help make logic programming more suitable for writing large systems, we develop linguistic mechanismsthat permit the organization of logic programs around abstractions.

In particular, we present the design of Denali, an equational logic programming language that supports predicate and data abstraction.

The key issue in introducing predicate abstraction is dealing with the dierence be- tween the declarative and procedural interpretations of logic programs. We address this issue by introducing a two-dimensional type system to describe predicate interfaces. The two components are a sort system and a novel multi-valued mode system. Multi-valued modes constrain the ways in which arguments to predicates may be instantiated. A collection of such modes is dened by the programmer for each sort.

The key issue in introducing data abstraction is providing ways to obtain equational unication procedures. We develop a pragmatic approach that relies upon the pro- grammer to implement these procedures. We facilitate this by supporting a variety of techniques that simplify the problem. Among these techniques are treating unication on a sort-by-sort basis, layering implementations so as to exploit built-in unication procedures, and using the mode system to constrain the unication problem.

Finally, we establish the basis for implementing Denali by developing procedures for performing moded equational resolution and for combining moded equational unication procedures.

Keywords: Logic Programming, Equational Logic Programming, Programming Metho- dology, Multi-valued Mode, Predicate Abstraction, Data Abstraction, Equational Theory, Moded Equational Resolution, Moded Equational Unication.

This thesis was supervised by John V. Guttag and was submitted to the Department of Electrical Engineering and Computer Science on July 20, 1987, in partial fulllment of the requirements for the degree of Doctor of Philosophy in Computer Science.

3

(4)
(5)

To Judy, Baxter, and Big Wooe.

5

(6)
(7)

Contents

Acknowledgments 11

1 Introduction 13

1.1 Prolog : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 16 1.1.1 Background : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 16 1.1.2 Predicate abstraction : : : : : : : : : : : : : : : : : : : : : : : : : 19 1.1.3 Data abstraction : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 1.2 Denali : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 23 1.2.1 Predicate abstraction : : : : : : : : : : : : : : : : : : : : : : : : : 23 1.2.2 Data abstraction : : : : : : : : : : : : : : : : : : : : : : : : : : : 24 1.3 Related work : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 27 1.4 Contributions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 28 1.5 Roadmap : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 30

2 Predicate abstraction in Denali 33

2.1 Predicate interfaces using bi-valued modes : : : : : : : : : : : : : : : : : 34 2.1.1 Sorts : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 35 2.1.2 Bi-valued mode systems : : : : : : : : : : : : : : : : : : : : : : : 36 2.2 Moded evaluation : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 38 2.2.1 Moded selection : : : : : : : : : : : : : : : : : : : : : : : : : : : : 38 2.2.2 Mode guards : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 41 2.3 Predicate interfaces using multi-valued modes : : : : : : : : : : : : : : : 42 2.3.1 Multi-valued mode systems : : : : : : : : : : : : : : : : : : : : : 43 2.3.2 Moded bases : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 44 2.4 Summary of mode denitions : : : : : : : : : : : : : : : : : : : : : : : : 46 2.5 Dening multi-valued modes : : : : : : : : : : : : : : : : : : : : : : : : : 47 2.6 Related work : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 49

3 Equational unication in Denali 51

3.1 Equational unication : : : : : : : : : : : : : : : : : : : : : : : : : : : : 53 3.1.1 Denition : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 53 3.1.2 Problems : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 55 3.2 Simplifying unication : : : : : : : : : : : : : : : : : : : : : : : : : : : : 56 3.2.1 Sort stratication : : : : : : : : : : : : : : : : : : : : : : : : : : : 57 3.2.2 Simplifying abstractions : : : : : : : : : : : : : : : : : : : : : : : 58 3.2.3 Moded unication: : : : : : : : : : : : : : : : : : : : : : : : : : : 58

7

(8)

8 Contents 3.3 Moded equational resolution : : : : : : : : : : : : : : : : : : : : : : : : : 60 3.3.1 Multiple uniers : : : : : : : : : : : : : : : : : : : : : : : : : : : 60 3.3.2 Mode restriction anomaly : : : : : : : : : : : : : : : : : : : : : : 62 3.4 Related work : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 64

4 Data abstraction in Denali 67

4.1 Requirements : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 68 4.1.1 Data abstraction in conventional languages : : : : : : : : : : : : : 69 4.1.2 Data abstraction in Prolog : : : : : : : : : : : : : : : : : : : : : : 70 4.1.3 Denali interfaces : : : : : : : : : : : : : : : : : : : : : : : : : : : 71 4.2 Implicit implementation : : : : : : : : : : : : : : : : : : : : : : : : : : : 74 4.3 Explicit implementation : : : : : : : : : : : : : : : : : : : : : : : : : : : 76 4.3.1 Denotations : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 78 4.3.2 Abstract modes : : : : : : : : : : : : : : : : : : : : : : : : : : : : 80 4.3.3 Exported predicates : : : : : : : : : : : : : : : : : : : : : : : : : 81 4.3.4 Unication predicates: : : : : : : : : : : : : : : : : : : : : : : : : 82 4.4 Comparison of implementation methods : : : : : : : : : : : : : : : : : : 83 4.5 Summary of abstraction in Denali : : : : : : : : : : : : : : : : : : : : : : 84

5 Moded equational resolution 87

5.1 Background : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 88 5.1.1 Denite clause programs with equality : : : : : : : : : : : : : : : 88 5.1.2 Equational completeness : : : : : : : : : : : : : : : : : : : : : : : 90 5.2 ESL resolution : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 91 5.2.1 Overlap reduction: : : : : : : : : : : : : : : : : : : : : : : : : : : 93 5.2.2 Selection reduction : : : : : : : : : : : : : : : : : : : : : : : : : : 95 5.2.3 ESL trees : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 98 5.2.4 N-ESL resolution : : : : : : : : : : : : : : : : : : : : : : : : : : : 101 5.3 Moded resolution : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 103 5.3.1 Equational modes and moded bases : : : : : : : : : : : : : : : : : 104 5.3.2 Using moded bases : : : : : : : : : : : : : : : : : : : : : : : : : : 105 5.3.3 Moded selection rules : : : : : : : : : : : : : : : : : : : : : : : : : 107 5.4 Moded resolution procedures : : : : : : : : : : : : : : : : : : : : : : : : : 109 5.4.1 Nondeterministic moded selection : : : : : : : : : : : : : : : : : : 110 5.4.2 Solvable selection : : : : : : : : : : : : : : : : : : : : : : : : : : : 112 5.4.3 Well-moded selection : : : : : : : : : : : : : : : : : : : : : : : : : 116 5.5 Summary : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 119

6 Moded equational unication 121

6.1 Approaches to equational unication : : : : : : : : : : : : : : : : : : : : 122 6.1.1 Direct implementation : : : : : : : : : : : : : : : : : : : : : : : : 122 6.1.2 Narrowing : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 123 6.1.3 Combining algorithms : : : : : : : : : : : : : : : : : : : : : : : : 124 6.2 Combining moded unication procedures : : : : : : : : : : : : : : : : : : 127 6.2.1 Sorted algorithms : : : : : : : : : : : : : : : : : : : : : : : : : : : 128

(9)

Contents 9 6.2.2 Non-terminating procedures : : : : : : : : : : : : : : : : : : : : : 130 6.2.3 Independent procedures : : : : : : : : : : : : : : : : : : : : : : : 131 6.2.4 Moded procedures : : : : : : : : : : : : : : : : : : : : : : : : : : 131 6.2.5 An extended combining procedure: : : : : : : : : : : : : : : : : : 132

7 Semantics of Denali 135

7.1 Denotation form: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 136 7.1.1 Interfaces : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 139 7.1.2 Implementations : : : : : : : : : : : : : : : : : : : : : : : : : : : 141 7.1.3 Denotation sorts : : : : : : : : : : : : : : : : : : : : : : : : : : : 144 7.1.4 Sort checking : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 145 7.2 Representation form : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 146 7.2.1 Symbols : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 146 7.2.2 Clause conversion : : : : : : : : : : : : : : : : : : : : : : : : : : : 148 7.2.3 Unication conversion : : : : : : : : : : : : : : : : : : : : : : : : 150 7.2.4 Mode conversion : : : : : : : : : : : : : : : : : : : : : : : : : : : 151 7.3 Translating denotations to representations : : : : : : : : : : : : : : : : : 152 7.3.1 Translating ground terms : : : : : : : : : : : : : : : : : : : : : : 154 7.3.2 Translating general terms : : : : : : : : : : : : : : : : : : : : : : 155 7.3.3 Translation paradigm : : : : : : : : : : : : : : : : : : : : : : : : : 156 7.4 Abstract meaning : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 156 7.5 Operational Meaning : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 157 7.5.1 Interpreter: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 158 7.5.2 Unication: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 160

8 Conclusions 163

8.1 Contributions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 163 8.2 Further work : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 165

References 167

Biography 173

Références

Documents relatifs

Moreover, as in the order-sorted case, the multi-language term algebra T SG over a regular multi-language signature SG is initial in M LA lg SG [6].. Therefore, given a multi-

The focus of the paper is the analysis of the programming style to be used for model- ing the maximum bisimulation problem in a way as declarative way as possible in some dialects

The “laws” are then given by imposing several structural properties: (i) in a given term tree, arities imposed by Σ must be reflected by the branching in the underlying tree

Going in the other direction, while OBCAs are ideal to model this restricted class of logic programs, the classical notion of cellular automata (for instance, Conway’s Game of

These results are intuitive because the OLP program of Figure 4 is based on the idea that the search space can be significantly reduced using domain knowledge (i.e, dependencies

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des

For any relaxation of TALM to be sound relative to encoding into a logic program, the unique values axioms would have to become an explicit part of the the definitional theory..

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des