ICE-Based Refinement Type Discovery for Higher-Order Functional Programs

We propose a method for automatically finding refinement types of higher-order function programs. Our method is an extension of the Ice framework of Garg et al. for finding invariants. In addition to the usual positive and negative samples in machine learning, their Ice framework uses implication constraints, which consist of pairs (x, y) such that if x satisfies an invariant, so does y. From these constraints, Ice infers inductive invariants effectively. We observe that the implication constraints in the original Ice framework are not suitable for finding invariants of recursive functions with multiple function calls. We thus generalize the implication constraints to those of the form ({x1,⋯,xk},y)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(\{x_1,\dots ,x_k\}, y)$$\end{document}, which means that if all of x1,⋯,xk\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$x_1,\dots ,x_k$$\end{document} satisfy an invariant, so does y. We extend their algorithms for inferring likely invariants from samples, verifying the inferred invariants, and generating new samples. We have implemented our method and confirmed its effectiveness through experiments.

[1]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

[2]  Naoki Kobayashi,et al.  Combining higher-order model checking with refinement type inference , 2019, PEPM@POPL.

[3]  Dan Roth,et al.  Learning invariants using decision trees and implication counterexamples , 2016, POPL.

[4]  Alexander Aiken,et al.  A Data Driven Approach for Algebraic Loop Invariants , 2013, ESOP.

[5]  Kenneth L. McMillan,et al.  Computing Relational Fixed Points using Interpolation , 2013 .

[6]  Andrei Voronkov,et al.  Finding Loop Invariants for Programs over Arrays Using a Theorem Prover , 2009, FASE.

[7]  Aaron R. Bradley,et al.  SAT-Based Model Checking without Unrolling , 2011, VMCAI.

[8]  Dirk Beyer,et al.  Tools and Algorithms for the Construction and Analysis of Systems: 25 Years of TACAS: TOOLympics, Held as Part of ETAPS 2019, Prague, Czech Republic, April 6–11, 2019, Proceedings, Part III , 2019, Lecture Notes in Computer Science.

[9]  Rupak Majumdar,et al.  HMC: Verifying Functional Programs Using Abstract Interpreters , 2011, CAV.

[10]  Naoki Kobayashi,et al.  Dependent type inference with interpolants , 2009, PPDP '09.

[11]  Cesare Tinelli,et al.  The Kind 2 Model Checker , 2016, CAV.

[12]  Dirk Beyer,et al.  Competition on Software Verification - (SV-COMP) , 2012, TACAS.

[13]  Tachio Terauchi Dependent types from counterexamples , 2010, POPL '10.

[14]  Nikolaj Bjørner,et al.  Z3: An Efficient SMT Solver , 2008, TACAS.

[15]  Nikolaj Bjørner,et al.  Generalized Property Directed Reachability , 2012, SAT.

[16]  Naoki Kobayashi,et al.  HoIce: An ICE-Based Non-linear Horn Clause Solver , 2018, APLAS.

[17]  Flemming Nielson,et al.  Principles of Program Analysis , 1999, Springer Berlin Heidelberg.

[18]  Viktor Kuncak,et al.  A Verification Toolkit for Numerical Transition Systems - Tool Paper , 2012, FM.

[19]  Nikolaj Bjørner,et al.  Horn Clause Solvers for Program Verification , 2015, Fields of Logic and Computation II.

[20]  Suresh Jagannathan,et al.  Learning refinement types , 2015, ICFP.

[21]  Alberto Pettorossi,et al.  Solving Horn Clauses on Inductive Data Types Without Induction , 2018, Theory and Practice of Logic Programming.

[22]  Naoki Kobayashi,et al.  Towards a scalable software model checker for higher-order programs , 2013, PEPM '13.

[23]  Yaron Minsky OCaml for the masses , 2011, CACM.

[24]  Naoki Kobayashi,et al.  Automating relatively complete verification of higher-order functional programs , 2013, POPL.

[25]  Alexander Aiken,et al.  From invariant checking to invariant inference using randomized search , 2014, Formal Methods Syst. Des..

[26]  Patrick Maxim Rondon,et al.  Liquid types , 2008, PLDI '08.

[27]  Suresh Jagannathan,et al.  Compositional and Lightweight Dependent Type Inference for ML , 2013, VMCAI.

[28]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

[29]  Naoki Kobayashi,et al.  ICE-Based Refinement Type Discovery for Higher-Order Functional Programs , 2018, Journal of Automated Reasoning.

[30]  Suresh Jagannathan,et al.  Dependent Array Type Inference from Tests , 2015, VMCAI.

[31]  Barbara König,et al.  Tools and Algorithms for the Construction and Analysis of Systems , 2012, Lecture Notes in Computer Science.

[32]  Sagar Chaki,et al.  SMT-based model checking for recursive programs , 2014, Formal Methods in System Design.

[33]  Grigory Fedyukovich,et al.  Solving Constrained Horn Clauses Using Syntax and Data , 2018, 2018 Formal Methods in Computer Aided Design (FMCAD).

[34]  Christof Löding,et al.  ICE: A Robust Framework for Learning Invariants , 2014, CAV.

[35]  Suresh Jagannathan,et al.  A data-driven CHC solver , 2018, PLDI.

[36]  Naoki Kobayashi,et al.  Automatic Termination Verification for Higher-Order Functional Programs , 2014, ESOP.

[37]  Suresh Jagannathan,et al.  Automatically learning shape specifications , 2016, PLDI.

[38]  Alexander Aiken,et al.  Verification as Learning Geometric Concepts , 2013, SAS.

[39]  Sanjeev Arora,et al.  Computational Complexity: A Modern Approach , 2009 .