628 research outputs found
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.Comment: 19 page
A Relational Logic for Higher-Order Programs
Relational program verification is a variant of program verification where
one can reason about two programs and as a special case about two executions of
a single program on different inputs. Relational program verification can be
used for reasoning about a broad range of properties, including equivalence and
refinement, and specialized notions such as continuity, information flow
security or relative cost. In a higher-order setting, relational program
verification can be achieved using relational refinement type systems, a form
of refinement types where assertions have a relational interpretation.
Relational refinement type systems excel at relating structurally equivalent
terms but provide limited support for relating terms with very different
structures.
We present a logic, called Relational Higher Order Logic (RHOL), for proving
relational properties of a simply typed -calculus with inductive types
and recursive definitions. RHOL retains the type-directed flavour of relational
refinement type systems but achieves greater expressivity through rules which
simultaneously reason about the two terms as well as rules which only
contemplate one of the two terms. We show that RHOL has strong foundations, by
proving an equivalence with higher-order logic (HOL), and leverage this
equivalence to derive key meta-theoretical properties: subject reduction,
admissibility of a transitivity rule and set-theoretical soundness. Moreover,
we define sound embeddings for several existing relational type systems such as
relational refinement types and type systems for dependency analysis and
relative cost, and we verify examples that were out of reach of prior work.Comment: Submitted to ICFP 201
Refinement type equations and Grincevičjus series
AbstractWe consider L1-solutions of the following refinement type equationsf(x)=∑n∈Zcn,1f(kx−n)+∑n∈Zcn,−1f(−kx−n), where k⩾2 is an integer and for all n∈Z reals cn,1, cn,−1 are non-negative with ∑n∈Z(cn,1+cn,−1)=k and ∑n∈Zlog|n|(cn,1+cn,−1)<+∞. Necessary and sufficient conditions for the existence of non-trivial L1-solutions in several special cases are given
Answer Refinement Modification: Refinement Type System for Algebraic Effects and Handlers
Algebraic effects and handlers are a mechanism to structure programs with
computational effects in a modular way. They are recently gaining popularity
and being adopted in practical languages, such as OCaml. Meanwhile, there has
been substantial progress in program verification via refinement type systems.
However, thus far, there has not been a satisfactory refinement type system for
algebraic effects and handlers. In this paper, we fill the void by proposing a
novel refinement type system for algebraic effects and handlers. The
expressivity and usefulness of algebraic effects and handlers come from their
ability to manipulate delimited continuations, but delimited continuations also
complicate programs' control flow and make their verification harder. To
address the complexity, we introduce a novel concept that we call answer
refinement modification (ARM for short), which allows the refinement type
system to precisely track what effects occur and in what order when a program
is executed, and reflect the information as modifications to the refinements in
the types of delimited continuations. We formalize our type system that
supports ARM (as well as answer type modification) and prove its soundness.
Additionally, as a proof of concept, we have implemented a corresponding type
checking and inference algorithm for a subset of OCaml 5, and evaluated it on a
number of benchmark programs. The evaluation demonstrates that ARM is
conceptually simple and practically useful. Finally, a natural alternative to
directly reasoning about a program with delimited continuations is to apply a
continuation passing style (CPS) transformation that transforms the program to
a pure program. We investigate this alternative, and show that the approach is
indeed possible by proposing a novel CPS transformation for algebraic effects
and handlers that enjoys bidirectional (refinement-)type-preservation.Comment: 66 page
Inhomogeneous poly-scale refinement type equations and Markov operators with perturbations
Given measure spaces (Ω1,A1,μ1), . . . , (ΩN,AN,μN), functions φ1 : Rm×Ω1 Rm, . . . ,φN : Rm×ΩN Rm and g : Rm R, we present results on the existence of solutions f : Rm R of the inhomogeneous poly-scale refinement type equation of the form f(x) = ΣN n=1 ∫ Ωn det(φn)′x(x, ωn) f (φn(x, ωn)) dμn(ωn) + g(x)
in some special classes of functions. The results are obtained by Banach fixed point theorem applied to a perturbed Markov operator connected with the considered inhomogeneous poly-scale refinement type equation.
Mathematics Subject Classification. Primary 37H99, 37N99; Secondary 39B12
Refinement type contracts for verification of scientific investigative software
Our scientific knowledge is increasingly built on software output. User code
which defines data analysis pipelines and computational models is essential for
research in the natural and social sciences, but little is known about how to
ensure its correctness. The structure of this code and the development process
used to build it limit the utility of traditional testing methodology. Formal
methods for software verification have seen great success in ensuring code
correctness but generally require more specialized training, development time,
and funding than is available in the natural and social sciences. Here, we
present a Python library which uses lightweight formal methods to provide
correctness guarantees without the need for specialized knowledge or
substantial time investment. Our package provides runtime verification of
function entry and exit condition contracts using refinement types. It allows
checking hyperproperties within contracts and offers automated test case
generation to supplement online checking. We co-developed our tool with a
medium-sized (3000 LOC) software package which simulates
decision-making in cognitive neuroscience. In addition to helping us locate
trivial bugs earlier on in the development cycle, our tool was able to locate
four bugs which may have been difficult to find using traditional testing
methods. It was also able to find bugs in user code which did not contain
contracts or refinement type annotations. This demonstrates how formal methods
can be used to verify the correctness of scientific software which is difficult
to test with mainstream approaches
Mechanizing Refinement Types (extended)
Practical checkers based on refinement types use the combination of implicit
semantic sub-typing and parametric polymorphism to simplify the specification
and automate the verification of sophisticated properties of programs. However,
a formal meta-theoretic accounting of the soundness of refinement type systems
using this combination has proved elusive. We present \lambda_RF a core
refinement calculus that combines semantic sub-typing and parametric
polymorphism. We develop a meta-theory for this calculus and prove soundness of
the type system. Finally, we give a full mechanization of our meta-theory using
the refinement-type based LiquidHaskell as a proof checker, showing how
refinements can be used for mechanization.Comment: 32 pages, under revie
- …