dafny-lang / dafny

Dafny is a verification-aware programming language
https://dafny.org
Other
2.88k stars 256 forks source link

Documentation: hard to figure out how to run Boogie manually #1153

Open tchajed opened 3 years ago

tchajed commented 3 years ago

For debugging particularly tricky problems I think at some point you need to drop down to the Boogie level. Currently it's kind of tricky to run the same version of Boogie that Dafny is using, because it seems to call it via a DLL. Would it be possible to expose it? Or at least point to Boogie installation instructions?

When I did go and follow the Boogie installation instructions I also had to get the .NET 3.1 runtime because Dafny is using .NET 5 and Boogie wasn't compatible with it - that might just be a separate Boogie issue.

RustanLeino commented 3 years ago

I do this all the time when debugging Dafny itself. It is doable and simple--once you know how. :/ It would be good to document this. Here is a start to that documentation:

tchajed commented 3 years ago

This documentation looks great to me, thanks Rustan! I didn't know about the default Boogie options but that does seem important.

hmijail commented 4 months ago

I'm looking into using Axiom Profiler to try to help improve verification times. Given the changing Dafny / Boogie interface, plus functionalities like Dafny's --isolate-assertions, --random-seed, it'd be great to have more clarity on how to get insight into a reproducible end-to-end verification - from Dafny code to Z3 proof log.

Or even, would it be possible to have an option for the toolchain to dump the proper intermediate products it generated?

Currently I'm making do with dafny's --bprint (marked as internal), and then trying various boogie / z3 options until something seems to work. But I think that in this way I am losing most of the work already done by dafny itself, plus possibly butchering the whole thing, let alone getting something reproducible.

keyboardDrummer commented 3 months ago

I'm looking into using Axiom Profiler to try to help improve verification times. Given the changing Dafny / Boogie interface, plus functionalities like Dafny's --isolate-assertions, --random-seed, it'd be great to have more clarity on how to get insight into a reproducible end-to-end verification - from Dafny code to Z3 proof log.

Or even, would it be possible to have an option for the toolchain to dump the proper intermediate products it generated?

Currently I'm making do with dafny's --bprint (marked as internal), and then trying various boogie / z3 options until something seems to work. But I think that in this way I am losing most of the work already done by dafny itself, plus possibly butchering the whole thing, let alone getting something reproducible.

How far do you get with the information @RustanLeino provided above?

Or even, would it be possible to have an option for the toolchain to dump the proper intermediate products it generated?

Next step could be that --bprint also prints out a boogie CLI invocation that uses the correct arguments, although that is somewhat surprising not too easy to generate from Dafny's programmatic use of Boogie :-)

hmijail commented 3 months ago

How far do you get with the information @RustanLeino provided above?

As it is, I think the only information that still kinda-works is the /print / --bprint.

As for boogie options, I already have a set of options that "generate something" after experimenting with the (even more outdated) info at AxiomProfiler Dafny wiki page. Then I found this issue, but realized that the mentioned ApplyDefaultOptions() and SetZ3Options() links are dead in the current tree, so I thought better to ask instead of keeping blindly trying even more options.

For a concrete example: I couldn't find a difference between what is --bprinted with and without --isolate-assertions - nor any other option to carry forward those isolated assertions down the chain. For example, would it be similar to using the @PROC@ boogie macros, as in /proverOpt:LOG_FILE=input-@PROC@.log? Looks like it might, but feels wrong to be reverse-engineering this kind of thing.

keyboardDrummer commented 3 months ago

For a concrete example: I couldn't find a difference between what is --bprinted with and without --isolate-assertions - nor any other option to carry forward those isolated assertions down the chain.

--isolate-assertions becomes /vcsSplitOnEveryAssert in Boogie.

hmijail commented 3 months ago

My use case is that I have an interesting run of e.g. dafny measure-complexity [--isolate-assertions] --random-seed X --iterations 10 --log json myfile.dfy , where one specific function (or Assertion Batch) with a specific Random Seed failed to verify. Let's say I want to examine what's going on in Axiom Profiler. How can one drill into that function (or AB) and RS down to the z3 proof log?

I can see /vcsSplitOnEveryAssert being one piece of the puzzle, but is that all? For example, the Dafny reference manual mentions that the randomness is automatically implemented by modifying details of the source code. Does that happen in Dafny (and then I need a bpl file specific to the RS), or does that happen in Boogie (and then I only need to pass the RS to Boogie together with the generic bpl)?

My basic assumption is that by narrowing down the scope at the dafny level I will have an easier time in Axiom Profiler. The mentions of boogie's /proc imply the same. But maybe AP really requires good understanding of the whole dafny-boogie-z3 transformations, and then asking for help at the dafny level makes no sense?

keyboardDrummer commented 3 months ago

My use case is that I have an interesting run of e.g. dafny measure-complexity [--isolate-assertions] --random-seed X --iterations 10 --log json myfile.dfy , where one specific function (or Assertion Batch) with a specific Random Seed failed to verify

Our advice is to debug such problems at the Dafny level. Here's a piece of documentation that can help with that: https://dafny.org/dafny/DafnyRef/DafnyRef#sec-brittle-verification It links to two other pages that contain most of the information, so be sure to check those out.

I can see /vcsSplitOnEveryAssert being one piece of the puzzle, but is that all? For example, the Dafny reference manual mentions that the randomness is automatically implemented by modifying details of the source code. Does that happen in Dafny (and then I need a bpl file specific to the RS), or does that happen in Boogie (and then I only need to pass the RS to Boogie together with the generic bpl)?

That happens in Boogie, although I'm only 50% sure that passing the RS to Boogie will give the same results.