kenmcmil / ivy

IVy is a research tool intended to allow interactive development of protocols and their proofs of correctness and to provide a platform for developing and experimenting with automated proof techniques. In particular, IVy provides interactive visualization of automated proofs, and supports a use model in which the human protocol designer and the automated tool interact to expose errors and prove correctness.
Other
77 stars 24 forks source link

Translation from Ivy to mypyvy #76

Open dranov opened 8 months ago

dranov commented 8 months ago

This PR adds a method to automatically translate Ivy specifications to mypyvy.

This works by retrofitting the SMT-LIB generated by Ivy into mypyvy syntax, so the resulting mypyvy specifications are quite a bit uglier than those a human would write.

You invoke the method by adding attribute method = convert_to_mypyvy in the isolate that needs to be translated (or at the top-level of the Ivy file), and then invoke ivy_check on the file. When invoked with the convert_to_mypyvy method, ivy_check takes two (optional, default to false) arguments:

The converted mypyvy specification is generated in the directory in which ivy_check is invoked and takes the name of the Ivy specification, e.g. tpc.ivy becomes tpc.pyv.

In terms of implementation:

Due to how it works (by leveraging Ivy's translation to SMT-LIB), the translation should support all Ivy features and it should require little to no maintenance if/when the language evolves. I have tested this only with Ivy specifications with #lang ivy1.7 and #lang ivy1.8.

To give you a sense of what the output looks like, this Ivy specification is translated into this .pyv file.

dranov commented 8 months ago

This doesn't yet handle native integers in the Ivy spec.