Saved in:
Bibliographic Details
Main Authors: Affeldt, Reynald, Garrigue, Jacques, Saikawa, Takafumi
Format: Preprint
Published: 2023
Subjects:
Online Access:https://arxiv.org/abs/2312.06103
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913648529637376
author Affeldt, Reynald
Garrigue, Jacques
Saikawa, Takafumi
author_facet Affeldt, Reynald
Garrigue, Jacques
Saikawa, Takafumi
contents One can perform equational reasoning about computational effects with a purely functional programming language thanks to monads. Even though equational reasoning for effectful programs is desirable, it is not yet mainstream. This is partly because it is difficult to maintain pencil-and-paper proofs of large examples. We propose a formalization of a hierarchy of effects using monads in the Coq proof assistant that makes monadic equational reasoning practical. Our main idea is to formalize the hierarchy of effects and algebraic laws as interfaces like it is done when formalizing hierarchy of algebras in dependent type theory. Thanks to this approach, we clearly separate equational laws from models. We can then take advantage of the sophisticated rewriting capabilities of Coq and build libraries of lemmas to achieve concise proofs of programs. We can also use the resulting framework to leverage on Coq's mathematical theories and formalize models of monads. In this article, we explain how we formalize a rich hierarchy of effects (nondeterminism, state, probability, etc.), how we mechanize examples of monadic equational reasoning from the literature, and how we apply our framework to the design of equational laws for a subset of ML with references.
format Preprint
id arxiv_https___arxiv_org_abs_2312_06103
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle A Practical Formalization of Monadic Equational Reasoning in Dependent-type Theory
Affeldt, Reynald
Garrigue, Jacques
Saikawa, Takafumi
Logic in Computer Science
One can perform equational reasoning about computational effects with a purely functional programming language thanks to monads. Even though equational reasoning for effectful programs is desirable, it is not yet mainstream. This is partly because it is difficult to maintain pencil-and-paper proofs of large examples. We propose a formalization of a hierarchy of effects using monads in the Coq proof assistant that makes monadic equational reasoning practical. Our main idea is to formalize the hierarchy of effects and algebraic laws as interfaces like it is done when formalizing hierarchy of algebras in dependent type theory. Thanks to this approach, we clearly separate equational laws from models. We can then take advantage of the sophisticated rewriting capabilities of Coq and build libraries of lemmas to achieve concise proofs of programs. We can also use the resulting framework to leverage on Coq's mathematical theories and formalize models of monads. In this article, we explain how we formalize a rich hierarchy of effects (nondeterminism, state, probability, etc.), how we mechanize examples of monadic equational reasoning from the literature, and how we apply our framework to the design of equational laws for a subset of ML with references.
title A Practical Formalization of Monadic Equational Reasoning in Dependent-type Theory
topic Logic in Computer Science
url https://arxiv.org/abs/2312.06103