Giter Club home page Giter Club logo

uclid5-api's Introduction

uclid5-api

Installing

pip3 install . # use -e flag when developing

Usage Example

The following Python code

from uclid5_api import Module, induction, integer

m = Module("fib")
a = m.declare_var("a", integer())
b = m.declare_var("b", integer())
m.init.assign(a, 0)
m.init.assign(b, 1)
m.next.assign(a, b)
m.next.assign(b, a + b)
m.assert_invariant("b_gte_0", b >= 0)

print(m)

will print

module fib {
  var a: integer;
  var b: integer;
  init {
    a = 0;
    b = 1;
  }
  next {
    a' = b;
    b' = a + b;
  }
  invariant b_gte_0: b >= 0;
}

Testing

pipx run tox

Formatting

pipx run pre-commit run --all-files --show-diff-on-failure

Verification (EXPERIMENTAL)

You can attempt a proof-by-induction with the induction function.

m = Module("test")
x = m.declare_var("x", integer())

m.init.assign(x, 0)
then_, else_ = m.init.branch(x == 0)
then_.assign(x, x + 1)
else_.assign(x, x + 2)
m.init.assign(x, x * 7)

m.assert_invariant("x_eq_7", x == 7)
assert induction(m) is True

You can generate the SMT-LIB queries by giving the induction function a file name prefix, e.g., induction(m, "test").

uclid5-api's People

Contributors

federicoaureliano avatar

Watchers

 avatar

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.