Giter Club home page Giter Club logo

domains's Introduction

Domains Build status Build status

Toy language to help experiment with numerical domains for abstract interpretation. The language is inspired by the following book:

  Rival, Xavier, and Kwangkeun Yi. Introduction to static analysis: an abstract interpretation perspective. Mit Press, 2020.

The goal is to build a framework that helps experimenting with numerical domains and static analysis methods to infer which regions in the 2D space are reachable by the programs written in the graphical language. To get basic syntax highlight for the language install utils/ide/trlang/trlang.vsix extension to VS code.

This project is discontinued, a more advanced version written in Rust is available here.

Running the interpreter

Consider the following example program from the book:

init(50, 50, 50, 50);
translation(10, 0);
iter {
  { translation(10, 0) } or { rotation(0, 0, 90) }
}

Running ./domains example.tr --svg --executions 3 will output the SVG to the standard output that visualizes some execution traces of the program. An execution is defined as a random walk of the control flow graph.

Output:

Example output

Running the analyzer

Consider the following small program:

init(50, 50, 50, 50);
iter {
  {
    translation(10, 0)
  } or {
    translation(0, 10)
  }
};
rotation(0, 0, 180)

Running ./domains signDemo.tr --analyze sign will print out the same program along with some annotations. The annotations will contain the facts that the analyzer was able to infer about the program. In this case, the output will be:

init(50, 50, 50, 50) /* { x: Positive, y: Positive } */;
iter {
  {
    translation(10, 0) /* { x: Positive, y: Positive } */
  } or {
    translation(0, 10) /* { x: Positive, y: Positive } */
  }
};
rotation(0, 0, 180) /* { x: Negative, y: Negative } */

Another example:

Running ./domains filename.tr --analyze interval on:

init(50, 50, 50, 50);
translation(10, 0);
iter {
  translation(10, 0)
}

will output:

init(50, 50, 50, 50) /* { x: [50, 100], y: [50, 100] } */;
translation(10, 0) /* { x: [60, 110], y: [50, 100] } */;
iter {
  translation(10, 0) /* { x: [70, inf], y: [50, 100] } */
}

Alternatively, we can visualize the analysis result along with some executions running ./domains filename.tr --analyze interval --svg --executions 10 --loopiness 5. The gray area represents the regions of the 2D space that the analysis deduced as reachable.

Interval example output

Dependencies

Build

  • Meson
  • C++20 compatible compiler
  • fmt
  • cairo (optional for svg output)

Test

  • gtest
  • turnt

domains's People

Contributors

xazax-hun avatar

Watchers

James Cloos avatar  avatar

domains's Issues

Support assertions

Add assertions about the current state in the tr language. This could provide an opportunity for static analysis to emit warnings when if an assertion might or will fail.

More elaborate command line option handling

  • The driver should be able to print more detailed diagnostics about the individual options.
  • We should automate some of the boilerplate adding a new option or use a library.
  • We should have bash autocompletion for options.
  • We should have abbreviations for the command line flags.

Support conditions in loop/alternative as an extension

If loops/alternatives could have condition expressions based on the state, it would be possible to demonstrate how narrowing works, and we could eliminate paths based on the analysis state. Moreover, it would be possible to experiment with path sensitive analysis and symbolic execution.

Add fixed-point iteration that works on the edges instead of the nodes

Imagine the following scenario in constant propagation:

B1   B2
  \   /
   B3

State:

  B1:  u: 1, v: 2 
  B2:  v: 1 u: 2

With the flat constant propagation lattice, after merging the state for B1 and B2 we would get u: Top, v: Top. But in case B3 is u + v, we could execute the transfer function both for the state in B1 and in B2, and merge after the transfer functions are executed.

Overall, we will execute the transfer functions more often, but will end up having better precision.

Introduce regression tests

Use lit test or a similar framework to also test the driver as it starts to accumulate non-trivial amount of code.

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.