• Aucun résultat trouvé

Further Consideration about Syn- Syn-tactic Restrictions

As described in 3.2, the application of unfolding may be prohibited in Kanamori and Horiuchi's framework.

In this subsection, we discuss some methods to avoid prohibition, though we do not necessarily give the pre-cise syntactic restriction. (Due to space limitations, we do not refer to the terminating property, though several sufficient conditions are known to guarantee it.) (1) Universally Quantified Variables Appearing

in Positive Atoms

Positive unfolding can not be applied to definite formulae at positive atoms with universally quantified variables.

Thus, we have the following two problems.

(a) Synchronized descent rules can not be defined when universally quantified variables are instantiated by neg-ative unfolding.

(b) We can not unfold formulae of the form V X A when A is an atom and some variables in X appear in A.

To avoid case (a), the following restriction is sufficient.

When applying negative unfolding, no universally quan-tified variable is instantiated. Though the restriction seems to be strong, most of significant examples of pro-gram synthesis can be dealt with under the restriction.

Case (b) corresponds to the compilation failure in Sato and Tamaki's first order compiler [19]. They restricted their language as follows. For every implicational goal Fl -7 F2 appearing in a formula, uvar(F1);2uvar(F2 ) holds, where uvar(Fi) means the set of universally quan-tified variables appearing in Fi .

The above condition is available for our problem. Note that the application of positive unfolding does not af-fect the condition. When applying negative unfolding at atom A in universally quantified implicational goal G, the following restrictions are also required. All the uni-versally quantified variables appearing in A also appear in some negative defined atom in each result of negative

unfolding G, or they are unified with terms consisting of constants and global variables by reduction w.r.t.

=.

We believe that techniques such as mode analysis are available to guarantee that every applicable negative un-folding satisfies the above conditions.

(2) Global Variables Appearing in Negative Atoms

Negative unfolding should be applied without instantiat-ing global variables. In some cases, this restriction may be critical. However, we can deal with most of those cases by adding positive atoms to the formula such tha~

the globaJ variables can be instantiated by applying pos-itive unfolding at those atoms. Atoms with predicates which specify data types (cf. list) are available. For example, with the definitions of 'member' and '<' in Ex-ample 2.1, negative unfolding can not be applied to the definite formula below.

less-than-all(X,L) +-V Y(member(Y,L) -7 X<Y).

However, we can apply negative unfolding to the formula below, after positive unfolding list(L).

less-than-all(X,L)

+-list(L) 1\ V Y(member(Y,L) -7 X<Y).

(3) Sato's Unfold/Fold Transformation

Recently, Sato proposed unfold/fold transformation rules for full first order programs [18]. Their unfolding op-eration does not require conditions like Kanamori and Horiuchi's. On the other hand, more complex condi-tions are required when applying folding. Thus, when we adopt Sato's rules in place of Kanamori and Hori-uchi's, we need not consider the restrictions discussed in (1) and (2) above, while some other difficulties are introduced to satisfy the folding conditions.

4 Discussion

The work described here is an extension of Pettorossi and Proietti's work on program transformation [14, 15, 16].

They formalized the successful unfold/fold transforma-tion in three ways, and showed that the problem of whether a given program can be transformed successfully or not is unsolvable. They also showed some classes of definite clause programs which can be transformed suc-cessfully. Our results owe much to their work, though currently we do not know whether our problem is decid-able.

Proietti and Pettorossi also showed that any defi-nite clause program can be transformed successfully by performing suitable generalization of the atoms to be folded [15, 16]. However, the generalization technique is not available for our problem. Folding by a definition formula obtained by generalizing atoms with universally quantified variables may not satisfy the conditions for

folding [7], since universally quantified variables can not appear in the head of the formula.

Proietti and Pettorossi also showed a transformation procedure called loop absorption [15, 16]. In this pro-cedure, they found clause C and its descendant clause C' such that C"s body is an instance of C's (or a sub-set of C"s body is identical to C's bqdy). Then, a new definition clause whose body is identical to that of C is constructed. They also showed a procedure to elimi-nate unnecessary variables [17]. We can modify our naive procedure described in 3.1 by incorporating the loop ab-sorption and the elimination of unnecessary variables.

. Programs obtained by the modified procedure are ex-pected to be more efficient and have less code than those obtained by the naive procedure.

There have been several studies on logic program syn-thesis from universally quantified implicational formu-lae [3, 4, 19]. Our work is closely related to that of Dayantis [3]. There, program synthesis was also consid-ered from formulae of the form H ~ VX(A -+ B). They showed that a class of those formulae can be transformed into definite clauses by deductive derivation. They also discussed the generality of the class using several exam-ples. Their deductive method is analogous to unfold/fold transformation and the derivation processes almost cor-respond to those by our procedure when our procedure does not apply positive unfolding. They also mechanized their derivation processes. Our notion of the sound-ness of the application of unfolding is ensured by part of their syntactic restrictions on the arguments of formulae, though we have not discussed how this is ensured. How-ever, the classes we have shown are still wider than those they showed after we incorporate those restrictions.

Sato and Tamaki showed a deterministic algorithm to transform logic programs with universally quantified im-plicational formulae into definite clause programs [19].

In their method, unfold/fold transformation is applied to universal continuation forms. Their method can be applied to a wider class of first order formulas than ours, while the results of the compilation are not necessarily efficient and the code sizes of those results increase gen-erally.

5 Conclusion

A logic program synthesis method from some classes of first order logic specifications have been shown. The method is based on unfold/fold transformation. Some classes of first order formulae which can be transformed into definite clause programs by unfold/fold transforma-tion have been shown.

Acknowledgments

I would like to thank Tadashi Kanamori and anonymous referees for helpful comments. I would also like to thank

471

Koichi Furukawa and Ryuzo Hasegawa for their advice, and Kazuhiro Fuchi for giving me the opportunity to do this research.

References

[1] Burstall, R.M. and J.Darlington, "A Transforma-tion System for Developing Recursive Programs", J.ACM, VoL24, No.1, ppA4-67, 1977.

[2] Clark, K.L. and S. Sickel, "Predicate Logic: A Cal-culus for Deriving Programs", Proc. of 5th Inter-national Joint Conference on Artificial Intelligence, ppA19-420, 1977.

[3] Dayantis, G., "Logic Program Derivation for a Class of First Order Logic Relations" , Proc. of 10th International Joint Conference on Artificial Intel-ligence, pp.9-14, Italy, 1987.

[4] Fribourg, L., "Extracting Logic Programs from Proofs that Use Extended Prolog Execution and Induction", Proc. of 7th International Conference on Logic Programming, pp.685-699, Jerusalem, 1990.

[5] Hansson, A. and Tarnlund, S.A., "A Natural Pro-gramming Calculus", Proc. of 6th International Joint Conference on Artificial Intelligence, pp.348-355, 1979.

[6] Hogger, C.J., "Derivation of Logic Programs", J.ACM, VoL28, pp.372-392, 1981.

[7] Kanamori, T. and K. Horiuchi, "Construction of Logic Programs Based on Generalized Unfold/Fold Rules", Proc. of 4th International Conference on Logic Programming, pp.744-768, Melbourne, 1987.

[8] Kawamura, T., "Derivation of Efficient Logic Pro-grams by Synthesizing New Predicates", Proc.

of 1991 International Logic Programming Sympo-sium, pp.611-625, San Diego, 1991.

[9] Komorowski, J., "Partial Evaluation As A Means for Inferencing Data Structures in An Applicative Language: A Theory And Implementation in The Case of Prolog", Proc. of the ACM Symposium on Principles of Programming Languages, pp.255-267, 1982.

[10] Komorowski, J., "Towards a Programming Methodology Founded on Partial Deduction", Proc. of the European Conference on Artificial In-telligence, ppA04-409,1990.

[11] Lau, K.K. and S. D. Prestwich, "Top-down Syn-thesis of Recursive Logic Procedures from First-order Logic Specifications", Proc. of 7th Interna-tional Conference on Logic Programming, pp.667-684, Jerusalem, 1990.

[12] Lau, K.K. and S. D. Prestwich, "Synthesis of a Family of Recursive Sorting Procedures", Proc.

of 1991 International Logic Programming Sympo-sium, pp.641-658, San Diego, 1991.

[13] Lloyd, J. W., "Foundations of Logic Program-ming", Springer-Verlag, 2nd Edition, Berlin, Hei-delberg, New York, 1987.

[14] Pettorossi, A. and M. Proietti, "Decidability Re-sults and Characterization of Strategies for the Development of Logic Programs", Proc. of 6th International Conference on Logic Programming, pp.539-553, Lisboa, 1989.

[15] Proietti, M. and A. Pettorossi, "Construction of Efficient Logic Programs by Loop Absorption and Generalization", Proc. of the Second Workshop on Meta-programming in Logic, pp.57-81, Leuven, 1990.

[16] Proietti, M. and A. Pettorossi, "Synthesis of Eu-reka Predicates for Developing Logic Programs", Proc. of 3rd European Symposium on Program-ming, Copenhagen, LNCS 432, Springer-Verlag, pp.307-325,1990.

[17] Proietti, M. and A. Pettorossi, "Unfolding - Def-inition - Folding, In This Order, For Avoiding Unnecessary Variables In Logic Programs", Proc.

of 3rd International Symposium on Programming Language Implementation and Logic Program-ming, Passau, LNCS 528, Springer- Verlag, pp.347-358,1991.

[18] Sato, T., "An Equivalence Preserving First Or-der Unfold/fold Transformation System", Alge-braic and Logic Programming, Proceedings, LNCS 463, Springer-Verlag, pp.173-188, 1990.

[19] Sato, T. and H. Tamaki, "First Order Compiler : A Deterministic Logic Program Synthesis Algo-rithm", J .Symbolic Computation, Vol. 8 , pp.605-627, 1989.

[20] Tamaki, H. and T. Sato, "Unfold/Fold Transfor-mation of Logic Programs", Proc. of 2nd Inter-national Logic Programming Conference, pp.127-138, Uppsala, 1984.

PROCEEDINGS OF THE INTERNATIONAL CONFERENCE ON FIFTH GENERATION COMPUTER SYSTEMS 1992,

edited by ICOT. © ICOT, 1992 473