-
Notifications
You must be signed in to change notification settings - Fork 3
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
Faulty Selection sort verification #37
Comments
The specification only checks that the algorithm preserves all elements |
Good catch! I think the following is a fix.
@stefan-aws could you double check? This may or may not be the right fix to use for the blog post. If it is, next step will be to go back to the blog post and update accordingly. |
@atomb This is a striking example of a spectacular specification failure, do you know if the auditor would have flagged this? |
This is a really interesting example! The auditor wouldn't detect this, but the proof dependency analysis almost would. Say you rewrite the ensures clause into two, like so: method SelectionnSort(a: array<int>)
modifies a
ensures Ordered(a,0,a.Length)
ensures Preserved(a,0,a.Length)
{ If you then run
This indicates that the only thing used to prove the We currently warn about a proof of an assertion/postcondition that does not depend on the assertion itself, because that means it was proved vacuously. We don't warn, however, for a proof that depends only on the assertion being proved. For inline assertions, there may be legitimate situations where the proof is self-contained -- where the predicate is a tautology. For a postcondition, however, I think the situation almost certainly indicates a mistake. We should implement that check. |
blog/assets/src/insertion-sort/VerifiedInt.dfy
Line 8 in 6069d9b
blog/assets/src/insertion-sort/VerifiedInt.dfy
Line 34 in 6069d9b
blog/assets/src/insertion-sort/VerifiedInt.dfy
Line 50 in 6069d9b
They way the
Ordered
predicate is specified and then used makes it trivially true.Ordered(a,0,a.Length)
leaves us with0 < 0
in the left-hand side of the implication.The text was updated successfully, but these errors were encountered: