**8. Conclusions and future work**

We have presented a logical and semantic framework for the declarative diagnosis of wrong and missing computed answers in *CFLP*(D), a generic scheme for Constraint Functional-Logic Programming over a given constraint domain D which combines the expressivity of lazy *FP* and *CLP* languages. The diagnosis technique of wrong answers represents the computation which has produced a wrong computed answer by means of an abridged proof tree whose inspection leads to the discovery of some erroneous program rule responsible for the wrong answer. The logical correctness of the method can be formally proved thanks to the connection between abbreviated proof trees and program semantics. The method for missing answers relies on computation trees whose nodes are labeled with *answer collection assertions* (*aca*s). As in declarative diagnosis for *FP* languages, the values displayed at *aca*s are shown in the most evaluated form demanded by the topmost computation. Following the *CLP* tradition, we have shown that our computation trees for missing answers are abbreviated proof trees in a suitable inference system, the so-called *Constraint Negative Proof Calculus*. Thanks to this fact, we can prove the correctness of our diagnosis method for any admissible goal solving system whose recollection of computed answers can be represented by means of a proof tree in the constraint negative proof calculus. As far as we know, no comparable result was previously available for such an expressive framework as *CFLP*.

Deransart, P., Hermenegildo, M. & Małuszy ´nski, J. (2000). *Analysis and Visualization tools for*

<sup>147</sup> A Semantic Framework for the Declarative Debugging

Drabent, W., Nadjm-Tehrani, S. & Małuszy ´nski, J. (1989). Algorithmic Debugging with

Estévez, S, Hortalá, T., Rodríguez, M. & del Vado, R. (2009). On the cooperation of the

Fernández, A.J., Hortalá-González, M.T., Sáenz-Pérez, F. & del Vado-Vírseda, R. (2007).

Ferrand, G. (1987). Error Diagnosis in Logic Programming, an Adaptation of E.Y. Shapiro's

Ferrand, G., Lesaint, W. & Tessier, A. (2002). Theoretical foundations of value withdrawal

Ferrand, G., Lesaint, W. & Tessier, A. (2003). Towards declarative diagnosis of constraint

Hermenegildo, M., Puebla, G., Bueno, F. & López-García, P. (2002). Abstract Verification and Debugging of Constraint Logic Programs. *Proc. CSCLP'02*, pp. 1–14, 2002. Lloyd, J.W. (1987). Declarative Error Diagnosis. *New Generation Computing 5(2)*, 133–154, 1987. López-Fraguas, F.J.; Rodríguez-Artalejo, M. & del Vado-Vírseda, R. (2006). A New Generic

*and Symbolic Computation*, volume 20, numbers 1-2, pages 73-122, June 2007. López-Fraguas, F.J., Rodríguez-Artalejo, M. & del Vado-Vírseda, R. (2005). Constraint Functional Logic Programming Revisited. *WRLA'04*, ENTCS 117, pp. 5–50, 2005. López-Fraguas, F.J. & Sánchez-Hernández, J. (1999). T OY: A Multiparadigm Declarative

López-Fraguas, F.J., Rodríguez-Artalejo, M. & del Vado-Vírseda, R. (2004). A lazy narrowing

Naish, L. (1997). A Declarative Debugging Scheme. *Journal of Functional and Logic Programming*

Naish, L. & Barbour, T. (1995). A declarative debugger for a logical-functional language. *DSTO*

Nilsson, H. (2001). How to look busy while being as lazy as ever: the Implementation of a lazy functional debugger. *Journal of Functional Programming*, 11(6):629–671, 2001. Nilsson, H. & Fritzson, P. (1994). Algorithmic Debugging of Lazy Funcional Languages.

Nilsson, H. & Sparud, J. (1997). The Evaluation Dependence Tree as a basis for Lazy Functional

Scheme for Functional Logic Programming with Constraints. *Journal of Higher-Order*

System. In *Proc. RTA'99*, Springer LNCS 1631, pp 244–247, 1999. System and

calculus for declarative constraint programming. *6th International Conference on*

programs over finite domains. *ArXiv Computer Science e-prints*, 2003. Hanus, M. (2003). *Curry: an Integrated Functional Logic Language*, Version 0.8, April 15, 2003.

http://www-ps.informatik.uni-kiel.de/currywiki/.

documentation available at http://toy.sourceforge.net.

*Programming*, pp. 501-522. The MIT Press, 1989.

of Wrong and Missing Answers in Declarative Constraint Programming

Method. *Journal of Logic Programming* 4(3), 177-198, 1987.

explanations for domain reduction. *ENTCS 76*, 2002.

*Programming*, vol. 9, pp. 415–527, 2009.

*Logic Programming*, 7(5):537–582, 2007.

*PPDP'04*, ACM Press, pp. 43–54, 2004.

*General Document*, 5(2):91–99, 1995.

*Journal of Functional Programming*, 4(3):337–370, 1994.

Debugging. *Automated Software Engineering*, 4(2):121–150, 1997.

2000.

Available at:

*(3)*, 1997.

*Constraint Programming: Constraint Debugging*. Springer LNCS 1870, pp. 151–174,

Assertions. In *Harvey Abramson and M.H. Rogers, editors, Meta-programming in Logic*

constraint domains H, R, and FD in *CFLP*. *Journal of Theory and Practice of Logic*

Constraint functional logic programming over finite domains. *Theory and Practice of*

Intuitively, the notion of *aca* bears some loose relationship to programming techniques related to answer recollection, as e.g., *encapsulated search* (Brassel et al., 2004). However, *aca*s in our setting are not a programming technique. Rather, they serve as logical statements whose falsity reveals incompleteness of computed answers with respect to expected answers. In principle, one could also think of a kind of logical statements somewhat similar to *aca*s, but asserting the *equality* of the observed and expected sets of computed answers for one and the same goal with a finite search space. We have not developed this idea, which could support the declarative diagnosis of a third kind of unexpected results, namely *incorrect answer sets* as done for *Datalog*. In fact, we think that a separate diagnosis of wrong and missing answers is pragmatically more convenient for users of *CFLP* languages.

On the practical side, our method can be applied to actual *CFLP* systems such as *Curry* or T OY, leading to correct diagnosis under the pragmatic assumption that they behave as admissible goal solving systems. This assumption is plausible in so far as the systems are based on formal goal solving procedures that can be argued to be admissible. A debugging tool called DDT , which implements the proposed technique for wrong answers over the domain R of arithmetic constraints over the real numbers has been implemented as a non-trivial extension of previously existing debugging tools. DDT provides several practical facilities for reducing the number and the complexity of the questions that are presented to the user during a debugging session. Moreover, a prototype debugger for missing answers under development is available, which implements the method in T OY.

As future work, we plan several improvements of DDT , such as enabling the diagnosis supporting *finite domain constraints* (Estévez et al., 2009; Fernández et al., 2007), and providing new facilities for simplifying the presentation of queries to the user. In this sense, some important pragmatic problems well known for declarative diagnosis tools in *FP* and *CLP* languages also arise in our context: both the *CT*s and the *aca*s at their nodes may be very big in general, causing computation overhead and difficulties for the user in answering the questions posed by the debugging tool. In spite of these difficulties, the prototype works reasonably well in cases where the goal's search space is relatively small, and we believe that working with such goals can be useful for detecting many programming bugs in practice.

#### **9. References**


26 Will-be-set-by-IN-TECH

Intuitively, the notion of *aca* bears some loose relationship to programming techniques related to answer recollection, as e.g., *encapsulated search* (Brassel et al., 2004). However, *aca*s in our setting are not a programming technique. Rather, they serve as logical statements whose falsity reveals incompleteness of computed answers with respect to expected answers. In principle, one could also think of a kind of logical statements somewhat similar to *aca*s, but asserting the *equality* of the observed and expected sets of computed answers for one and the same goal with a finite search space. We have not developed this idea, which could support the declarative diagnosis of a third kind of unexpected results, namely *incorrect answer sets* as done for *Datalog*. In fact, we think that a separate diagnosis of wrong and missing answers is

On the practical side, our method can be applied to actual *CFLP* systems such as *Curry* or T OY, leading to correct diagnosis under the pragmatic assumption that they behave as admissible goal solving systems. This assumption is plausible in so far as the systems are based on formal goal solving procedures that can be argued to be admissible. A debugging tool called DDT , which implements the proposed technique for wrong answers over the domain R of arithmetic constraints over the real numbers has been implemented as a non-trivial extension of previously existing debugging tools. DDT provides several practical facilities for reducing the number and the complexity of the questions that are presented to the user during a debugging session. Moreover, a prototype debugger for missing answers

As future work, we plan several improvements of DDT , such as enabling the diagnosis supporting *finite domain constraints* (Estévez et al., 2009; Fernández et al., 2007), and providing new facilities for simplifying the presentation of queries to the user. In this sense, some important pragmatic problems well known for declarative diagnosis tools in *FP* and *CLP* languages also arise in our context: both the *CT*s and the *aca*s at their nodes may be very big in general, causing computation overhead and difficulties for the user in answering the questions posed by the debugging tool. In spite of these difficulties, the prototype works reasonably well in cases where the goal's search space is relatively small, and we believe that working with such goals can be useful for detecting many programming bugs in practice.

Alpuente, M., Ballis, D., Correa, F.J. & Falaschi, M. (2003). Correction of Functional Logic

Boye, J., Drabent, W. & Małuszy ´nski, J. (1997). Declarative Diagnosis of Constraint Programs: an Assertion-based Approach. *DiSCiPl Delieverable D.WP2.2.M1.1-2*, 1997. Brassel, B., Hanus, M. & Huch, F. (2004). Encapsulating non-determinism in functional logic

Caballero, R. (2005). A Declarative Debugger of Incorrect Answers for Constraint

Caballero, R. & Rodríguez-Artalejo, M. (2004). DDT : A Declarative Debugging Tool for Functional Logic Languages. *Proc. FLOPS'04*, Springer LNCS 2998, pp. 70–84, 2004.

Comini, M., Levi, G., Meo, M.C. & Vitiello, G. (1999). Abstract diagnosis. *Journal of Logic*

computations. *Journal of Functional and Logic Programming*, 2004.

Functional-Logic Programs. *Proc. WCFLP'05*, ACM, pp. 8–13, 2005.

pragmatically more convenient for users of *CFLP* languages.

under development is available, which implements the method in T OY.

Programs, *Proc. ESOP'03*, Springer LNCS, 2003.

*Programming* 39 (1–3): 43–93, 1999.

**9. References**


http://www-ps.informatik.uni-kiel.de/currywiki/.


**Section 4** 

**Semantic Web and Interfaces** 

