Skip to content

Commit f71151a

Browse files
Addressed second half of Nil's feedback
1 parent 0a92ce7 commit f71151a

File tree

2 files changed

+131
-58
lines changed

2 files changed

+131
-58
lines changed

paper/paper.bib

Lines changed: 108 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ @Book{plfa22.08
55
month = aug,
66
url = {https://plfa.inf.ed.ac.uk/22.08/},
77
}
8+
89
@mastersthesis{ivardeBruin2023,
910
author = {Ivar {de Bruin}},
1011
title = {Improving {Agda}'s module system},
@@ -54,11 +55,20 @@ @article{DBLP:journals/jfp/VezzosiMA21
5455
}
5556

5657
@inproceedings{norell2009dependently,
57-
title={Dependently typed programming in {Agda}},
58-
author={Norell, Ulf},
59-
booktitle={Proceedings of the 4th international workshop on Types in language design and implementation},
60-
pages={1--2},
61-
year={2009}
58+
author = {Norell, Ulf},
59+
title = {Dependently typed programming in {Agda}},
60+
year = {2009},
61+
isbn = {9781605584201},
62+
publisher = {Association for Computing Machinery},
63+
address = {New York, NY, USA},
64+
url = {https://doi.org/10.1145/1481861.1481862},
65+
doi = {10.1145/1481861.1481862},
66+
booktitle = {Proceedings of the 4th International Workshop on Types in Language Design and Implementation},
67+
pages = {1–2},
68+
numpages = {2},
69+
keywords = {programming, dependent types},
70+
location = {Savannah, GA, USA},
71+
series = {TLDI '09}
6272
}
6373

6474
@inproceedings{hu2021categories,
@@ -97,39 +107,69 @@ @article{florence2019esterel
97107
}
98108

99109
@article{bach2017intrinsically,
100-
title={Intrinsically-typed definitional interpreters for imperative languages},
101-
author={Bach Poulsen, Casper and Rouvoet, Arjen and Tolmach, Andrew and Krebbers, Robbert and Visser, Eelco},
102-
journal={Proceedings of the ACM on Programming Languages},
103-
volume={2},
104-
number={POPL},
105-
pages={1--34},
106-
year={2017},
107-
publisher={ACM New York, NY, USA}
110+
author = {Bach Poulsen, Casper and Rouvoet, Arjen and Tolmach, Andrew and Krebbers, Robbert and Visser, Eelco},
111+
title = {Intrinsically-typed definitional interpreters for imperative languages},
112+
year = {2017},
113+
issue_date = {January 2018},
114+
publisher = {Association for Computing Machinery},
115+
address = {New York, NY, USA},
116+
volume = {2},
117+
number = {POPL},
118+
url = {https://doi.org/10.1145/3158104},
119+
doi = {10.1145/3158104},
120+
journal = {Proc. ACM Program. Lang.},
121+
month = dec,
122+
articleno = {16},
123+
numpages = {34},
124+
keywords = {type safety, scope graphs, mechanized semantics, dependent types, definitional interpreters, Java, Agda}
108125
}
109126

110-
@inproceedings{pizani2018pi,
111-
title={Pi-ware: Hardware description and verification in agda},
112-
author={Pizani Flor, Jo{\~a}o Paulo and Swierstra, Wouter and Sijsling, Yorick},
113-
booktitle={21st International Conference on Types for Proofs and Programs (TYPES 2018)},
114-
year={2018},
115-
organization={Schloss-Dagstuhl-Leibniz Zentrum f{\"u}r Informatik}
127+
@InProceedings{pizani2018pi,
128+
author = {Pizani Flor, Jo\~{a}o Paulo and Swierstra, Wouter and Sijsling, Yorick},
129+
title = {{Pi-Ware: Hardware Description and Verification in Agda}},
130+
booktitle = {21st International Conference on Types for Proofs and Programs (TYPES 2015)},
131+
pages = {9:1--9:27},
132+
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
133+
ISBN = {978-3-95977-030-9},
134+
ISSN = {1868-8969},
135+
year = {2018},
136+
volume = {69},
137+
editor = {Uustalu, Tarmo},
138+
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
139+
address = {Dagstuhl, Germany},
140+
URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.TYPES.2015.9},
141+
URN = {urn:nbn:de:0030-drops-84791},
142+
doi = {10.4230/LIPIcs.TYPES.2015.9},
143+
annote = {Keywords: dependently typed programming, Agda, EDSL, hardware description languages, functional programming}
116144
}
117145

118146
@article{daggitt2023routing,
119-
title={Formally verified convergence of policy-rich dbf routing protocols},
120-
author={Daggitt, Matthew L and Griffin, Timothy G},
121-
journal={IEEE/ACM Transactions on Networking},
147+
author={Daggitt, Matthew L. and Griffin, Timothy G.},
148+
journal={IEEE/ACM Transactions on Networking},
149+
title={Formally Verified Convergence of Policy-Rich {DBF} Routing Protocols},
122150
year={2023},
123-
publisher={IEEE}
151+
volume={32},
152+
number={2},
153+
pages={1645-1660},
154+
keywords={Routing protocols;Protocols;Mathematical models;Routing;Convergence;Libraries;Filtering;Vector routing protocols;algebra;convergence;formal verification;Agda},
155+
doi={10.1109/TNET.2023.3326336}
124156
}
157+
125158
126159
@inproceedings{carette2020leveraging,
127-
title={Leveraging the information contained in theory presentations},
128-
author={Carette, Jacques and Farmer, William M and Sharoda, Yasmine},
129-
booktitle={Intelligent Computer Mathematics: 13th International Conference, CICM 2020, Bertinoro, Italy, July 26--31, 2020, Proceedings 13},
130-
pages={55--70},
131-
year={2020},
132-
organization={Springer}
160+
author = {Carette, Jacques and Farmer, William M. and Sharoda, Yasmine},
161+
title = {Leveraging the Information Contained in Theory Presentations},
162+
year = {2020},
163+
isbn = {978-3-030-53517-9},
164+
publisher = {Springer-Verlag},
165+
address = {Berlin, Heidelberg},
166+
url = {https://doi.org/10.1007/978-3-030-53518-6_4},
167+
doi = {10.1007/978-3-030-53518-6_4},
168+
booktitle = {Intelligent Computer Mathematics: 13th International Conference, CICM 2020, Bertinoro, Italy, July 26–31, 2020, Proceedings},
169+
pages = {55–70},
170+
numpages = {16},
171+
keywords = {Formal library, Algebraic hierarchy},
172+
location = {Bertinoro, Italy}
133173
}
134174

135175
@book{paulson1994isabelle,
@@ -153,21 +193,37 @@ @misc{coq2024manual
153193
howpublished = "\url{https://coq.inria.fr/doc/V8.19.0/refman}"
154194
}
155195

156-
@inproceedings{van2020maintaining,
157-
title={Maintaining a library of formal mathematics},
158-
author={{van Doorn}, Floris and Ebner, Gabriel and Lewis, Robert Y},
159-
booktitle={International Conference on Intelligent Computer Mathematics},
160-
pages={251--267},
161-
year={2020},
162-
organization={Springer}
196+
@InProceedings{van2020maintaining,
197+
author="van Doorn, Floris
198+
and Ebner, Gabriel
199+
and Lewis, Robert Y.",
200+
editor="Benzm{\"u}ller, Christoph
201+
and Miller, Bruce",
202+
title="Maintaining a Library of Formal Mathematics",
203+
booktitle="Intelligent Computer Mathematics",
204+
year="2020",
205+
publisher="Springer International Publishing",
206+
address="Cham",
207+
pages="251--267",
208+
abstract="The Lean mathematical library mathlib is developed by a community of users with very different backgrounds and levels of experience. To lower the barrier of entry for contributors and to lessen the burden of reviewing contributions, we have developed a number of tools for the library which check proof developments for subtle mistakes in the code and generate documentation suited for our varied audience.",
209+
isbn="978-3-030-53518-6"
163210
}
164211

212+
165213
@inproceedings{allais2019generic,
166-
title={Generic level polymorphic n-ary functions},
167-
author={Allais, Guillaume},
168-
booktitle={Proceedings of the 4th ACM SIGPLAN International Workshop on Type-Driven Development},
169-
pages={14--26},
170-
year={2019}
214+
author = {Allais, Guillaume},
215+
title = {Generic level polymorphic n-ary functions},
216+
year = {2019},
217+
isbn = {9781450368155},
218+
publisher = {Association for Computing Machinery},
219+
address = {New York, NY, USA},
220+
url = {https://doi.org/10.1145/3331554.3342604},
221+
doi = {10.1145/3331554.3342604},
222+
pages = {14–26},
223+
numpages = {13},
224+
keywords = {Agda, Arity-generic programming, Dependent types, Universe polymorphism},
225+
location = {Berlin, Germany},
226+
series = {TyDe 2019}
171227
}
172228

173229

@@ -219,3 +275,14 @@ @inproceedings{cohen2020hierarchy
219275
pages={34--1},
220276
year={2020}
221277
}
278+
279+
@article{devriese2011bright,
280+
title={On the bright side of type classes: instance arguments in Agda},
281+
author={Devriese, Dominique and Piessens, Frank},
282+
journal={ACM SIGPLAN Notices},
283+
volume={46},
284+
number={9},
285+
pages={143--155},
286+
year={2011},
287+
publisher={ACM New York, NY, USA}
288+
}

paper/paper.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Through the Curry-Howard lens [@DBLP:journals/cacm/Wadler15],
101101
these types and programs can be seen respectively as theorem
102102
statements and proofs.
103103

104-
This paper presents the Agda standard library (hereafter: `agda-stdlib` [@agda-stdlib]), which offers many of the fundamental definitions and results necessary for users to quickly begin developing Agda programs and proofs.
104+
This paper presents the Agda standard library (hereafter: `agda-stdlib` [@agda-stdlib-v2.0]), which offers fundamental definitions and results necessary for users to quickly begin developing Agda programs and proofs.
105105
Unlike the standard libraries of traditional programming languages, `agda-stdlib` provides not only standard utilities and data structures, but also a substantial portion of the basic discrete mathematics essential for proving the correctness of programs.
106106

107107
# Statement of need
@@ -152,34 +152,36 @@ On the contrary, "coinfective" options affect the import*ed* modules; these are
152152
This categorisation enables libraries to integrate safe Agda code with code that uses unsafe operating system calls, while maintaining the safety guarantees of the former.
153153

154154
Second, the development of `agda-stdlib` motivated adding the ability to attach custom messages to definitions, which are then displayed by the compiler when the definitions are used. This enabled the implementation of deprecation warnings amongst other features, and lets end-users more easily evolve their code alongside new versions of `agda-stdlib`.
155+
Thirdly, `agda-stdlib` has been used as a test bed for the design of co-inductive data types, as evidenced by the three different otions of co-inductive data present in the library.
155156

156157
# Design
157158

158159
Designing a standard library for an ITP such as Agda presents several challenges.
159160

160-
Firstly, as discussed, `agda-stdlib` contains much of the foundational mathematics used to prove program correctness.
161+
Firstly, as discussed, `agda-stdlib` contains much of the basic mathematics useful for proving program correctness.
161162
While the focus on discrete mathematics and algebra reflects the bias in its user base towards programming language theory, organising this material into a coherent and logical structure is difficult, though some recent efforts exist in this direction [@carette2020leveraging,@cohen2020hierarchy].
162163
There is constant tension between being as general as possible (e.g., defining operations over general algebraic structures) and providing clear, straightforward, and intuitive definitions (e.g., defining operations concretely over integers).
163164
Additionally, there is a persistent temptation to introduce new representations of existing mathematical objects that are easier to work with for a particular application, which comes at the cost of duplicating the theory for the new representation.
164-
Theorem provers like Isabelle [@paulson1994isabelle] and Coq [@coq2024manual] approach these problems by having very minimal standard libraries and encouraging the use of external libraries developed by the community, which reduces the emphasis on ensuring the existence of canonical definitions for certain concepts, at the cost of lack of interoperability between various packages.
165-
On the other hand, like `agda-stdlib`, MathLib [@van2020maintaining] for Lean aims to provide a repository of canonical definitions.
165+
Theorem provers like Isabelle [@paulson1994isabelle] and Coq [@coq2024manual] have very minimal standard libraries and encouraging the use of external libraries developed by the community, which reduces the emphasis on ensuring the existence of canonical definitions for certain concepts, at the cost of lack of interoperability between various packages.
166+
On the other hand, like `agda-stdlib`, MathLib [@van2020maintaining] for Lean provides a repository of canonical definitions.
167+
Philisophically, `agda-stdlib` is more closely aligned with the approach of the MathLib community, and aims to provide canonical definitions for mathematical objects and introduce new representations only sparingly.
166168

167169
A second challenge is that Agda was the first major ITP to fully embrace dependently-typed programming as the default.
168-
With the exception of Idris, a more recent entrant to the field [@brady2013idris], other major theorem provers either do not support dependent types or encourage their use only sparingly.
170+
With the exception of Idris, a more recent entrant to the field [@brady2013idris], either other major theorem provers do not support dependent types or their communities and libraries encourage their use only sparingly.
169171
In contrast, nearly everything in `agda-stdlib` makes use of dependent types, with correctness-related invariants being closely integrated with definitions.
170172
For example, we can specify that `reverse` defined on length-indexed vectors is length-preserving *by virtue of its type*.
171-
Furthermore, most proofs consist of evidence-bearing terms for the relevant types, rather than being "irrelevant".
172-
As a result, the library provides relatively sophisticated features like polymorphic n-ary functions [@allais2019generic], regular expressions which provide proof of membership when compiled and applied, and proof-carrying `All` and `Any` predicates for containers.
173-
While this provides powerful tools for users, learning how to design such a large-scale, dependently-typed library is an ongoing journey. The Agda standard library is the first such to tackle this challenge.
174-
Relatedly, `agda-stdlib` has been used as a test bed for the design of the Agda language itself, as evidenced by the library's inclusion of three different notions of co-inductive data types.
175-
176-
Agda’s unique support for dependently-parameterised modules [@ivardeBruin2023] has also significantly influenced the library’s design.
177-
Although type classes are a common mechanism for creating interfaces and overloading syntax in other functional languages such as Haskell [@haskell2010], and other ITPs like Coq and Lean's MathLib use them extensively as a core feature of their design, the developers of `agda-stdlib` has so far found little need to exploit such an approach.
178-
While Agda supports a very general form of instance search, the ability to use qualified, parameterised modules appears to reduce the need for it compared to the languages mentioned above.
179-
Additionally, parameterised modules enable the safe and scalable embedding of non-constructive mathematics into a constructive system.
180-
Since Agda is entirely constructive, the vast majority of `agda-stdlib` is also constructive.
181-
Non-constructive methods, such as classical reasoning, can be achieved by passing the relevant axioms as module parameters.
182-
This enables users to write provably "safe" non-constructive code, i.e. without having to *postulate* such axioms.
173+
Furthermore, most proofs consist of evidence-bearing terms for the relevant types and therefore can themselves be computed on.
174+
By using dependent types, the library provides sophisticated features like polymorphic n-ary functions [@allais2019generic] and regular expressions which provide proof of membership when compiled and applied.
175+
While widespread use of dependent types provides powerful tools for users, learning how to design a large, dependently-typed library is an ongoing journey, and we believe the Agda standard library has been one of the first such standard libraries to tackle the challenge.
176+
177+
Unlike other ITPs, Agda’s module system [@ivardeBruin2023] supports module parameters whose type is dependent on earlier module parameters and this has also significantly influenced the design of `agda-stdlib`.
178+
Many functional languages, such as Haskell [@haskell2010], and ITP libraries, like Lean's MathLib, use type classes as the primary mechanism for creating interfaces and overloading syntax.
179+
While Agda supports a more general form of type-classes via instances [@devriese2011bright], we have found that the use of qualified, dependently-parameterised modules can reproduce most of the abstraction capabilities of type-classes.
180+
The main benefits are that it allows users to explicitly describe which objects are being used to instantiate the abstract code and reduces the risk of time-consuming searches at type-checking time.
181+
The main drawback is that users needs to use qualified imports when instantiating the abstract code twice in the same scope.
182+
Another benefit of parameterised modules is we have found that they facilitate the safe and scalable embedding of non-constructive mathematics into a largely constructive standard library.
183+
In particular, non-constructive operations, such as classical reasoning, can be made available by passing them as module parameters, allowing code access to them throughout the module.
184+
This enables users to write non-constructive code, without either having to postulate the axioms (which would incompatible with the `--safe` flag), or explicitly pass them through as arguments to every function in the module.
183185

184186
# Testing
185187

@@ -215,4 +217,8 @@ without whom Agda itself would not exist.
215217

216218
The authors of this paper are listed approximately in order of contribution to the library. A full list of contributors to `agda-stdlib` may be found in the `LICENCE` in the GitHub source tree.
217219

220+
# Funding and conflicts of interest
221+
222+
The authors of this paper have received no funding to work on the library, and have no conflicts of interest.
223+
218224
# References

0 commit comments

Comments
 (0)