When there are two or more array input parameters in a method #2158
-
Hi all, I'm a new user of Dafny. I have a question and hope to get help. Thanks. When a
The assertion above might not hold. The counter-example given shows that the two arrays may be equal. (1) When a (2) I didn't write |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @dreamqin68 , |
Beta Was this translation helpful? Give feedback.
Hello @dreamqin68 ,
This is a very nice demonstration of how Dafny can prevent aliasing errors, thanks !
(1) What you did is correct, you either have to add
a != b
as a precondition, or wrap the assignment in aif a != b { ... }
construct.(2) I tried to replace
b[0] := element;
bya[0] := element;
but it correctly indicatesassignment might update an array element not in the enclosing context's modifies clause
. Can you please detail your example?