Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3546189.3549919acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article
Open access

How to safely use extensionality in Liquid Haskell

Published: 06 September 2022 Publication History

Abstract

Refinement type checkers are a powerful way to reason about functional programs. For example, one can prove properties of a slow, specification implementation and port the proofs to an optimized pure implementation that behaves the same. But to reason about higher-order programs, we must reason about equalities between functions: we need a consistent encoding of functional extensionality.
A natural but naive phrasing of the functional extensionality axiom (funExt) is inconsistent in refinement type systems with semantic subtyping and polymorphism: if we assume funExt, then we can prove false. We demonstrate the inconsistency and develop a new approach to equality in Liquid Haskell: we define a propositional equality in a library we call PEq. Using PEq avoids the inconsistency while proving useful equalities at higher types; we demonstrate its use in several case studies. We validate PEq by building a model and developing its metatheory. Additionally, we prove metaproperties of PEq inside Liquid Haskell itself using an unnamed folklore technique, which we dub 'classy induction'.

References

[1]
Thorsten Altenkirch and Conor McBride. 2006. Towards Observational Type Theory. http://www.strictlypositive.org/ott.pdf Unpublished manuscript
[2]
Carlo Angiuli, Evan Cavallo, Kuen-Bang Hou (Favonia), Robert Harper, and Jonathan Sterling. 2018. The RedPRL Proof Assistant (Invited Paper). In Theoretical Computer Science. https://doi.org/10.4204/eptcs.274.1
[3]
Carlo Angiuli, Kuen-Bang Hou (Favonia), and Robert Harper. 2018. Cartesian Cubical Computational Type Theory: Constructive Reasoning with Paths and Equalities. In Computer Science Logic. http://drops.dagstuhl.de/opus/volltexte/2018/9673
[4]
Robert Atkey and Patricia Johann. 2015. Interleaving Data and Effects. In Journal of Functional Programming. https://doi.org/10.1017/S0956796815000209
[5]
Haniel Barbosa, Andrew Reynolds, Daniel El Ouraoui, Cesare Tinelli, and Clark Barrett. 2019. Extending SMT Solvers to Higher-Order Logic. In CADE. isbn:978-3-030-29436-6 https://doi.org/10.1007/978-3-030-29436-6_3
[6]
Clark Barrett, Aaron Stump, and Cesare Tinelli. 2010. The SMT-LIB Standard: Version 2.0. Department of Computer Science, The University of Iowa. www.SMT-LIB.org
[7]
Gavin M. Bierman, Andrew D. Gordon, Catalin Hritcu, and David E. Langworthy. 2012. Semantic Subtyping with an SMT Solver. In Journal of Functional Programming. https://doi.org/10.1017/S0956796812000032
[8]
Simon Boulier, Pierre-Marie Pédrot, and Nicolas Tabareau. 2017. The Next 700 Syntactical Models of Type Theory. In Certified Programs and Proofs. https://doi.org/10.1145/3018610.3018620
[9]
Koen Claessen and John Hughes. 2002. Testing Monadic Code with QuickCheck. In GPCE. https://doi.org/10.1145/636517.636527
[10]
Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg. 2015. Cubical Type Theory: a Constructive Interpretation of the Univalence Axiom. In Types for Proofs and Programs. https://doi.org/10.4230/LIPIcs.TYPES.2015.5
[11]
Robert L. Constable, Stuart F. Allen, Mark Bromley, Rance Cleaveland, J. F. Cremer, R. W. Harper, Douglas J. Howe, Todd B. Knoblock, N. P. Mendler, Prakash Panangaden, James T. Sasaki, and Scott F. Smith. 1986. Implementing Mathematics with the Nuprl Proof Development System. Prentice Hall. isbn:978-0-13-451832-9 http://dl.acm.org/citation.cfm?id=10510
[12]
Robert L Constable and Scott Fraser Smith. 1987. Partial objects in constructive type theory. Cornell University. https://dl.acm.org/doi/10.5555/866226
[13]
Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of Dependent Interoperability. In Journal of Functional Programming. https://doi.org/10.1017/S0956796818000011
[14]
Github FStarLang. 2018. Functional Equality Discussions in F*. https://github.com/FStarLang/FStar/blob/cba5383bd0e84140a00422875de21a8a77bae116/ulib/FStar.FunctionalExtensionality.fsti#L133-L134
[15]
Jeremy Gibbons and Ralf Hinze. 2011. Just Do It: Simple Monadic Equational Reasoning. In ICFP. https://doi.org/10.1145/2034773.2034777
[16]
Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts Made Manifest. In Journal of Functional Programming. https://doi.org/10.1017/S0956796812000135
[17]
Louis-Julien Guillemette and Stefan Monnier. 2008. A Type-Preserving Compiler in Haskell. In ICFP. isbn:9781595939197 https://doi.org/10.1145/1411204.1411218
[18]
Kenneth Knowles and Cormac Flanagan. 2010. Hybrid Type Checking. In ACM Transactions on Programming Languages and Systems. https://doi.org/10.1145/1667048.1667051
[19]
Kenneth Knowles, Aaron Tomb, Jessica Gronski, Stephen N. Freund, and Cormac Flanagan. 2006. Sage: Hybrid checking for flexible specifications. In Scheme and Functional Programming Workshop. http://www.cs.williams.edu/~freund/papers/06-sfp.pdf
[20]
Leonidas Lampropoulos, Zoe Paraskevopoulou, and Benjamin C. Pierce. 2018. Generating Good Generators for Inductive Relations. In POPL. https://doi.org/10.1145/3158133
[21]
K. Rustan M. Leino. 2012. Developing verified programs with Dafny. In High Integrity Language Technology. https://doi.org/10.1145/2402676.2402682
[22]
Yiyun Liu, James Parker, Patrick Redmond, Lindsey Kuper, Michael Hicks, and Niki Vazou. 2020. Verifying Replicated Data Types with Typeclass Refinements in Liquid Haskell. In OOPSLA. https://doi.org/10.1145/3428284
[23]
Kenji Maillard, Danel Ahman, Robert Atkey, Guido Martínez, Cătălin Hriţcu, Exequiel Rivas, and Éric Tanter. 2019. Dijkstra Monads for All. In ICFP. https://doi.org/10.1145/3341708
[24]
E. Moggi. 1989. Computational Lambda-Calculus and Monads. In LICS. https://doi.org/10.1109/LICS.1989.39155
[25]
Benjamin Moon, Harley Eades III, and Dominic Orchard. 2021. Graded Modal Dependent Type Theory. In ESOP, Nobuko Yoshida (Ed.). https://doi.org/10.1007/978-3-030-72019-3_17
[26]
Aleksandar Nanevski, Greg Morrisett, and Lars Birkedal. 2006. Polymorphism and Separation in Hoare Type Theory. In ICFP. isbn:1595933093 https://doi.org/10.1145/1159803.1159812
[27]
Tobias Nipkow and Christian Prehofer. 1993. Type Checking Type Classes. In POPL. isbn:0897915607 https://doi.org/10.1145/158511.158698
[28]
Tobias Nipkow and Gregor Snelting. 1991. Type Classes and Overloading Resolution via Order-Sorted Unification. In Functional Programming Languages and Computer Architecture. https://doi.org/10.1007/3540543961_1
[29]
Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types. In International Conference on Theoretical Computer Science. https://doi.org/10.1007/1-4020-8141-3_34
[30]
Patrick M. Rondon, Ming Kawaguci, and Ranjit Jhala. 2008. Liquid Types. In PLDI. isbn:978-1-59593-860-2 https://doi.org/10.1145/1375581.1375602
[31]
John Rushby, Sam Owre, and Natarajan Shankar. 1998. Subtypes for Specifications: Predicate Subtyping in PVS. IEEE Transactions on Software Engineering, https://doi.org/10.1109/32.713327
[32]
Taro Sekiyama, Atsushi Igarashi, and Michael Greenberg. 2017. Polymorphic Manifest Contracts, Revised and Resolved. In ACM Transactions on Programming Languages and Systems. https://doi.org/10.1145/2994594
[33]
Lucas Silver and Steve Zdancewic. 2021. Dijkstra Monads Forever: Termination-Sensitive Specifications for Interaction Trees. In POPL. https://doi.org/10.1145/3434307
[34]
Matthieu Sozeau. 2008. Un environnement pour la programmation avec types dépendants. Ph. D. Dissertation. Université Paris 11. https://tel.archives-ouvertes.fr/tel-00640052
[35]
Matthieu Sozeau and Nicolas Oury. 2008. First-Class Type Classes. In Theorem Proving in Higher Order Logics. https://doi.org/10.1007/978-3-540-71067-7_23
[36]
Jonathan Sterling, Carlo Angiuli, and Daniel Gratzer. 2019. Cubical Syntax for Reflection-Free Extensional Equality. In LIPIcs. https://doi.org/10.4230/LIPIcs.FSCD.2019.31
[37]
Nikhil Swamy, Catalin Hritcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean-Karim Zinzindohoué, and Santiago Zanella-Béguelin. 2016. Dependent Types and Multi-Monadic Effects in F*. In POPL. http://dx.doi.org/10.1145/2837614.2837655
[38]
Nikhil Swamy, Joel Weinberger, Cole Schlesinger, Juan Chen, and Benjamin Livshits. 2013. Verifying Higher-Order Programs with the Dijkstra Monad. In PLDI. isbn:9781450320146 https://doi.org/10.1145/2491956.2491978
[39]
Wouter Swierstra. 2009. A Hoare Logic for the State Monad. In TPHOLs. https://doi.org/10.1007/978-3-642-03359-9_30
[40]
Nicolas Tabareau, Éric Tanter, and Matthieu Sozeau. 2021. The Marriage of Univalence and Parametricity. J. ACM, https://doi.org/10.1145/3429979
[41]
Niki Vazou, Joachim Breitner, Rose Kunkel, David Van Horn, and Graham Hutton. 2018. Theorem Proving for All: Equational Reasoning in Liquid Haskell (Functional Pearl). In Haskell. isbn:978-1-4503-5835-4 https://doi.org/10.1145/3242744.3242756
[42]
Niki Vazou and Michael Greenberg. 2021. How to Safely Use Extensionality in Liquid Haskell (extended version). In CoRR. https://doi.org/10.48550/ARXIV.2103.02177
[43]
Niki Vazou, Anish Tondwalkar, Vikraman Choudhury, Ryan G. Scott, Ryan R. Newton, Philip Wadler, and Ranjit Jhala. 2018. Refinement Reflection: Complete Verification with SMT. In POPL. https://doi.org/10.1145/3158141
[44]
P. Wadler and S. Blott. 1989. How to Make Ad-Hoc Polymorphism Less Ad Hoc. In POPL. https://doi.org/10.1145/75277.75283
[45]
Stephanie Weirich. 2017. The Influence of Dependent Types (Keynote). In POPL. isbn:9781450346603 https://doi.org/10.1145/3009837.3009923
[46]
Markus Wenzel. 1997. Type Classes and Overloading in HigherOorder Logic. In Theorem Proving in Higher Order Logics. https://doi.org/10.1007/BFb0028402
[47]
Hongwei Xi and Frank Pfenning. 1998. Eliminating Array Bound Checking through Dependent Types. In PLDI. https://doi.org/10.1145/277650.277732
[48]
Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, and Steve Zdancewic. 2019. Interaction Trees: Representing Recursive and Impure Programs in Coq. In POPL. https://doi.org/10.1145/3371119

Cited By

View all
  • (2024)Quotient Haskell: Lightweight Quotient Types for AllProceedings of the ACM on Programming Languages10.1145/36328698:POPL(785-815)Online publication date: 5-Jan-2024
  • (2023)On the Practicality and Soundness of Refinement TypesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.396.1396(1-3)Online publication date: 17-Nov-2023
  • (2023)Explicit Refinement TypesProceedings of the ACM on Programming Languages10.1145/36078377:ICFP(187-214)Online publication date: 31-Aug-2023

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
Haskell 2022: Proceedings of the 15th ACM SIGPLAN International Haskell Symposium
September 2022
136 pages
ISBN:9781450394383
DOI:10.1145/3546189
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 06 September 2022

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. function equality
  2. functional extensionality
  3. refinement types

Qualifiers

  • Research-article

Conference

Haskell '22
Sponsor:
Haskell '22: 15th ACM SIGPLAN International Haskell Symposium
September 15 - 16, 2022
Ljubljana, Slovenia

Acceptance Rates

Overall Acceptance Rate 57 of 143 submissions, 40%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)125
  • Downloads (Last 6 weeks)23
Reflects downloads up to 22 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Quotient Haskell: Lightweight Quotient Types for AllProceedings of the ACM on Programming Languages10.1145/36328698:POPL(785-815)Online publication date: 5-Jan-2024
  • (2023)On the Practicality and Soundness of Refinement TypesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.396.1396(1-3)Online publication date: 17-Nov-2023
  • (2023)Explicit Refinement TypesProceedings of the ACM on Programming Languages10.1145/36078377:ICFP(187-214)Online publication date: 31-Aug-2023

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media