{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,7,16]],"date-time":"2026-07-16T20:15:51Z","timestamp":1784232951855,"version":"3.55.0"},"reference-count":62,"publisher":"Cambridge University Press (CUP)","issue":"8","license":[{"start":{"date-parts":[[2024,10,21]],"date-time":"2024-10-21T00:00:00Z","timestamp":1729468800000},"content-version":"unspecified","delay-in-days":50,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":["cambridge.org"],"crossmark-restriction":true},"short-container-title":["Math. Struct. Comp. Sci."],"published-print":{"date-parts":[[2024,9]]},"abstract":"<jats:title>Abstract<\/jats:title><jats:p>We give a simple, direct, and reusable logical relations technique for languages with term and type recursion and partially defined differentiable functions. We demonstrate it by working out the case of automatic differentiation (AD) correctness: namely, we present a correctness proof of a dual numbers style AD code transformation for realistic functional languages in the ML-family. We also show how this code transformation provides us with correct forward- and reverse-mode AD.<\/jats:p><jats:p>The starting point is to interpret a functional programming language as a suitable freely generated categorical structure. In this setting, by the universal property of the syntactic categorical structure, the dual numbers AD code transformation and the basic <jats:inline-formula><jats:alternatives><jats:inline-graphic xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" mime-subtype=\"png\" xlink:href=\"S0960129524000215_inline1.png\"\/><jats:tex-math>\n$\\boldsymbol{\\omega } \\mathbf{Cpo}$\n<\/jats:tex-math><\/jats:alternatives><\/jats:inline-formula>-semantics arise as structure preserving functors. The proof follows, then, by a novel logical relations argument.<\/jats:p><jats:p>The key to much of our contribution is a powerful monadic logical relations technique for term recursion and recursive types. It provides us with a semantic correctness proof based on a simple approach for denotational semantics, making use only of the very basic concrete model of <jats:inline-formula><jats:alternatives><jats:inline-graphic xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" mime-subtype=\"png\" xlink:href=\"S0960129524000215_inline2.png\"\/><jats:tex-math>\n$\\omega$\n<\/jats:tex-math><\/jats:alternatives><\/jats:inline-formula>-cpos.<\/jats:p>","DOI":"10.1017\/s0960129524000215","type":"journal-article","created":{"date-parts":[[2024,10,21]],"date-time":"2024-10-21T12:47:13Z","timestamp":1729514833000},"page":"747-806","update-policy":"https:\/\/doi.org\/10.1017\/policypage","source":"Crossref","is-referenced-by-count":2,"title":["Automatic differentiation for ML-family languages: Correctness via logical relations"],"prefix":"10.1017","volume":"34","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-1817-2797","authenticated-orcid":false,"given":"Fernando","family":"Lucatelli Nunes","sequence":"first","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-4603-0523","authenticated-orcid":false,"given":"Matthijs","family":"V\u00e1k\u00e1r","sequence":"additional","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"56","published-online":{"date-parts":[[2024,10,21]]},"reference":[{"key":"S0960129524000215_ref9","unstructured":"Carpenter, B. , Hoffman, M. , 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":"S0960129524000215_ref54","doi-asserted-by":"publisher","DOI":"10.1016\/0022-4049(72)90019-9"},{"key":"S0960129524000215_ref58","unstructured":"V\u00e1k\u00e1r, M. (2020). Denotational correctness of forward-mode automatic differentiation for iteration and recursion. arXiv preprint arXiv: 2007.05282."},{"key":"S0960129524000215_ref30","unstructured":"Kerjean, M. and P\u00e9drot, P.-M. (2022). \u2202 is for Dialectica. working paper or preprint."},{"key":"S0960129524000215_ref42","doi-asserted-by":"publisher","DOI":"10.1109\/LICS.1989.39155"},{"key":"S0960129524000215_ref11","unstructured":"Cockett, J. R. B. , Cruttwell, G. S. and Gallagher, J. D. (2012). Differential restriction categories. arXiv preprint arXiv: 1208.4068."},{"key":"S0960129524000215_ref27","doi-asserted-by":"publisher","DOI":"10.1145\/3190508.3190530"},{"key":"S0960129524000215_ref62","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/N16-1035"},{"key":"S0960129524000215_ref38","unstructured":"Margossian, C. C. and Betancourt, M. (2021). Efficient automatic differentiation of implicit functions. arXiv preprint arXiv: 2112.14217."},{"key":"S0960129524000215_ref35","first-page":"217","article-title":"On biadjoint triangles","volume":"31","author":"Lucatelli Nunes","year":"2016","journal-title":"Theory and Applications of Categories"},{"key":"S0960129524000215_ref16","doi-asserted-by":"publisher","DOI":"10.1145\/3236765"},{"key":"S0960129524000215_ref36","doi-asserted-by":"publisher","DOI":"10.1007\/s10485-022-09694-w"},{"key":"S0960129524000215_ref18","doi-asserted-by":"publisher","DOI":"10.1038\/s41586-020-2405-7"},{"key":"S0960129524000215_ref51","unstructured":"Smeding, T. J. and V\u00e1k\u00e1r, M. I. (2024). Parallel dual-numbers reverse ad. arXiv preprint arXiv: 2207.03418v3."},{"key":"S0960129524000215_ref49","doi-asserted-by":"publisher","DOI":"10.1561\/2200000018"},{"key":"S0960129524000215_ref34","doi-asserted-by":"publisher","DOI":"10.1016\/S0890-5401(03)00088-9"},{"key":"S0960129524000215_ref26","doi-asserted-by":"crossref","unstructured":"Huot, M. , Staton, S. and V\u00e1k\u00e1r, M. (2021). Higher order automatic differentiation of higher order functions. CoRR, abs\/2101.06757.","DOI":"10.46298\/lmcs-18(1:41)2022"},{"key":"S0960129524000215_ref39","doi-asserted-by":"publisher","DOI":"10.1145\/3434309"},{"key":"S0960129524000215_ref10","first-page":"180","article-title":"Lax comma 2-categories and admissible 2-functors","volume":"40","author":"Clementino","year":"2024","journal-title":"Theory and Applications of Categories"},{"key":"S0960129524000215_ref4","doi-asserted-by":"publisher","DOI":"10.1016\/0377-0427(94)90294-1"},{"key":"S0960129524000215_ref20","doi-asserted-by":"publisher","DOI":"10.1016\/j.entcs.2015.12.012"},{"key":"S0960129524000215_ref60","doi-asserted-by":"publisher","DOI":"10.1145\/3290349"},{"key":"S0960129524000215_ref17","doi-asserted-by":"publisher","DOI":"10.1109\/LICS.1994.316083"},{"key":"S0960129524000215_ref23","doi-asserted-by":"publisher","DOI":"10.1137\/1.9780898717761"},{"key":"S0960129524000215_ref22","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-45793-3_37"},{"key":"S0960129524000215_ref19","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0084215"},{"key":"S0960129524000215_ref47","unstructured":"Plotkin, G. (2018). Some principles of differential programming languages. In: Invited talk, POPL, 2028."},{"key":"S0960129524000215_ref52","doi-asserted-by":"publisher","DOI":"10.1137\/0211062"},{"key":"S0960129524000215_ref14","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0060485"},{"key":"S0960129524000215_ref7","doi-asserted-by":"publisher","DOI":"10.1007\/s10485-019-09572-y"},{"key":"S0960129524000215_ref41","doi-asserted-by":"crossref","unstructured":"Mitchell, J. C. and Scedrov, A. (1992). Notes on sconing and relators. In: International Workshop on Computer Science Logic, Springer, pp. 352\u2013378.","DOI":"10.1007\/3-540-56992-8_21"},{"key":"S0960129524000215_ref29","doi-asserted-by":"crossref","unstructured":"Kelly, G. M. and Street, R. (1974). Review of the elements of 2-categories. In: Lecture Notes in Mathematics, Category Seminar (Proc. Sem., Sydney, 1972\/1973), 420, Springer, vol. 75\u2013103.","DOI":"10.1007\/BFb0063101"},{"key":"S0960129524000215_ref50","doi-asserted-by":"publisher","DOI":"10.1145\/3571247"},{"key":"S0960129524000215_ref5","unstructured":"Betancourt, M. (2019). Double-pareto lognormal distribution in stan."},{"key":"S0960129524000215_ref12","volume-title":"28th EACSL Annual Conference on Computer Science Logic, CSL 2020, January 13-16, 2020, Barcelona, Spain","volume":"152","author":"Cockett","year":"2020"},{"key":"S0960129524000215_ref32","unstructured":"Lee, W. , Yu, H. , Rival, X. and Yang, H. (2020). On correctness of automatic differentiation for non-differentiable functions. In: Advances in Neural Information Processing Systems, 33, 6719\u20136730."},{"key":"S0960129524000215_ref59","doi-asserted-by":"crossref","unstructured":"V\u00e1k\u00e1r, M. (2021). Reverse AD at higher types: pure, principled and denotationally correct. In: 30th European Symposium on Programming, ESOP 2021, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2021, Luxembourg City, Luxembourg, March 27 \u2013 April 1, 2021. Proceedings, Springer. 607\u2013634.Proceedings,","DOI":"10.1007\/978-3-030-72019-3_22"},{"key":"S0960129524000215_ref31","doi-asserted-by":"publisher","DOI":"10.1145\/3498710"},{"key":"S0960129524000215_ref55","doi-asserted-by":"crossref","unstructured":"Tai, K. S. , Socher, R. and Manning, C. D. (2015). Improved semantic representations from tree-structured long short-term memory networks. arXiv preprint arXiv: 1503.00075.","DOI":"10.3115\/v1\/P15-1150"},{"key":"S0960129524000215_ref1","doi-asserted-by":"crossref","unstructured":"Abadi, M. and Plotkin, G. (2020). A simple differentiable programming language. In: Proc. POPL 2020, ACM.","DOI":"10.1145\/3371106"},{"key":"S0960129524000215_ref13","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0077118"},{"key":"S0960129524000215_ref8","doi-asserted-by":"crossref","unstructured":"Brunel, A. , Mazza, D. and Pagani, M. (2020). Backpropagation in the simply typed lambda-calculus with linear negation. In: Proc. POPL.","DOI":"10.1145\/3371132"},{"key":"S0960129524000215_ref24","doi-asserted-by":"crossref","unstructured":"Huot, M. , Lew, A. K. , Mansinghka, V. K. and Staton, S. (2023). $\\omega$ pap spaces: Reasoning denotationally about higher-order, recursive probabilistic and differentiable programs. In: 2023 38th Annual ACM\/IEEE Symposium on Logic in Computer Science (LICS), IEEE, 1\u201314.","DOI":"10.1109\/LICS56636.2023.10175739"},{"key":"S0960129524000215_ref40","doi-asserted-by":"publisher","DOI":"10.1145\/3236024.3280855"},{"key":"S0960129524000215_ref61","doi-asserted-by":"publisher","DOI":"10.1145\/3527634"},{"key":"S0960129524000215_ref56","doi-asserted-by":"publisher","DOI":"10.1007\/s10928-019-09630-x"},{"key":"S0960129524000215_ref45","doi-asserted-by":"publisher","DOI":"10.1145\/1330017.1330018"},{"key":"S0960129524000215_ref48","doi-asserted-by":"publisher","DOI":"10.1145\/3341701"},{"key":"S0960129524000215_ref25","doi-asserted-by":"crossref","unstructured":"Huot, M. , Staton, S. and V\u00e1k\u00e1r, M. (2020). Correctness of automatic differentiation via diffeologies and categorical gluing. Full version. arxiv:2001.02209.","DOI":"10.1007\/978-3-030-45231-5_17"},{"key":"S0960129524000215_ref15","doi-asserted-by":"publisher","DOI":"10.1016\/S0304-3975(03)00392-X"},{"key":"S0960129524000215_ref43","doi-asserted-by":"publisher","DOI":"10.1016\/0890-5401(91)90052-4"},{"key":"S0960129524000215_ref46","doi-asserted-by":"publisher","DOI":"10.1006\/inco.1996.0052"},{"key":"S0960129524000215_ref44","doi-asserted-by":"publisher","DOI":"10.1017\/S096012952300018X"},{"key":"S0960129524000215_ref3","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-030-44914-8_3"},{"key":"S0960129524000215_ref57","unstructured":"van Merrienboer, B. , Breuleux, O. , Bergeron, A. and Lamblin, P. (2018). Automatic differentiation in ml: where we are and where we should be going. In: Advances in Neural Information Processing Systems, 8757\u20138767."},{"key":"S0960129524000215_ref53","unstructured":"Socher, R. , Lin, C. C. , Manning, C. and Ng, A. Y. (2011). Parsing natural scenes and natural language with recursive neural networks. In: Proceedings of the 28th international conference on machine learning (ICML-11), 129\u2013136."},{"key":"S0960129524000215_ref21","unstructured":"Goodrich, B. (2017). Conway-maxwell-poisson distribution."},{"key":"S0960129524000215_ref6","volume-title":"Iteration Theories - The Equational Logic of Iterative Processes","author":"Bloom","year":"1993"},{"key":"S0960129524000215_ref37","volume-title":"Categories for the Working Mathematician","volume":"5","author":"Mac Lane","year":"2013"},{"key":"S0960129524000215_ref28","volume-title":"Basic Concepts of Enriched Category Theory","volume":"64","author":"Kelly","year":"1982"},{"key":"S0960129524000215_ref2","unstructured":"Ahmed, A. J. (2006). Step-indexed syntactic logical relations for recursive and quantified types. In: Sestoft, P. (ed.) 15th European Symposium on Programming, ESOP 2006, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2006, Vienna, Austria, March 27-28, 2006, Proceedings, Springer, vol. 3924, 69\u201383, Lecture Notes in Computer Science."},{"key":"S0960129524000215_ref33","volume-title":"Call-by-Push-Value: A Functional\/Imperative Synthesis","volume":"2","author":"Levy","year":"2012"}],"container-title":["Mathematical Structures in Computer Science"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.cambridge.org\/core\/services\/aop-cambridge-core\/content\/view\/S0960129524000215","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,2,6]],"date-time":"2025-02-06T09:02:46Z","timestamp":1738832566000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.cambridge.org\/core\/product\/identifier\/S0960129524000215\/type\/journal_article"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2024,9]]},"references-count":62,"journal-issue":{"issue":"8","published-print":{"date-parts":[[2024,9]]}},"alternative-id":["S0960129524000215"],"URL":"https:\/\/doi.org\/10.1017\/s0960129524000215","relation":{},"ISSN":["0960-1295","1469-8072"],"issn-type":[{"value":"0960-1295","type":"print"},{"value":"1469-8072","type":"electronic"}],"subject":[],"published":{"date-parts":[[2024,9]]},"assertion":[{"value":"\u00a9 The Author(s), 2024. Published by Cambridge University Press","name":"copyright","label":"Copyright","group":{"name":"copyright_and_licensing","label":"Copyright and Licensing"}},{"value":"This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https:\/\/creativecommons.org\/licenses\/by\/4.0\/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.","name":"license","label":"License","group":{"name":"copyright_and_licensing","label":"Copyright and Licensing"}},{"value":"This content has been made available to all.","name":"free","label":"Free to read"}]}}