{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2025,6,13]],"date-time":"2025-06-13T06:28:48Z","timestamp":1749796128211,"version":"3.40.5"},"reference-count":32,"publisher":"Cambridge University Press (CUP)","issue":"4","license":[{"start":{"date-parts":[[2023,7,6]],"date-time":"2023-07-06T00:00:00Z","timestamp":1688601600000},"content-version":"unspecified","delay-in-days":5,"URL":"https:\/\/www.cambridge.org\/core\/terms"}],"content-domain":{"domain":["cambridge.org"],"crossmark-restriction":true},"short-container-title":["Theory and Practice of Logic Programming"],"published-print":{"date-parts":[[2023,7]]},"abstract":"<jats:title>Abstract<\/jats:title><jats:p>Automatic differentiation (AD) is a range of algorithms to compute the numeric value of a function\u2019s (partial) derivative, where the function is typically given as a computer program or abstract syntax tree. AD has become immensely popular as part of many learning algorithms, notably for neural networks. This paper uses Prolog to systematically derive gradient-based forward- and reverse-mode AD variants from a simple executable specification: evaluation of the symbolic derivative. Along the way we demonstrate that several Prolog features (DCGs, co-routines) contribute to the succinct formulation of the algorithm. We also discuss two applications in probabilistic programming that are enabled by our Prolog algorithms. The first is parameter learning for the Sum-Product Loop Language and the second consists of both parameter learning and variational inference for probabilistic logic programming.<\/jats:p>","DOI":"10.1017\/s1471068423000145","type":"journal-article","created":{"date-parts":[[2023,7,6]],"date-time":"2023-07-06T08:09:01Z","timestamp":1688630941000},"page":"900-917","update-policy":"https:\/\/doi.org\/10.1017\/policypage","source":"Crossref","is-referenced-by-count":3,"title":["Automatic Differentiation in Prolog"],"prefix":"10.1017","volume":"23","author":[{"ORCID":"https:\/\/orcid.org\/0000-0001-8771-5559","authenticated-orcid":false,"given":"TOM","family":"SCHRIJVERS","sequence":"first","affiliation":[]},{"given":"BIRTHE","family":"VAN DEN BERG","sequence":"additional","affiliation":[]},{"ORCID":"https:\/\/orcid.org\/0000-0003-1654-9703","authenticated-orcid":false,"given":"FABRIZIO","family":"RIGUZZI","sequence":"additional","affiliation":[]}],"member":"56","published-online":{"date-parts":[[2023,7,6]]},"reference":[{"key":"S1471068423000145_ref11","doi-asserted-by":"publisher","DOI":"10.1016\/j.tcs.2012.02.024"},{"key":"S1471068423000145_ref8","doi-asserted-by":"crossref","unstructured":"Dash, S. , Kaddar, Y. , Paquet, H. and Staton, S. 2023. Affine monads and lazy structures for bayesian programming. Proceedings of the ACM on Programming Languages 7, POPL, 1338\u20131368.","DOI":"10.1145\/3571239"},{"key":"S1471068423000145_ref3","unstructured":"Bradbury, J. , Frostig, R. , Hawkins, P. , Johnson, M. J. , Leary, C. , Maclaurin, D. , Necula, G. , Paszke, A. , VanderPlas, J. , Wanderman-Milne, S. and Zhang, Q. 2018. JAX: Composable transformations of Python+NumPy programs. URL: https:\/\/github.com\/google\/jax."},{"key":"S1471068423000145_ref1","unstructured":"Abadi, M. , Agarwal, A. , Barham, P. , Brevdo, E. , Chen, Z. , Citro, C. , Corrado, G. S. , Davis, A. , Dean, J. , Devin, M. , Ghemawat, S. , Goodfellow, I. , Harp, A. , Irving, G. , Isard, M. , Jia, Y. , Jozefowicz, R. , Kaiser, L. , Kudlur, M. , Levenberg, J. , Mane, D. , Monga, R. , Moore, S. , Murray, D. , Olah, C. , Schuster, M. , Shlens, J. , Steiner, B. , Sutskever, I. , Talwar, K. , Tucker, P. , Vanhoucke, V. , Vasudevan, V. , Viegas, F. , Vinyals, O. , Warden, P. , Wattenberg, M. , Wicke, M. , Yu, Y. and Zheng, X. 2015. TensorFlow: Large-scale machine learning on heterogeneous systems. Software available from tensorflow.org."},{"key":"S1471068423000145_ref9","doi-asserted-by":"crossref","unstructured":"Debray, S. K. 1988. Unfold\/fold transformations and loop optimization of logic programs. In Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation. PLDI\u201988. New York, NY, USA, 297\u2013307.","DOI":"10.1145\/53990.54020"},{"key":"S1471068423000145_ref10","unstructured":"Gabel, P. L. 2020. Automatic differentiation. URL: http:\/\/petergabel.info\/blog\/AutoDiff\/#Backward-Mode-Automatic-Differentiation-1."},{"key":"S1471068423000145_ref26","doi-asserted-by":"publisher","DOI":"10.1145\/3571247"},{"key":"S1471068423000145_ref13","doi-asserted-by":"publisher","DOI":"10.1609\/aaai.v25i1.7852"},{"key":"S1471068423000145_ref27","first-page":"1","article-title":"Higher order automatic differentiation with dual numbers","volume":"1","author":"Szirmay-Kalos","year":"2021","journal-title":"Periodica Polytechnica Electrical Engineering and Computer Science 65"},{"key":"S1471068423000145_ref20","article-title":"Reverse-mode AD in a functional framework: Lambda the ultimate backpropagator","volume":"2","author":"Pearlmutter","year":"2008","journal-title":"ACM Transactions on Programming Languages and Systems 30"},{"volume-title":"Foundations of Probabilistic Logic Programming: Languages, Semantics, Inference and Learning","year":"2018","author":"Riguzzi","key":"S1471068423000145_ref22"},{"key":"S1471068423000145_ref29","doi-asserted-by":"publisher","DOI":"10.1017\/S1471068402001618"},{"key":"S1471068423000145_ref19","unstructured":"Paszke, A. , Gross, S. , Massa, F. , Lerer, A. , Bradbury, J. , Chanan, G. , Killeen, T. , Lin, Z. , Gimelshein, N. , Antiga, L. , Desmaison, A. , Kopf, A. , Yang, E. , DeVito, Z. , Raison, M. , Tejani, A. , Chilamkurthy, S. , Steiner, B. , Fang, L. , Bai, J. and Chintala, S. 2019. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32. Curran Associates, Inc., 8024\u20138035."},{"key":"S1471068423000145_ref18","doi-asserted-by":"crossref","unstructured":"Nguyen, M. , Perera, R. , Wang, M. and Wu, N. 2022. Modular probabilistic models via algebraic effects. Proceedings of the ACM on Programming Languages 6, ICFP, 381\u2013410.","DOI":"10.1145\/3547635"},{"key":"S1471068423000145_ref15","doi-asserted-by":"crossref","unstructured":"Krawiec, F. , Jones, S. P. , Krishnaswami, N. , Ellis, T. , Eisenberg, R. A. and Fitzgibbon, A. W. 2022. Provably correct, asymptotically efficient, higher-order reverse-mode automatic differentiation. Proceedings of the ACM on Programming Languages 6, POPL, 1\u201330.","DOI":"10.1145\/3498710"},{"key":"S1471068423000145_ref5","first-page":"1","article-title":"Stan: A probabilistic programming language","volume":"1","author":"Carpenter","year":"2017","journal-title":"Journal of Statistical Software 76"},{"key":"S1471068423000145_ref2","unstructured":"Abdallah, S. 2017. Automatic differentiation using constraint handling rules in Prolog. URL: https:\/\/arxiv.org\/abs\/1706.00231."},{"key":"S1471068423000145_ref6","unstructured":"Carpenter, B. , Hoffman, M. D. , Brubaker, M. , Lee, D. , Li, P. and Betancourt, M. 2015. The stan math library: Reverse-mode automatic differentiation in c++. arXiv preprint arXiv:1509.07164."},{"key":"S1471068423000145_ref25","doi-asserted-by":"publisher","DOI":"10.1017\/S1471068405002541"},{"key":"S1471068423000145_ref16","unstructured":"Manhaeve, R. , Dumancic, S. , Kimmig, A. , Demeester, T. and De Raedt, L. 2018. Deepproblog: Neural probabilistic logic programming. In Advances in Neural Information Processing Systems 31."},{"key":"S1471068423000145_ref12","doi-asserted-by":"publisher","DOI":"10.1017\/S1471068412000154"},{"key":"S1471068423000145_ref23","doi-asserted-by":"publisher","DOI":"10.1017\/S1471068420000435"},{"key":"S1471068423000145_ref4","doi-asserted-by":"publisher","DOI":"10.1017\/S1471068403001893"},{"key":"S1471068423000145_ref24","first-page":"1330","article-title":"PRISM: A language for symbolic-statistical modeling","volume":"97","author":"Sato","year":"1997","journal-title":"In IJCAI"},{"key":"S1471068423000145_ref21","doi-asserted-by":"publisher","DOI":"10.24963\/kr.2022\/47"},{"key":"S1471068423000145_ref14","doi-asserted-by":"publisher","DOI":"10.1145\/359131.359136"},{"key":"S1471068423000145_ref7","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-55481-0"},{"key":"S1471068423000145_ref30","doi-asserted-by":"crossref","unstructured":"Wang, F. , Zheng, D. , Decker, J. M. , Wu, X. , Essertel, G. M. and Rompf, T. 2019. Demystifying differentiable programming: Shift\/reset the penultimate backpropagator. Proceedings of the ACM on Programming Languages 3, ICFP, 96:1\u201396:31.","DOI":"10.1145\/3341700"},{"volume-title":"Local Rings","year":"1962","author":"Nagata","key":"S1471068423000145_ref17"},{"key":"S1471068423000145_ref28","doi-asserted-by":"publisher","DOI":"10.2139\/ssrn.4358090"},{"key":"S1471068423000145_ref31","doi-asserted-by":"publisher","DOI":"10.1145\/355586.364791"},{"key":"S1471068423000145_ref32","doi-asserted-by":"publisher","DOI":"10.48550\/arXiv.1301.1299"}],"container-title":["Theory and Practice of Logic Programming"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.cambridge.org\/core\/services\/aop-cambridge-core\/content\/view\/S1471068423000145","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2024,2,27]],"date-time":"2024-02-27T09:38:17Z","timestamp":1709026697000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.cambridge.org\/core\/product\/identifier\/S1471068423000145\/type\/journal_article"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2023,7]]},"references-count":32,"journal-issue":{"issue":"4","published-print":{"date-parts":[[2023,7]]}},"alternative-id":["S1471068423000145"],"URL":"https:\/\/doi.org\/10.1017\/s1471068423000145","relation":{},"ISSN":["1471-0684","1475-3081"],"issn-type":[{"type":"print","value":"1471-0684"},{"type":"electronic","value":"1475-3081"}],"subject":[],"published":{"date-parts":[[2023,7]]},"assertion":[{"value":"\u00a9 The Author(s), 2023. Published by Cambridge University Press","name":"copyright","label":"Copyright","group":{"name":"copyright_and_licensing","label":"Copyright and Licensing"}}]}}