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'.
- Thorsten Altenkirch and Conor McBride. 2006. Towards Observational Type Theory. http://www.strictlypositive.org/ott.pdf Unpublished manuscript Google Scholar
- 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 Google ScholarCross Ref
- 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 Google Scholar
- Robert Atkey and Patricia Johann. 2015. Interleaving Data and Effects. In Journal of Functional Programming. https://doi.org/10.1017/S0956796815000209 Google ScholarCross Ref
- 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 Google ScholarDigital Library
- 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 Google Scholar
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- Koen Claessen and John Hughes. 2002. Testing Monadic Code with QuickCheck. In GPCE. https://doi.org/10.1145/636517.636527 Google ScholarDigital Library
- 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 Google ScholarCross Ref
- 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 Google Scholar
- Robert L Constable and Scott Fraser Smith. 1987. Partial objects in constructive type theory. Cornell University. https://dl.acm.org/doi/10.5555/866226 Google Scholar
- Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of Dependent Interoperability. In Journal of Functional Programming. https://doi.org/10.1017/S0956796818000011 Google ScholarCross Ref
- Github FStarLang. 2018. Functional Equality Discussions in F*. https://github.com/FStarLang/FStar/blob/cba5383bd0e84140a00422875de21a8a77bae116/ulib/FStar.FunctionalExtensionality.fsti#L133-L134 Google Scholar
- Jeremy Gibbons and Ralf Hinze. 2011. Just Do It: Simple Monadic Equational Reasoning. In ICFP. https://doi.org/10.1145/2034773.2034777 Google ScholarDigital Library
- Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts Made Manifest. In Journal of Functional Programming. https://doi.org/10.1017/S0956796812000135 Google ScholarDigital Library
- Louis-Julien Guillemette and Stefan Monnier. 2008. A Type-Preserving Compiler in Haskell. In ICFP. isbn:9781595939197 https://doi.org/10.1145/1411204.1411218 Google ScholarDigital Library
- Kenneth Knowles and Cormac Flanagan. 2010. Hybrid Type Checking. In ACM Transactions on Programming Languages and Systems. https://doi.org/10.1145/1667048.1667051 Google ScholarDigital Library
- 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 Google Scholar
- Leonidas Lampropoulos, Zoe Paraskevopoulou, and Benjamin C. Pierce. 2018. Generating Good Generators for Inductive Relations. In POPL. https://doi.org/10.1145/3158133 Google ScholarDigital Library
- K. Rustan M. Leino. 2012. Developing verified programs with Dafny. In High Integrity Language Technology. https://doi.org/10.1145/2402676.2402682 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- E. Moggi. 1989. Computational Lambda-Calculus and Monads. In LICS. https://doi.org/10.1109/LICS.1989.39155 Google ScholarCross Ref
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- Tobias Nipkow and Christian Prehofer. 1993. Type Checking Type Classes. In POPL. isbn:0897915607 https://doi.org/10.1145/158511.158698 Google ScholarDigital Library
- 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 Google ScholarCross Ref
- 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 Google ScholarCross Ref
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- Lucas Silver and Steve Zdancewic. 2021. Dijkstra Monads Forever: Termination-Sensitive Specifications for Interaction Trees. In POPL. https://doi.org/10.1145/3434307 Google ScholarDigital Library
- 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 Google Scholar
- 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 Google ScholarDigital Library
- 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 Google ScholarCross Ref
- 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 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- Wouter Swierstra. 2009. A Hoare Logic for the State Monad. In TPHOLs. https://doi.org/10.1007/978-3-642-03359-9_30 Google ScholarDigital Library
- Nicolas Tabareau, Éric Tanter, and Matthieu Sozeau. 2021. The Marriage of Univalence and Parametricity. J. ACM, https://doi.org/10.1145/3429979 Google ScholarDigital Library
- 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 Google ScholarDigital Library
- 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 Google Scholar
- 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 Google ScholarDigital Library
- P. Wadler and S. Blott. 1989. How to Make Ad-Hoc Polymorphism Less Ad Hoc. In POPL. https://doi.org/10.1145/75277.75283 Google ScholarDigital Library
- Stephanie Weirich. 2017. The Influence of Dependent Types (Keynote). In POPL. isbn:9781450346603 https://doi.org/10.1145/3009837.3009923 Google ScholarDigital Library
- Markus Wenzel. 1997. Type Classes and Overloading in HigherOorder Logic. In Theorem Proving in Higher Order Logics. https://doi.org/10.1007/BFb0028402 Google ScholarCross Ref
- Hongwei Xi and Frank Pfenning. 1998. Eliminating Array Bound Checking through Dependent Types. In PLDI. https://doi.org/10.1145/277650.277732 Google ScholarDigital Library
- 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 Google ScholarDigital Library
Index Terms
- How to safely use extensionality in Liquid Haskell
Recommendations
Coinduction inductively: mechanizing coinductive proofs in Liquid Haskell
Haskell 2022: Proceedings of the 15th ACM SIGPLAN International Haskell SymposiumLiquid Haskell is an inductive verifier that cannot reason about codata. In this work we present two alternative approaches, namely indexed and constructive coinduction, to consistently encode coinductive proofs in Liquid Haskell. The ...
Verifying replicated data types with typeclass refinements in Liquid Haskell
This paper presents an extension to Liquid Haskell that facilitates stating and semi-automatically proving properties of typeclasses. Liquid Haskell augments Haskell with refinement types—our work allows such types to be attached to typeclass method ...
Refinement types for Haskell
PLPV '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Programming Languages meets Program VerificationWe present LiquidHaskell (http://goto.ucsd.edu/liquid), an automatic verifier for Haskell. LiquidHaskell uses Refinement types, a restricted form of dependent types where relationships between values are encoded by decorating types with logical ...
Comments