Abstract
For any LP system, tabling can be quite handy in a variety of tasks, especially if it is efficiently implemented and fully integrated in the language. Implementing tabling in Mercury poses special challenges for several reasons. First, Mercury is both semantically and culturally quite different from Prolog. While decreeing that tabled predicates must not include cuts is acceptable in a Prolog system, it is not acceptable in Mercury, since if-then-elses and existential quantification have sound semantics for stratified programs and are used very frequently both by programmers and by the compiler. The Mercury implementation thus has no option but to handle interactions of tabling with Mercury’s language features safely. Second, the Mercury implementation is vastly different from the WAM, and many of the differences (e.g. the absence of a trail) have significant impact on the implementation of tabling. In this paper, we describe how we adapted the copying approach to tabling to implement tabling in Mercury.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Chen, W., Warren, D.S.: Tabled evaluation with delaying for general logic programs. J. ACM 43(1), 20–74 (1996)
Demoen, B., Sagonas, K.: CAT: the Copying Approach to Tabling. J. of Functional and Logic Programming (November 1999)
Guo, H.-F., Gupta, G.: A simple scheme for implementing tabled logic programming systems based on dynamic reordering of alternatives. In: Codognet, P. (ed.) ICLP 2001. LNCS, vol. 2237, pp. 181–196. Springer, Heidelberg (2001)
Ramakrishnan, I.V., Rao, P., Sagonas, K., Swift, T., Warren, D.S.: Efficient access mechanisms for tabled logic programs. J. of Logic Programming 38(1), 31–54 (1999)
Rocha, R., Silva, F., Santos Costa, V.: On applying or-parallelism and tabling to logic programs. Theory and Practice of Logic Programming 5(1&2), 161–205 (2005)
Sagonas, K., Swift, T.: An abstract machine for tabled execution of fixed-order stratified logic programs. ACM Trans. on Prog. Lang. Syst. 20(3), 586–634 (1998)
Somogyi, Z., Henderson, F., Conway, T.: The execution algorithm of Mercury, an efficient purely declarative logic programming language. J. of Logic Progr. 26(1–3), 17–64 (1996)
Somogyi, Z., Sagonas, K.: Minimal model tabling in Mercury (2005). Available at, http://www.cs.mu.oz.au/research/mercury/information/papers.html
Tamaki, H., Sato, T.: OLD resolution with Tabulation. In: Shapiro, E. (ed.) ICLP 1986. LNCS, vol. 225, pp. 84–98. Springer, Heidelberg (1986)
Warren, D.H.D.: An abstract Prolog instruction set. Tech. Rep. 309, SRI International (1983)
Zhou, N.-F., Shen, Y.-D., Yuan, L.-Y., You, J.-H.: Implementation of a linear tabling mechanism. J. of Functional and Logic Programming 2001(10) (2001)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Somogyi, Z., Sagonas, K. (2005). Tabling in Mercury: Design and Implementation. In: Van Hentenryck, P. (eds) Practical Aspects of Declarative Languages. PADL 2006. Lecture Notes in Computer Science, vol 3819. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11603023_11
Download citation
DOI: https://doi.org/10.1007/11603023_11
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-30947-5
Online ISBN: 978-3-540-31685-5
eBook Packages: Computer ScienceComputer Science (R0)