Open cpitclaudel opened 2 years ago
Great, I'm so happy to see you figuring it out, because last october, I had the same bug, found out it was related to Lit not on some constructs of Seq, but I wasn't able later to reproduce this. It was on Seq#drop and Seq#length as well.
Dafny rejects the following code as of today:
Adding fuel using
{:fuel rsum, 10}
fixes the issue, but it should not be needed, because Dafny generates "free" reduction axioms for functions applied to literals. For example, this code verifies just fine:The problem becomes clear if you look at the generated axioms:
This is what happens with
sum
:But for
rsum
, the call toSeq#Take
is not marked asLit
:The problem is in the code that generates these axioms; specifically https://github.com/dafny-lang/dafny/blob/2b4b98072ebc13b71499a1de20d77aefde02f6c0/Source/Dafny/Verifier/Translator.ExpressionTranslator.cs#L723 does not propagate
Lit
pastSeq#Length
. Looking at the rest of the code, there are many more missing propagations — it's not just Seq#Length. Here is one other test, for example: