Rethinking Answer Set Programming Templates

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

Abstract

In imperative programming, the Domain-Driven Design methodology helps in co** with the complexity of software development by materializing in code the invariants of a domain of interest. Code is cleaner and more secure because any implicit assumption is removed in favor of invariants, thus enabling a fail fast mindset and the immediate reporting of unexpected conditions. This article introduces a notion of template for Answer Set Programming that, in addition to the don’t repeat yourself principle, enforces locality of some predicates by means of a simple naming convention. Local predicates are mapped to the usual global namespace adopted by mainstream engines, using universally unique identifiers to avoid name clashes. This way, local predicates can be used to enforce invariants on the expected outcome of a template in a possibly empty context of application, independently by other rules that can be added to such a context. Template applications transpiled this way can be processed by mainstream engines and safely shared with other knowledge designers, even when they have zero knowledge of templates.

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

Access this chapter

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

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

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. AlOmar, E.A., Wang, T., Raut, V., Mkaouer, M.W., Newman, C.D., Ouni, A.: Refactoring for reuse: an empirical study. Innov. Syst. Softw. Eng. 18(1), 105–135 (2022)

    Article  Google Scholar 

  2. Amendola, G., Berei, T., Ricca, F.: Testing in ASP: revisited language and programming environment. In: Faber, W., Friedrich, G., Gebser, M., Morak, M. (eds.) JELIA 2021. LNCS (LNAI), vol. 12678, pp. 362–376. Springer, Cham (2021). https://doi.org/10.1007/978-3-030-75775-5_24

    Chapter  Google Scholar 

  3. Baral, C., Dzifcak, J., Takahashi, H.: Macros, macro calls and use of ensembles in modular answer set programming. In: Etalle, S., Truszczyński, M. (eds.) ICLP 2006. LNCS, vol. 4079, pp. 376–390. Springer, Heidelberg (2006). https://doi.org/10.1007/11799573_28

    Chapter  Google Scholar 

  4. Bomanson, J., Janhunen, T., Niemelä, I.: Applying visible strong equivalence in answer-set program transformations. ACM Trans. Comput. Log. 21(4), 33:1–33:41 (2020)

    Google Scholar 

  5. Cabalar, P., Fandinno, J., Lierler, Y.: Modular answer set programming as a formal specification language. Theory Pract. Log. Program. 20(5), 767–782 (2020)

    Article  MathSciNet  Google Scholar 

  6. Calimeri, F., et al.: Asp-core-2 input language format. Theory Pract. Log. Program. 20(2), 294–309 (2020)

    Article  MathSciNet  Google Scholar 

  7. Calimeri, F., Ianni, G.: Template programs for disjunctive logic programming: an operational semantics. AI Commun. 19(3), 193–206 (2006)

    MathSciNet  Google Scholar 

  8. Dao-Tran, M., Eiter, T., Fink, M., Krennwallner, T.: Modular nonmonotonic logic programming revisited. In: Hill, P.M., Warren, D.S. (eds.) ICLP 2009. LNCS, vol. 5649, pp. 145–159. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02846-5_16

    Chapter  Google Scholar 

  9. Dao-Tran, M., Eiter, T., Fink, M., Krennwallner, T.: Distributed nonmonotonic multi-context systems. In: KR. AAAI Press (2010)

    Google Scholar 

  10. Eiter, T., Gottlob, G., Veith, H.: Modular logic programming and generalized quantifiers. In: Dix, J., Furbach, U., Nerode, A. (eds.) LPNMR 1997. LNCS, vol. 1265, pp. 289–308. Springer, Heidelberg (1997). https://doi.org/10.1007/3-540-63255-7_22

    Chapter  Google Scholar 

  11. Eiter, T., Tompits, H., Woltran, S.: On solution correspondences in answer-set programming. In: IJCAI, pp. 97–102. Professional Book Center (2005)

    Google Scholar 

  12. Erdem, E., Gelfond, M., Leone, N.: Applications of answer set programming. AI Mag. 37(3), 53–68 (2016)

    Google Scholar 

  13. Fandinno, J., Lifschitz, V., Lühne, P., Schaub, T.: Verifying tight logic programs with anthem and vampire. Theory Pract. Log. Program. 20(5), 735–750 (2020)

    Article  MathSciNet  Google Scholar 

  14. Fandinno, J., Pearce, D., Vidal, C., Woltran, S.: Comparing the reasoning capabilities of equilibrium theories and answer set programs. Algorithms 15(6), 201 (2022)

    Article  Google Scholar 

  15. Febbraro, O., Reale, K., Ricca, F.: Testing ASP programs in ASPIDE. In: CILC. CEUR Workshop Proceedings, vol. 810, pp. 115–129. CEUR-WS.org (2011)

    Google Scholar 

  16. Fink, M.: A general framework for equivalences in answer-set programming by countermodels in the logic of here-and-there. Theory Pract. Log. Program. 11(2–3), 171–202 (2011)

    Article  MathSciNet  Google Scholar 

  17. Geibinger, T., Tompits, H.: Characterising relativised strong equivalence with projection for non-ground answer-set programs. In: Calimeri, F., Leone, N., Manna, M. (eds.) JELIA 2019. LNCS (LNAI), vol. 11468, pp. 542–558. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-19570-0_36

    Chapter  Google Scholar 

  18. Greßler, A., Oetsch, J., Tompits, H.: Harvey: a system for random testing in ASP. In: Balduccini, M., Janhunen, T. (eds.) LPNMR 2017. LNCS (LNAI), vol. 10377, pp. 229–235. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-61660-5_21

    Chapter  Google Scholar 

  19. Heyting, A.: Die formalen regeln der intuitionistischen logik, pp. 42–56. Deütsche Akademie der Wissenschaften zu Berlin, Mathematisch-Naturwissenschaftliche Klasse (1930)

    Google Scholar 

  20. Janhunen, T., Niemelä, I., Oetsch, J., Pührer, J., Tompits, H.: On testing answer-set programs. In: ECAI. Frontiers in Artificial Intelligence and Applications, vol. 215, pp. 951–956. IOS Press (2010)

    Google Scholar 

  21. Janhunen, T., Niemelä, I., Oetsch, J., Pührer, J., Tompits, H.: Random vs. structure-based testing of answer-set programs: an experimental comparison. In: Delgrande, J.P., Faber, W. (eds.) LPNMR 2011. LNCS (LNAI), vol. 6645, pp. 242–247. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-20895-9_26

    Chapter  Google Scholar 

  22. Janhunen, T., Oikarinen, E., Tompits, H., Woltran, S.: Modularity aspects of disjunctive stable models. J. Artif. Intell. Res. 35, 813–857 (2009)

    Article  MathSciNet  Google Scholar 

  23. Kaminski, R., Romero, J., Schaub, T., Wanko, P.: How to build your own asp-based system?! Theory Pract. Log. Program. 23(1), 299–361 (2023)

    Article  MathSciNet  Google Scholar 

  24. Leach, P., Mealling, M., Salz, R.: A universally unique identifier (UUID) urn namespace. Internet Requests for Comments, July 2005. https://tools.ietf.org/html/rfc4122

  25. Lifschitz, V.: Achievements in answer set programming. Theory Pract. Log. Program. 17(5–6), 961–973 (2017)

    Article  MathSciNet  Google Scholar 

  26. Lifschitz, V.: Answer Set Programming. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-24658-7

  27. LĂĽhne, P.: Discovering and proving invariants in answer set programming and planning. CoRR abs/1905.03196 (2019)

    Google Scholar 

  28. Oetsch, J., Prischink, M., PĂĽhrer, J., Schwengerer, M., Tompits, H.: On the small-scope hypothesis for testing answer-set programs. In: KR. AAAI Press (2012)

    Google Scholar 

  29. Oetsch, J., Seidl, M., Tompits, H., Woltran, S.: Beyond uniform equivalence between answer-set programs. ACM Trans. Comput. Log. 22(1), 2:1–2:46 (2021)

    Google Scholar 

  30. Pearce, D.: Equilibrium logic. Ann. Math. Artif. Intell. 47(1–2), 3–41 (2006)

    Article  MathSciNet  Google Scholar 

  31. Son, T.C., Pontelli, E., Balduccini, M., Schaub, T.: Answer set planning: a survey. Theory Pract. Log. Program. 23(1), 226–298 (2023)

    Article  MathSciNet  Google Scholar 

  32. Vos, M.D., Kisa, D.G., Oetsch, J., Pührer, J., Tompits, H.: Annotating answer-set programs in LANA. Theory Pract. Log. Program. 12(4–5), 619–637 (2012)

    Article  MathSciNet  Google Scholar 

Download references

Acknowledgment

This work was partially supported by Italian Ministry of Research (MUR) under PRIN project PRODE “Probabilistic declarative process mining”, CUP H53D23003420006 under PNRR project FAIR “Future AI Research”, CUP H23C22000860006, under PNRR project Tech4You “Technologies for climate change adaptation and quality of life improvement”, CUP H23C22000370006, and under PNRR project SERICS “SEcurity and RIghts in the CyberSpace”, CUP H73C22000880001; by Italian Ministry of Health (MSAL) under POS projects CAL.HUB.RIA (CUP H53C22000800006) and RADIOAMICA (CUP H53C22000650006); by the LAIA lab (part of the SILA labs) and by GNCS-INdAM.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mario Alviano .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Alviano, M., Ianni, G., Pacenza, F., Zangari, J. (2023). Rethinking Answer Set Programming Templates. In: Gebser, M., Sergey, I. (eds) Practical Aspects of Declarative Languages. PADL 2024. Lecture Notes in Computer Science, vol 14512. Springer, Cham. https://doi.org/10.1007/978-3-031-52038-9_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-52038-9_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-52037-2

  • Online ISBN: 978-3-031-52038-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics

Navigation