Hostname: page-component-78c5997874-fbnjt Total loading time: 0 Render date: 2024-11-08T09:17:59.308Z Has data issue: false hasContentIssue false

Representation sharing for Prolog

Published online by Cambridge University Press:  09 August 2011

PHUONG-LAN NGUYEN
Affiliation:
Institut de Mathématiques Appliquées, UCO, Angers, France (e-mail: [email protected])
BART DEMOEN
Affiliation:
Department of Computer Science, K.U. Leuven, Belgium (e-mail: [email protected])

Abstract

Representation sharing can reduce the memory footprint of a program by sharing one representation between duplicate terms. The most common implementation of representation sharing in functional programming systems is known as hash-consing. In the context of Prolog, representation sharing has been given little attention. Some current techniques that deal with representation sharing are reviewed. The new contributions are (1) an easy implementation of input sharing for findall/3; and (2) a description of a sharer module that introduces representation sharing at runtime. Their realization is shown in the context of the Warren Abstract Machine (WAM) as implemented by hProlog. Both can be adapted to any WAM-like Prolog implementation. The sharer works independently of the garbage collector, but it can be made to cooperate with the garbage collector. Benchmark results show that the sharer has a cost comparable to the heap garbage collector, that its effectiveness is highly application-dependent, and that its policy must be tuned to the collector.

Type
Regular Papers
Copyright
Copyright © Cambridge University Press 2011

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Aït-Kaci, H. 1991. Warren's Abstract Machine: A Tutorial Reconstruction. MIT Press, Cambridge, MA.Google Scholar
Appel, A. W. and Gonçcalves, M. J. R. 1993 (Feb). Hash-consing Garbage Collection. Technical Report CS-TR-412-93, Com- puterr Science Department, Princeton University.Google Scholar
Appleby, K., Carlsson, M., Haridi, S. and Sahlin, D. 1988. Garbage collection for Prolog based on WAM. Communications of the ACM 31, 6 (June), 719741.Google Scholar
Baker, H. G. 1992. The Boyer Benchmark at warp Speed. SIGPLAN Lisp Pointers V, 3 (Jul–Sep), 1314.CrossRefGoogle Scholar
Bevemyr, J. and Lindgren, T. 1994. A simple and efficient copying garbage collector for Prolog. In Proceedings of the Sixth International Symposium on Programming Language Implementation and Logic Programming, Hermenegildo, M. and Penjam, J., Eds. Lecture Notes in Computer Science, no. 844. Springer-Verlag, New York, 88101.Google Scholar
Blockeel, H., Dehaspe, L., Demoen, B., Janssens, G., Ramon, J. and Vandecasteele, H. 2000. Executing query packs in ILP. In Proceedings of Inductive Logic Programming, 10th International Conference, ILP2000, London, UK, July, Cussens, J. and Frisch, A., Eds. Lecture Notes in Artificial Intelligence, vol. 1866. Springer, New York, 6077.Google Scholar
Boehm, H.-J. and Weiser, M. 1988. Garbage collection in an uncooperative environment. Software: Practice and Experience 18, 807820.Google Scholar
Carlsson, M. 1990. Design and Implementation of an Or-Parallel Prolog Engine. Ph.D. thesis, The Royal Institute of Technology (KTH), Stokholm, Sweden. See also http://www.sics.se/isl/sicstus.htmlGoogle Scholar
Chen, W. and Warren, D. S. 1996. Tabled evaluation with delaying for general logic programs. Journal of the ACM 43, 1 (January), 2074.CrossRefGoogle Scholar
Clocksin, W. and Mellish, C. 1984. Programming in Prolog. Springer-Verlag, New York.Google Scholar
Demoen, B. 2002. A different look at garbage collection for the WAM. In Proceedings of ICLP2002 – International Conference on Logic Programming, Stuckey, P., Ed. Lecture Notes in Computer Science no. 2401. ALP, Springer-Verlag, Copenhagen, Denmark, 179193.CrossRefGoogle Scholar
Demoen, B. and Nguyen, P.-L. 2000. So many WAM variations, so little time. In Computational Logic – CL2000, Proceedings of First International Conference, London, UK, July, Lloyd, J., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Palamidessi, C., Pereira, L. M., Sagiv, Y. and Stuckey, P. J., Eds. Lecture Notes in Artificial Intelligence, vol. 1861. ALP, Springer, New York, 12401254.Google Scholar
Ershov, A. P. 1958. On programming of arithmetic operations. Commun. ACM 1, 8, 36.Google Scholar
Gabriel, R. P. 1985. Performance and Evaluation of Lisp Systems. MIT Press.Google Scholar
Goto, E. 1974. Monocopy and Associative Algorithms in Extended Lisp. Technical Report TR 74-03, University of Tokyo, Tokyo, Japan.Google Scholar
Grimley-Evans, E. 1995. Findall/3 without copying? [online]. Accessed 14 July 2011. http://www.logicprogramming.org/newsletter/archive_93_96/net/meta-level/findall1.htmlGoogle Scholar
Gutmann, B. and Kersting, K. 2006. Tildecrf: Conditional random fields for logical sequences. In Proceedings of the 15th European Conference on Machine Learning (ECML-2006), Fürnkranz, J., Scheffer, J. and Spiliopoulou, T., Eds. Springer, New York, 174185.Google Scholar
Hirsch, M., Silverman, W. and Shapiro, E. 1987. Computation control and protection in the logix system. In Concurrent Prolog: Collected Papers, vol. 2, Shapiro, E., Ed. MIT Press, Cambridge, MA, 2845.Google Scholar
Mariën, A. and Demoen, B. 1993. Findall without findall/3. In Proceedings of the Tenth International Conference on Logic Programming, Warren, D. S., Ed. MIT Press, Cambridge, MA, 408423.Google Scholar
Neumerkel, U. 1989. Speicherbereinigung für Prologsysteme. M.S. thesis, Institut für Praktische Informatik der Technischen Universität Wien, Austria.Google Scholar
O'Keefe, R. 2001. O(1) reversible tree navigation without cycles. Theory and Practice of Logic Programming 1, 5, 617630.Google Scholar
Reade, C. 1989. Elements of Functional Programming. Addison-Wesley, Massachusetts.Google Scholar
Sagonas, K., Swift, T. and Warren, D. S. 1994. XSB as an efficient deductive database engine. In Proceedings of SIGMOD 1994 Conference, vol. 23:2. ACM, New York, 442453.Google Scholar
Sahlin, D. and Carlsson, M. 1991. Variable Shunting for the WAM. Technical Report SICS/R-91/9107, SICS, Stockholm, Sweden.Google Scholar
Somogyi, Z., Henderson, F. and Conway, T. 1996. The execution algorithm of mercury, an efficient purely declarative logic programming language. Journal of Logic Programming 29, 1–3, 1764.Google Scholar
Tarau, P. 1991. A simplified abstract machine for the execution of binary metaprograms. In Proceedings of the Logic Programming Conference'91. ICOT, Tokyo, 119128.Google Scholar
Tarau, P. 1992. Ecological memory management in a continuation passing prolog engine. In Proceedings of IWMM'92: International Workshop on Memory Management, Bekkers, Y. and Cohen, J., Eds. Lecture Notes in Computer Science, no. 637. Springer-Verlag, New York, 344356.Google Scholar
Tarau, P. and Majumdar, A. 2009. Interoperating logic engines. In Practical Aspects of Declarative Languages, 11th International Symposium, PADL 2009, Savannah, GA, Jan 19–20. LNCS 5418, Springer, New York, 137151.Google Scholar
VanRoy, P. Roy, P. and Despain, A. 1992. High-performance logic programming with the aquarius prolog compiler. IEEE Computer 25, 1, 5468.Google Scholar
Vandeginste, R., Sagonas, K. and Demoen, B. 2002. Segment order preserving and generational garbage collection for Prolog. In Proceedings of Practical Aspects of Declarative Languages, 4th International Symposium, PADL 2002, Krishnamurthi, S. and Ramakrishnan, C., Eds. Lecture Notes in Computer Science, vol. 2257. Springer, New York, 299317.Google Scholar
Wallace, M., Novello, S. and Schimpf, J. 1997. ECLiPSe: A platform for constraint logic programming. ICL Systems Journal 12, 1 (May), 159200.Google Scholar
Warren, D. H. D. 1983. An Abstract Prolog Instruction Set. Technical Report 309, SRI, California.Google Scholar
Wielemaker, J., Huang, Z. and van der Meij, L. 2008. SWI-Prolog and the web. Theory and Practice of Logic Programming 8, 3, 363392.Google Scholar