Code Monkey home page Code Monkey logo

intensional-constraints's Introduction

Intensional Constraints

This repository is depreciated! Check out the latest version here

The pattern-match safety problem is to verify that a given functional program will never crash due to nonexhaustive patterns in its function definitions. This tool is designed to prevent this type of crash.

For each top-level definition a set of constraints are inferred, these are both flow and context sensitive. The constraints are in terms of refinement variables which approximately refer to a single point in the function definition.

Usage

The tool is a plugin for GHC, and therefore directly integrated into the compilation processes. To add this analysis as another stage to compilation:

  1. Download this repository
  2. Add path/to/intensional-constraints to your cabal.project file in the ``packages` stanza
  3. Add -fplugin=Lib to the ghc-options field, and intensional-constraints to the build-depends field.

Troubleshooting

As this is only a prototype tool, it's interface and deployment is underdeveloped. If you wish to run the tool on a package which it depends, i.e. the containers pacakge, cabal will consider this case as a cyclic dependency. To circumnavigate this issue we recommend changing the name of the package on which you wish to run the tool, or holding out for a better interface!

The Taxonomy of Constraints

The constraints produced by analysis have two components: a guard (on the left of the question mark), and the body on the right, corresponding to context sensitivity and flow sensitivity respectively.

  • k in X ? X >- Y

As it stands there is no explicit error reporting, however, unsatisfiable constraints are immediately identifiable:

  • k in {}

intensional-constraints's People

Contributors

sjrsay avatar ec-jones avatar

Watchers

 avatar  avatar

Forkers

mpickering

intensional-constraints's Issues

Bug in constraint generation

I think there is a bug in constraint generation which is exposed by the function f in the SetsForVariants.hs test. The output from my branch (which has pull requests #3 and #4 merged) is:

(f, forall 12.inj_12 T -> inj_15 T where ? inj_12 T >- {A | B})

If I turn off saturation so that the generated constraints only are present:

(f,
 forall 12 13 14 15 16 17 18 19 20 21 22 23 24 25.inj_12 T
                                                  ->
                                                  inj_15 T
   where
     ? inj_13 T >- {A | B}
     ? inj_17 T >- {A | B}
     [B] in inj_18 T ? inj_21 T >- {A | B}
     [C] in inj_18 T ? inj_24 T >- {A | B}
     ? inj_12 T >- inj_13 T
     [A] in inj_13 T ? inj_13 T >- inj_14 T
     [B] in inj_13 T ? inj_13 T >- inj_14 T
     [A] in inj_18 T ? inj_19 T >- inj_15 T
     [B] in inj_18 T ? inj_22 T >- inj_15 T
     [C] in inj_18 T ? inj_25 T >- inj_15 T
     ? inj_16 T >- inj_17 T
     [A] in inj_17 T ? inj_17 T >- inj_18 T
     [B] in inj_17 T ? inj_17 T >- inj_18 T
     [A] in inj_18 T ? B >- inj_19 T
     [B] in inj_18 T ? inj_20 T >- inj_21 T
     [B] in inj_18 T, [A] in inj_21 T ? inj_21 T >- inj_22 T
     [B] in inj_18 T, [B] in inj_21 T ? inj_21 T >- inj_22 T
     [C] in inj_18 T ? inj_23 T >- inj_24 T
     [C] in inj_18 T, [A] in inj_24 T ? inj_24 T >- inj_25 T
     [C] in inj_18 T, [B] in inj_24 T ? inj_24 T >- inj_25 T)

which I don't think will saturate correctly. We need something like 13 T >- 16 T.

I think the h function from the same test also suffers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.