Refinement Type Inference via Horn Constraint Optimization

We propose a novel method for inferring refinement types of higher-order functional programs. The main advantage of the proposed method is that it can infer maximally preferred (i.e., Pareto optimal) refinement types with respect to a user-specified preference order. The flexible optimization of refinement types enabled by the proposed method paves the way for interesting applications, such as inferring most-general characterization of inputs for which a given program satisfies (or violates) a given safety (or termination) property. Our method reduces such a type optimization problem to a Horn constraint optimization problem by using a new refinement type system that can flexibly reason about non-determinism in programs. Our method then solves the constraint optimization problem by repeatedly improving a current solution until convergence via template-based invariant generation. We have implemented a prototype inference system based on our method, and obtained promising results in preliminary experiments.

[1]  Daniel Larraz,et al.  Proving Non-termination Using Max-SMT , 2014, CAV.

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

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

[4]  Naoki Kobayashi,et al.  On-Demand Refinement of Dependent Types , 2008, FLOPS.

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

[6]  Albert Oliveras,et al.  On SAT Modulo Theories and Optimization Problems , 2006, SAT.

[7]  Naoki Kobayashi,et al.  Predicate Abstraction and CEGAR for Disproving Termination of Higher-Order Functional Programs , 2015, CAV.

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

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

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

[11]  Peter W. O'Hearn,et al.  Proving Nontermination via Safety , 2014, TACAS.

[12]  Jürgen Giesl,et al.  Proving Non-looping Non-termination Automatically , 2012, IJCAR.

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

[14]  Sumit Gulwani,et al.  SPEED: precise and efficient static estimation of program computational complexity , 2009, POPL '09.

[15]  Andrey Rybalchenko,et al.  Solving Existentially Quantified Horn Clauses , 2013, CAV.

[16]  Henny B. Sipma,et al.  Linear Invariant Generation Using Non-linear Constraint Solving , 2003, CAV.

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

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

[19]  Sumit Gulwani,et al.  Program analysis as constraint solving , 2008, PLDI '08.

[20]  Naoki Kobayashi,et al.  Predicate abstraction and CEGAR for higher-order model checking , 2011, PLDI '11.