Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use the right bitvector comparison in
ComputeLessEq
Dafny adds a free invariant on each loops that states that the loop variable is smaller than or equal to its initial value. For bitvectors, Dafny produced ≥ instead of ≤, possibly due to a typo? Specifically, the issue was: - In `Translator.TrStatement.cs` (`TrLoop`): ``` // include a free invariant that says that all completed iterations so far have only decreased the termination metric … Bpl.Expr decrCheck = DecreasesCheck(toks, types, types, decrs, initDecr, null, null, true, false); ``` - In `Translator.cs` (`DecreasesCheck`): ``` Bpl.Expr less, atmost, eq; ComputeLessEq(toks[i], types0[i], types1[i], ee0[i], ee1[i], out less, out atmost, out eq, includeLowerBound); ``` - In `Translator.cs` (`ComputeLessEq`): ``` } else if (ty0 is BitvectorType) { BitvectorType bv = (BitvectorType)ty0; eq = Bpl.Expr.Eq(e0, e1); less = FunctionCall(tok, "lt_bv" + bv.Width, Bpl.Type.Bool, e0, e1); atmost = FunctionCall(tok, "ge_bv" + bv.Width, Bpl.Type.Bool, e0, e1); ``` `"ge_bv"` is wrong. * `Source/Dafny/Verifier/Translator.cs` (`ComputeLessEq`): Change `ge` into `le`. * `Test/git-issues/git-issue-2511.dfy`: New file, showing the issue in all places where `ComputeLessEq` was used. Introduced in 3f899b9. Closes #2511.
- Loading branch information