Skip to content

Commit

Permalink
Test if this is a typo in prelude (#3412)
Browse files Browse the repository at this point in the history
This PR fixes #3411 
Seems like one of Boogie's axiom was wrong, but it was unnoticed because
another application axiom was ignoring the wrong argument.
I added the test case of the issue.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
  • Loading branch information
MikaelMayer authored Jan 26, 2023
1 parent 97f1ced commit 5bd9203
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/DafnyCore/DafnyPrelude.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ axiom (forall ty: Ty, heap: Heap, len: int, init: HandleType ::
axiom (forall ty: Ty, heap: Heap, len: int, init: HandleType, i: int ::
{ Seq#Index(Seq#Create(ty, heap, len, init), i) }
$IsGoodHeap(heap) && 0 <= i && i < len ==>
Seq#Index(Seq#Create(ty, heap, len, init), i) == Apply1(TInt, TSeq(ty), heap, init, $Box(i)));
Seq#Index(Seq#Create(ty, heap, len, init), i) == Apply1(TInt, ty, heap, init, $Box(i)));

function Seq#Append<T>(Seq T, Seq T): Seq T;
axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) }
Expand Down
7 changes: 7 additions & 0 deletions Test/git-issues/git-issue-3411.dfy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %baredafny verify %args "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method Test(f: int -> int) {
assert seq(1, x => f(x))[0] == f(0); // No problem
assert seq(1, f)[0] == f(0); // No problem anymore
}
2 changes: 2 additions & 0 deletions Test/git-issues/git-issue-3411.dfy.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Dafny program verifier finished with 1 verified, 0 errors
1 change: 1 addition & 0 deletions docs/dev/news/3411.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an axiom related to sequence comprehension extraction

0 comments on commit 5bd9203

Please sign in to comment.