Skip to main content

Tabling in Mercury: Design and Implementation

  • Conference paper
Book cover Practical Aspects of Declarative Languages (PADL 2006)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 3819))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Chen, W., Warren, D.S.: Tabled evaluation with delaying for general logic programs. J. ACM 43(1), 20–74 (1996)

    MATH  MathSciNet  Google Scholar 

  2. Demoen, B., Sagonas, K.: CAT: the Copying Approach to Tabling. J. of Functional and Logic Programming (November 1999)

    Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. 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)

    Article  MATH  Google Scholar 

  5. 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)

    Article  MATH  MathSciNet  Google Scholar 

  6. 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)

    Article  Google Scholar 

  7. 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)

    Article  Google Scholar 

  8. Somogyi, Z., Sagonas, K.: Minimal model tabling in Mercury (2005). Available at, http://www.cs.mu.oz.au/research/mercury/information/papers.html

  9. Tamaki, H., Sato, T.: OLD resolution with Tabulation. In: Shapiro, E. (ed.) ICLP 1986. LNCS, vol. 225, pp. 84–98. Springer, Heidelberg (1986)

    Google Scholar 

  10. Warren, D.H.D.: An abstract Prolog instruction set. Tech. Rep. 309, SRI International (1983)

    Google Scholar 

  11. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics