Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design by contract for python #147

Open
adsharma opened this issue Aug 13, 2021 · 2 comments
Open

Design by contract for python #147

adsharma opened this issue Aug 13, 2021 · 2 comments

Comments

@adsharma
Copy link

adsharma commented Aug 13, 2021

I was not aware of Nagini or Viper work when I wrote this:

https://adsharma.github.io/pysmt/

I worked on https://github.com/adsharma/py2many/ - a transpiler in the past and am looking into adding some static verification capabilities before generating code in other languages such as C++ and Rust.

A few questions:

  • Can the Nagini/Viper/Boogie/Z3 stack be collapsed to: a subset of python -> z3?
  • I'm looking to build a boogie like thing with pythonic syntax (linked in the blog post above). I read something about B-SMT in a ETH paper. Agree that infix syntax is more human readable.
  • Can we maintain compatibility of input source with python3? In my proposal, if smt.pre would evaluate to False and python interpreter ignores that block. I like requires/ensures better than pre/post.
  • Datatypes: I've built something using @sealed for py2many. Perhaps we can reuse it.
  • Can we use python as the intermediate language instead of viper?

Let me know if any of this sounds interesting.

@marcoeilers
Copy link
Owner

I think this is a bit difficult to discuss in Github comments (I'm not sure I completely understand all of your questions, and some of my answers would be rather long as well); if you'd be interested, we could have a quick chat about this on Skype/Zoom/... instead?

@adsharma
Copy link
Author

py2many/py2many#443 is a demo of translating a python ADT that uses the @Sealed syntax to z3 -smt2 compatible format.

Also edited the text above for legibility.

The flow I'm thinking about is:

  1. static python
  2. contract python - no spec yet, but this will be a different subset of python
  3. smt2 sexpression accepted by z3 -smt2

(1) -> py2many -verify -> (2) -> py2many --smt=1 -> (3) (proceed to next step only after verification)
(1) -> py2many -> C++/Rust/Go -> Verified executable

I'll email you to coordinate an in person chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants