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

Suggest changes that could reduce brittleness #5259

Open
atomb opened this issue Mar 27, 2024 · 1 comment
Open

Suggest changes that could reduce brittleness #5259

atomb opened this issue Mar 27, 2024 · 1 comment
Assignees
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny

Comments

@atomb
Copy link
Member

atomb commented Mar 27, 2024

Summary

When there are changes that could potentially reduce brittleness, but aren't guaranteed to, it would be useful to have unobtrusive suggestions to help Dafny programmers more quickly learn what code patterns are often at fault in creating brittle verification.

Background and Motivation

Brittleness is a regular challenge in Dafny verification, and can sometimes block the development process indefinitely while trying to refactor code into a form that will verify.

Sometimes the reasons for brittleness are straightforward. Issue #5253 proposes a feature to warn about situations that essentially always lead to brittleness. However, sometimes the reasons are not as straightforward, and certain code changes may be helpful in one instance but unnecessary (or even detrimental) in others. When there are changes that would often help reduce brittleness, but aren't guaranteed to, it would be helpful to be able to quickly learn what they are when brittleness arises, or to use them to refactor code in advance when worried about brittleness arising.

Proposed Feature

Provide suggestions about how to refactor code to reduce brittleness when the following patterns occur:

  • Functions with ensures clauses (and suggest moving them to lemmas)
  • Transparent functions (and suggest using --default-function-transparency, making them opaque, or using current or future features that provide more fine-grained control over transparency)
  • Contract clauses without labels (and suggest labeling them)
  • Subset types with transparent/inline predicates (and suggest moving them to opaque functions or making them opaque inline if we implement a feature for doing that)

This would be enabled with a flag --suggest-brittleness-reduction. At the CLI, it would print textual messages pointing to the code in question and describing how one might want to refactor it. In the IDE, it would result in an unobtrusive dotted line under the relevant pieces of code that would show the same message when hovering over.

Alternatives

Like #5253, these suggestions could be static, in a document. But, like #5253, direct, active feedback, as long as it isn't obtrusive, would help accelerate the process.

@atomb atomb added the kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny label Mar 27, 2024
@atomb atomb self-assigned this Mar 27, 2024
@keyboardDrummer
Copy link
Member

Provide suggestions about how to refactor code to reduce brittleness when the following patterns occur:

I feel like each of the listed items warrants its own discussion. I suggest having separate GH issues for them.

For example, looking at Contract clauses without labels (and suggest labeling them). Am I correctly understanding that each ensures clause can have a label? If so then I wonder:

  • Why does the contract have multiple ensures clauses? If it's a lemma, why is it not split into two lemmas?
  • What if the contract has only a single ensures clause but a conjunction, so only one label can be given? Should it be possible to label sub-expressions?
  • If it's a function with multiple ensures clauses, what's the point of having this suggestion if we're driving towards functions without ensures clauses anyways?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
Projects
None yet
Development

No branches or pull requests

2 participants