Skip to main content

Exploiting Term Hiding to Reduce Run-Time Checking Overhead

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 2018)

Abstract

One of the most attractive features of untyped languages is the flexibility in term creation and manipulation. However, with such power comes the responsibility of ensuring the correctness of these operations. A solution is adding run-time checks to the program via assertions, but this can introduce overheads that are in many cases impractical. While static analysis can greatly reduce such overheads, the gains depend strongly on the quality of the information inferred. Reusable libraries, i.e., library modules that are pre-compiled independently of the client, pose special challenges in this context. We propose a technique which takes advantage of module systems which can hide a selected set of functor symbols to significantly enrich the shape information that can be inferred for reusable libraries, as well as an improved run-time checking approach that leverages the proposed mechanisms to achieve large reductions in overhead, closer to those of static languages, even in the reusable-library context. While the approach is general and system-independent, we present it for concreteness in the context of the Ciao assertion language and combined static/dynamic checking framework. Our method maintains the full expressiveness of the assertion language in this context. In contrast to other approaches it does not introduce the need to switch the language to a (static) type system, which is known to change the semantics in languages like Prolog. We also study the approach experimentally and evaluate the overhead reduction achieved in the run-time checks.

Research partially funded by Spanish MINECO TIN2015-67522-C3-1-R grant TRACES and the Madrid M141047003 N-GREENS program. We also thank Dylan McDermott, Alan Mycroft, and the anonymous reviewers for their comments. An extended abstract on this work was published as [1].

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 44.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 60.00
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

Similar content being viewed by others

Notes

  1. 1.

    In practice constraints are also located in modules. It is trivial to extend the formalization to include this, we do not write it explicitly for simplicity.

  2. 2.

    In the general case Pre and Post can be DNF formulas of prop literals but we limit them to conjunctions herein for simplicity of presentation.

  3. 3.

    Note that even if several assertion conditions may be violated at the same time, we consider only the first one of them. The ordering is only imposed by the implementation and does not affect the semantics.

  4. 4.

    The formal definition of the equivalence relation on derivations, as well as proofs for the theorems and lemmas can be found in Appendix A of the extended version of this paper available from CoRR at https://arxiv.org/abs/1705.06662 (v3).

  5. 5.

    In practice, an exception is multifile predicates. However, since they need to be declared explicitly, local reasoning is still valid assuming conservative semantics (e.g., topmost abstract values) for them.

  6. 6.

    Note that this can be achieved in other systems: e.g., in XSB [4] it can be done with a :- local/1 declaration, combined with not exporting the symbol.

  7. 7.

    This can be implemented very efficiently with a simple bit check on the atom properties and does not impact the execution.

  8. 8.

    A simple example of assertions, escaping terms, and shallow checks, as well as full plots for all benchmarks can be found in Appendices B-C of the extended version of this paper available from CoRR at https://arxiv.org/abs/1705.06662 (v3).

  9. 9.

    Due to our reusable library scenario the analysis of the libraries is performed without any knowledge of the client and thus the library interface checks must always remain.

  10. 10.

    The current measurements depend on the C getrusage() function, that on Mac OS has microsecond resolution.

References

  1. Stulova, N., Morales, J., Hermenegildo, M.: Towards run-time checks simplification via term hiding (extended abstract). In: Technical Communications of ICLP 2017, OASIcs (2017)

    Google Scholar 

  2. Hermenegildo, M., Bueno, F., Carro, M., López, P., Mera, E., Morales, J., Puebla, G.: An overview of Ciao and its design philosophy. TPLP 12(1–2), 219–252 (2012)

    MathSciNet  MATH  Google Scholar 

  3. Stulova, N., Morales, J., Hermenegildo, M.: Reducing the overhead of assertion run-time checks via static analysis. In: PPDP 2016, pp. 90–103. ACM, September 2016

    Google Scholar 

  4. Swift, T., Warren, D.S.: XSB: extending Prolog with tabled logic programming. TPLP 12(1–2), 157–187 (2012)

    MathSciNet  MATH  Google Scholar 

  5. Cabeza, D., Hermenegildo, M.: A new module system for Prolog. In: Lloyd, J., et al. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 131–148. Springer, Heidelberg (2000). https://doi.org/10.1007/3-540-44957-4_9

    Chapter  Google Scholar 

  6. Hermenegildo, M.V., Puebla, G., Bueno, F.: Using global analysis, partial specifications, and an extensible assertion language for program validation and debugging. In: Apt, K.R., Marek, V.W., Truszczynski, M., Warren, D.S. (eds.) The Logic Programming Paradigm, pp. 161–192. Springer, Heidelberg (1999). https://doi.org/10.1007/978-3-642-60085-2_7

    Chapter  Google Scholar 

  7. Puebla, G., Bueno, F., Hermenegildo, M.: Combined static and dynamic assertion-based debugging of constraint logic programs. In: Bossi, A. (ed.) LOPSTR 1999. LNCS, vol. 1817, pp. 273–292. Springer, Heidelberg (2000). https://doi.org/10.1007/10720327_16

    Chapter  Google Scholar 

  8. Stulova, N., Morales, J., Hermenegildo, M.: Assertion-based debugging of higher-order (C)LP programs. In: PPDP 2014, ACM, September 2014

    Google Scholar 

  9. Puebla, G., Albert, E., Hermenegildo, M.: Abstract interpretation with specialized definitions. In: Yi, K. (ed.) SAS 2006. LNCS, vol. 4134, pp. 107–126. Springer, Heidelberg (2006). https://doi.org/10.1007/11823230_8

    Chapter  Google Scholar 

  10. Stulova, N., Morales, J., Hermenegildo, M.: Practical run-time checking via unobtrusive property caching. TPLP 15(04–05), 726–741 (2015)

    MathSciNet  MATH  Google Scholar 

  11. Warren, D., Chen, W.: Formal semantics of a theory of modules. Technical report 87/11, SUNY at Stony Brook (1987)

    Google Scholar 

  12. Chen, W.: A theory of modules based on second-order logic. In: 4th IEEE International Symposium on Logic Programming, San Francisco, pp. 24–33 (1987)

    Google Scholar 

  13. Miller, D.: A logical analysis of modules in logic programming. J. Logic Program. 6, 79–108 (1989)

    Article  MathSciNet  MATH  Google Scholar 

  14. ISO: PROLOG: ISO/IEC DIS 13211–2 — Part 2: Modules (2000)

    Google Scholar 

  15. Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-Prolog. TPLP 12(1–2), 67–96 (2012)

    MathSciNet  MATH  Google Scholar 

  16. Carlsson, M., Mildner, P.: SICStus Prolog - the first 25 years. TPLP 12(1–2), 35–66 (2012)

    MathSciNet  MATH  Google Scholar 

  17. Santos Costa, V., Rocha, R., Damas, L.: The YAP Prolog system. TPLP 12(1–2), 5–34 (2012)

    MathSciNet  MATH  Google Scholar 

  18. Schimpf, J., Shen, K.: ECLiPSe - from LP to CLP. TPLP 12(1–2), 127–156 (2012)

    MATH  Google Scholar 

  19. Haemmerlé, R., Fages, F.: Modules for Prolog revisited. In: Etalle, S., Truszczyński, M. (eds.) ICLP 2006. LNCS, vol. 4079, pp. 41–55. Springer, Heidelberg (2006). https://doi.org/10.1007/11799573_6

    Chapter  Google Scholar 

  20. Mycroft, A., O’Keefe, R.: A polymorphic type system for Prolog. Artif. Intell. 23, 295–307 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  21. Somogyi, Z., Henderson, F., Conway, T.: The execution algorithm of Mercury: an efficient purely declarative logic programming language. J. Logic Program. 29(1–3), 17–64 (1996)

    Article  MATH  Google Scholar 

  22. Hill, P., Lloyd, J.: The Gödel Programming Language. MIT Press, Cambridge (1994)

    MATH  Google Scholar 

  23. Prolog Development Center: Visual Prolog

    Google Scholar 

  24. Schrijvers, T., Santos Costa, V., Wielemaker, J., Demoen, B.: Towards typed Prolog. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 693–697. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-89982-2_59

    Chapter  Google Scholar 

  25. Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop, pp. 81–92 (2006)

    Google Scholar 

  26. Takikawa, A., Feltey, D., Greenman, B., New, M., Vitek, J., Felleisen, M.: Is sound gradual typing dead? In: POPL 2016, pp. 456–468, January 2016

    Google Scholar 

  27. Cartwright, R., Fagan, M.: Soft typing. In: PLDI 1991, SIGPLAN, pp. 278–292. ACM (1991)

    Google Scholar 

  28. Hermenegildo, M.V., Bueno, F., Carro, M., López, P., Mera, E., Morales, J., Puebla, G.: The Ciao approach to the dynamic vs. static language dilemma. In: Proceedings of the International WS on Scripts to Programs, STOP 2011. ACM (2011)

    Google Scholar 

  29. Fähndrich, M., Logozzo, F.: Static contract checking with abstract interpretation. In: Beckert, B., Marché, C. (eds.) FoVeOOS 2010. LNCS, vol. 6528, pp. 10–30. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-18070-5_2

    Chapter  Google Scholar 

  30. Tobin-Hochstadt, S., Van Horn, D.: Higher-order symbolic execution via contracts. In: OOPSLA, pp. 537–554. ACM (2012)

    Google Scholar 

  31. Nguyen, P., Horn, D.V.: Relatively complete counterexamples for higher-order programs. In: PLDI 2015, pp. 446–456. ACM (2015)

    Google Scholar 

  32. Koukoutos, E., Kuncak, V.: Checking data structure properties orders of magnitude faster. In: Bonakdarpour, B., Smolka, S.A. (eds.) RV 2014. LNCS, vol. 8734, pp. 263–268. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-11164-3_22

    Google Scholar 

  33. Mera, E., Lopez-García, P., Hermenegildo, M.: Integrating software testing and run-time checking in an assertion verification framework. In: Hill, P.M., Warren, D.S. (eds.) ICLP 2009. LNCS, vol. 5649, pp. 281–295. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02846-5_25

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nataliia Stulova .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer International Publishing AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Stulova, N., Morales, J.F., Hermenegildo, M.V. (2018). Exploiting Term Hiding to Reduce Run-Time Checking Overhead. In: Calimeri, F., Hamlen, K., Leone, N. (eds) Practical Aspects of Declarative Languages. PADL 2018. Lecture Notes in Computer Science(), vol 10702. Springer, Cham. https://doi.org/10.1007/978-3-319-73305-0_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-73305-0_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-73304-3

  • Online ISBN: 978-3-319-73305-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics