Skip to main content

Teaching Prolog with Active Logic Documents

  • Chapter
  • First Online:
Prolog: The Next 50 Years

Part of the book series: Lecture Notes in Computer Science ((LNAI,volume 13900))

Abstract

Teaching materials for programming languages, and Prolog in particular, classically include textbooks, slides, notes, and exercise sheets, together with some Prolog programming environment. However, modern web technology offers many opportunities for embedding interactive components within such teaching materials. We report on our experiences in developing and applying our approach and the corresponding tools to facilitating this task, that we call Active Logic Documents (ALD). ALD offers both a very easy way to add click-to-run capabilities to any kind of teaching materials, independently of the tool used to generate them, as well as a tool-set for generating web-based materials with embedded examples and exercises. Both leverage on (components of) the Ciao Prolog Playground. Fundamental principles of our approach are that active parts run locally on the student’s browser, with no need for a central infrastructure, and that output is generated from a single, easy to use source that can be developed with any editor. We argue that this has multiple advantages from the point of view of scalability, low maintenance cost, security, ease of packaging and distribution, etc. over other approaches.

Partially funded by MICINN projects PID2019-108528RB-C21 ProCode, TED2021-132464B-I00 PRODIGY, and FJC2021-047102-I, by the Comunidad de Madrid program P2018/TCS-4339 BLOQUES-CM, by FCT under strategic project UIDB/04516/2020 (NOVA LINCS) and by the Tezos foundation. The authors would also like to thank the anonymous reviewers for very useful feedback on previous drafts of this paper.

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

Notes

  1. 1.

    https://jupyter.org/.

  2. 2.

    By “document” we mean the actual document (in pdf, or XML, etc.) which has been produced by the course writer and which is being read by the student.

  3. 3.

    https://ciao-lang.org/playground.

  4. 4.

    https://ciao-lang.org/playground/scasp.html.

  5. 5.

    Written in Prolog of course!.

  6. 6.

    Editors like MS-Word use non-human oriented document formats: bloated with metadata, often binary encoded and undocumented, almost impossible to modify and maintain without the original tools, and really hard to integrate with code-oriented version control systems.

  7. 7.

    However, note that once the markup language is stable and well defined, it is perfectly possible to implement rich WYSIWIG front-ends that can save documents in this format. See for example Lyx, TeXmacs, etc. or rich-editors for Markdown.

  8. 8.

    https://ciao-lang.org/ciao/build/doc/ciao_playground.html/.

  9. 9.

    https://ciao-lang.org/ciao/build/doc/ciao_playground.html/.

  10. 10.

    https://pika-lab.gitlab.io/tuprolog/2p-kt-web.

  11. 11.

    https://webassembly.org/.

  12. 12.

    See also [9] in this same book.

  13. 13.

    E.g., Interactive CiaoPP tutorials https://ciao-lang.org/ciao/build/doc/ciaopp_tutorials.html/.

  14. 14.

    E.g., Course material in Computational Logic: https://cliplab.org/~logalg.

References

  1. Arias, J., Carro, M., Salazar, E., Marple, K., Gupta, G.: Constraint answer set programming without grounding. Theory Pract. Logic Program. 18(3–4), 337–354 (2018). https://doi.org/10.1017/S1471068418000285

    Article  MathSciNet  MATH  Google Scholar 

  2. Brecklinghaus, A., Koerner, P.: A Jupyter kernel for Prolog. In: Proceedings 36th Workshop on (Constraint) Logic Lrogramming (WLP 2022). Lecture Notes in Informatics (LNI), Gesellschaft für Informatik, Bonn (2022)

    Google Scholar 

  3. Flach, P., Sokol, K., Wielemaker, J.: Simply logical - the first three decades. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 184–193. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_15

  4. Garcia-Pradales, G., Morales, J., Hermenegildo, M.V.: The Ciao Playground. Tech. rep., Technical University of Madrid (UPM) and IMDEA Software Institute (2021). http://ciao-lang.org/ciao/build/doc/ciao_playground.html/ciao_playground_manual.html

  5. Garcia-Pradales, G., Morales, J., Hermenegildo, M.V., Arias, J., Carro, M.: An s(CASP) In-browser playground based on Ciao prolog. In: ICLP2022 Workshop on Goal-directed Execution of Answer Set Programs (2022)

    Google Scholar 

  6. Haas, A., et al.: Bringing the web up to speed with webassembly. In: Cohen, A., Vechev, M.T. (eds.) Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, Barcelona, Spain, 18–23 June 2017, pp. 185–200. ACM (2017). https://doi.org/10.1145/3062341.3062363

  7. Hermenegildo, M.: A documentation generator for (C)LP systems. In: Lloyd, J., et al. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 1345–1361. Springer, Heidelberg (2000). https://doi.org/10.1007/3-540-44957-4_90

    Chapter  Google Scholar 

  8. Hermenegildo, M.V., Morales, J.: The LPdoc documentation generator. Ref. Manual (v3.0). Tech. rep., UPM (2011). http://ciao-lang.org

  9. Hermenegildo, M., Morales, J.: Some thoughts on how to teach Prolog. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M., Kowalski, R., Rossi, F. (eds.) Prolog: The Next 50 Years. LNCS (LNAI), vol. 13900, pp. 107–123. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-35254-6_9

  10. Knuth, D.: Literate programming. Computer J. 27, 97–111 (1984)

    Article  MATH  Google Scholar 

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

  12. Morales, J.F., Haemmerlé, R., Carro, M., Hermenegildo, M.V.: Lightweight compilation of (C)LP to JavaScript. Theory and Practice of Logic Programming, 28th International Conference on Logic Programming (ICLP2012) Special Issue 12(4–5), pp. 755–773 (2012)

    Google Scholar 

  13. Morrison, B.B., DiSalvo, B.J.: Khan academy gamifies computer science. In: Dougherty, J.D., Nagel, K., Decker, A., Eiselt, K. (eds.) The 45th ACM Technical Symposium on Computer Science Education, SIGCSE 2014, Atlanta, GA, USA, 5–8 March 2014, pp. 39–44. ACM (2014). https://doi.org/10.1145/2538862.2538946

  14. \(\tau \)Prolog – an open source Prolog interpreter in javascript. http://tau-prolog.org (2021). Accessed 16 May 2023

  15. Wielemaker, J., Riguzzi, F., Kowalski, R.A., Lager, T., Sadri, F., Calejo, M.: Using SWISH to realize interactive web-based tutorials for logic-based languages. Theory Pract. Log. Program. 19(2), 229–261 (2019). https://doi.org/10.1017/S1471068418000522

  16. Zakai, A.: Emscripten: an LLVM-to-Javascript compiler. In: Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications, pp. 301–312. SPLASH 2011, ACM, New York, NY, USA (2011). https://doi.org/10.1145/2048147.2048224

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Manuel V. Hermenegildo .

Editor information

Editors and Affiliations

Appendix

Appendix

Fig. 3.
figure 3

The full source and LPdoc output for the Active Logic Document for the simple factorial exercise.

Rights and permissions

Reprints and permissions

Copyright information

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

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Morales, J.F., Abreu, S., Ferreiro, D., Hermenegildo, M.V. (2023). Teaching Prolog with Active Logic Documents. In: Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M.V., Kowalski, R., Rossi, F. (eds) Prolog: The Next 50 Years. Lecture Notes in Computer Science(), vol 13900. Springer, Cham. https://doi.org/10.1007/978-3-031-35254-6_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-35254-6_14

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-35253-9

  • Online ISBN: 978-3-031-35254-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics