skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Refinement reflection: complete verification with SMT

Published:27 December 2017Publication History
Skip Abstract Section

Abstract

We introduce Refinement Reflection, a new framework for building SMT-based deductive verifiers. The key idea is to reflect the code implementing a user-defined function into the function’s (output) refinement type. As a consequence, at uses of the function, the function definition is instantiated in the SMT logic in a precise fashion that permits decidable verification. Reflection allows the user to write equational proofs of programs just by writing other programs using pattern-matching and recursion to perform case-splitting and induction. Thus, via the propositions-as-types principle, we show that reflection permits the specification of arbitrary functional correctness properties. Finally, we introduce a proof-search algorithm called Proof by Logical Evaluation that uses techniques from model checking and abstract interpretation, to completely automate equational reasoning. We have implemented reflection in Liquid Haskell and used it to verify that the widely used instances of the Monoid, Applicative, Functor, and Monad typeclasses actually satisfy key algebraic laws required to make the clients safe, and have used reflection to build the first library that actually verifies assumptions about associativity and ordering that are crucial for safe deterministic parallelism.

Skip Supplemental Material Section

Supplemental Material

refinementreflection.webm

webm

100.8 MB

References

  1. N. Amin, K. R. M. L., and T. Rompf. 2014. Computing with an SMT Solver. In TAP.Google ScholarGoogle Scholar
  2. A. Appel. 2016. Verified Functional Algorithms. https://www.cs.princeton.edu/~appel/vfa/Perm.html .Google ScholarGoogle Scholar
  3. K. Asada, R. Sato, and N. Kobayashi. 2015. Verifying Relational Properties of Functional Programs by First-Order Refinement. In PEPM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. L. Augustsson. 1998. Cayenne - a Language with Dependent Types.. In ICFP.Google ScholarGoogle Scholar
  5. C. Barrett, A. Stump, and C. Tinelli. 2010. The SMT-LIB Standard: Version 2.0.Google ScholarGoogle Scholar
  6. J. Bengtson, K. Bhargavan, C. Fournet, A.D. Gordon, and S. Maffeis. 2008. Refinement Types for Secure Implementations. In CSF . Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Y. Bertot and P. Castéran. 2004. Coq’Art: The Calculus of Inductive Constructions. Springer Verlag.Google ScholarGoogle Scholar
  8. R. S. Bird. 1989. Algebraic Identities for Program Calculation. In The Computer Journal. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. J. C. Blanchette, S. Böhme, and L. C. Paulson. 2011. Extending Sledgehammer with SMT Solvers. In CADE. Google ScholarGoogle ScholarCross RefCross Ref
  10. Jr. Bocchino, L. Robert, V. S. Adve, S. V. Adve, and M. Snir. 2009. Parallel Programming Must Be Deterministic by Default. In HotPar .Google ScholarGoogle Scholar
  11. C. Casinghino, V. Sjöberg, and S. Weirich. 2014. Combining proofs and programs in a dependently typed language. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Chen, R. Chugh, and N. Swamy. 2010. Type-preserving Compilation of End-to-end Verification of Security Enforcement. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. K. Claessen and J. Hughes. 2000. QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. E. M. Clarke, O. Grumberg, and D.E. Long. 1992. Model checking and abstraction. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Condit, M. Harren, Z. R. Anderson, D. Gay, and G. C. Necula. 2007. Dependent Types for Low-Level Programming. In ESOP . Google ScholarGoogle ScholarCross RefCross Ref
  16. R. L. Constable and S. F. Smith. 1987. Partial Objects In Constructive Type Theory. In LICS.Google ScholarGoogle Scholar
  17. P. Cousot and R. Cousot. 1977. Abstract Interpretation: A Unified Lattice Model for the Static Analysis of Programs. In POPL . Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. E. W. Dijkstra. 1975. Guarded Commands, Nondeterminacy and Formal Derivation of Programs. In Communications of the ACM .Google ScholarGoogle Scholar
  19. E. W. Dijkstra. 1976. A Discipline of Programming. Prentice-Hall.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. R. A. Eisenberg and J. Stolarek. 2014. Promoting functions to type families in Haskell. In Haskell. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A. Farmer, N. Sculthorpe, and A. Gill. 2015. Reasoning with the HERMIT: Tool Support for Equational Reasoning on GHC Core Programs. In Haskell.Google ScholarGoogle Scholar
  22. G. Gentzen. 1935. Inverstigations into Logical Deduction. In American Philosophical Quarterly.Google ScholarGoogle Scholar
  23. W. A. Howard. 1980. The formulae-as-types notion of construction. In Essays on Combinatory Logic, Lambda Calculus and Formalism .Google ScholarGoogle Scholar
  24. G. Hutton. 1999. A tutorial on the universality and expressiveness of fold. J. Functional Programming (1999).Google ScholarGoogle Scholar
  25. A. M. Kent, D. Kempe, and S. Tobin-Hochstadt. 2016. Occurrence typing modulo theories. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. K. W. Knowles and C. Flanagan. 2010. Hybrid type checking. In TOPLAS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. L. Kuper, A. Turon, N. R Krishnaswami, and R. R Newton. 2014. Freeze after writing: quasi-deterministic parallel programming with LVars. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. K. R. M. Leino. 2010. Dafny: An Automatic Program Verifier for Functional Correctness. In LPAR.Google ScholarGoogle Scholar
  29. K. R. M. Leino and C. Pit-Claudel. 2016. Trigger selection strategies to stabilize program verifiers. In CAV. Google ScholarGoogle ScholarCross RefCross Ref
  30. K. R. M. Leino and N. Polikarpova. 2016. Verified Calculations. In VSTTE.Google ScholarGoogle Scholar
  31. R. Leino. 2016. Dafny. (2016). https://github.com/Microsoft/dafny/blob/master/Test/dafny0/Fuel.dfy .Google ScholarGoogle Scholar
  32. S. Marlow, R. Newton, and S. Peyton-Jones. 2011. A Monad for Deterministic Parallelism. In Haskell. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. C. Mu, H. S. Ko, and P. Jansson. 2009. Algebra of Programming in Agda: Dependent Types for Relational Program Derivation. In J. Funct. Program.Google ScholarGoogle Scholar
  34. G. C. Necula. 1997. Proof carrying code. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. C. G. Nelson. 1980. Techniques for Program Verification. Ph.D. Dissertation. Stanford University.Google ScholarGoogle Scholar
  36. T. Nipkow, L.C. Paulson, and M. Wenzel. 2002. Isabelle/HOL — A Proof Assistant for Higher-Order Logic.Google ScholarGoogle Scholar
  37. U. Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Chalmers.Google ScholarGoogle Scholar
  38. X. Ou, G. Tan, Y. Mandelbaum, and D. Walker. 2004. Dynamic Typing with Dependent Types. In IFIP TCS. Google ScholarGoogle ScholarCross RefCross Ref
  39. J. C. Reynolds. 1972. Definitional interpreters for higher-order programming languages. In ACM National Conference. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. P. Rondon, M. Kawaguchi, and R. Jhala. 2008. Liquid Types. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. P. Rondon, M. Kawaguchi, and R. Jhala. 2010. Low-Level Liquid Types. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. J. Rushby, S. Owre, and N. Shankar. 1998. Subtypes for Specifications: Predicate Subtyping in PVS. TSE.Google ScholarGoogle Scholar
  43. E. L. Seidel, N. Vazou, and R. Jhala. 2015. Type Targeted Testing. In ESOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. V. Sjöberg and S. Weirich. 2015. Programming Up to Congruence. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. W. Sonnex, S. Drossopoulou, and S. Eisenbach. 2012. Zeno: An Automated Prover for Properties of Recursive Data Structures. In TACAS.Google ScholarGoogle Scholar
  46. M. Sousa and I. Dillig. 2016. Cartesian hoare logic for verifying k-safety properties. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. P. Suter, M. Dotta, and V. Kuncak. 2010. Decision Procedures for Algebraic Data Types with Abstractions. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. P. Suter, A. Sinan Köksal, and V. Kuncak. 2011. Satisfiability Modulo Recursive Programs. In SAS. Google ScholarGoogle ScholarCross RefCross Ref
  49. N. Swamy, C. Hriţcu, C. Keller, A. Rastogi, A. Delignat-Lavaud, S. Forest, K. Bhargavan, C. Fournet, P. Y. Strub, M. Kohlweiss, J. K. Zinzindohoue, and S. Zanella-Béguelin. 2016. Dependent Types and Multi-Monadic Effects in F*. In POPL.Google ScholarGoogle Scholar
  50. G. Tourlakis. 2008. Ackermann’s Function. (2008). http://www.cs.yorku.ca/~gt/papers/Ackermann-function.pdf .Google ScholarGoogle Scholar
  51. N. Vazou, L. Lampropoulos, and J. Polakow. 2017a. A Tale of Two Provers: Verifying Monoidal String Matching in Liquid Haskell and Coq. In Haskell.Google ScholarGoogle Scholar
  52. N. Vazou, P. Rondon, and R. Jhala. 2013. Abstract Refinement Types. In ESOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. N. Vazou, E. L. Seidel, R. Jhala, D. Vytiniotis, and S. L. Peyton-Jones. 2014. Refinement Types for Haskell. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. N. Vazou, A. Tondwalkar, V. Choudhury, R. G. Scott, R. R. Newton, P. Wadler, and R. Jhala. 2017b. Extended Version: Refinement Reflection: Complete Verification with SMT. (2017). https://nikivazou.github.io/static/popl18/ extended-refinement-reflection.pdfGoogle ScholarGoogle Scholar
  55. P. Vekris, B. Cosman, and R. Jhala. 2016. Refinement types for TypeScript. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. D. Vytiniotis, S. L. Peyton-Jones, K. Claessen, and D. Rosén. 2013. HALO: Haskell to Logic through Denotational Semantics. In POPL.Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. P. Wadler. 1987. A Critique of Abelson and Sussman or Why Calculating is Better Than Scheming. In SIGPLAN Not. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. P. Wadler. 2015. Propositions As Types. In Communications of the ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. H. Xi and F. Pfenning. 1998. Eliminating Array Bound Checking Through Dependent Types. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Refinement reflection: complete verification with SMT

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader