Giter Club home page Giter Club logo

pybelsberg's Introduction

pybelsberg

Build Status

An implementation of Babelsberg allowing constraint-based programming in Python (using the Z3 theorem prover).

See also Babelsberg/R, Babelsberg/JS.

It allows you to write code like the following:

from pybelsberg import always

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def distance(self, other):
        return math.sqrt((self.x - other.x)**2 + (self.y - other.y)**2)

a = Point(10.0, 0.0)
b = Point(0.0, 0.0)

# Declare a constraint that should always be satisfied
@always
def constant_distance():
    yield a.distance(b) == 20

print(a.x, a.y) # -> 20.0 0.0
print(b.x, b.y) # -> 0.0 0.0

a.x, a.y = 50.0
print(a.x, a.y) # -> 50.0 50.0
print(b.x, b.y) # -> 30.0 50.0

Setup

Pybelsberg requires Python version >= 3.3.

Z3 needs to be built from the unstable branch (using the provided instructions) because only this branch (as of August 2014) supports Python 3.x. Make sure the Z3 directory is in the PYTHONPATH.

Pybelsberg uses tox and py.test for testing.

Documentation

All of the supported functionality is covered by tests in the /tests directory. Files beginning with "demo" represent more complex use cases. All tests that are marked as "xfail" represent functionality that is not supported yet.

License

Pybelsberg is open-source and licensed under the BSD 3-Clause License.

pybelsberg's People

Contributors

lehmannro avatar timfel 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.