Skip to content

Commit

Permalink
Compatibility with Dafny 4.3, 4.4, and newer
Browse files Browse the repository at this point in the history
  • Loading branch information
atomb committed Jan 25, 2024
1 parent 84db322 commit e05139f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
verification:
strategy:
matrix:
version: [ 3.13.1, 4.0.0, 4.1.0, 4.2.0 ]
version: [ 3.13.1, 4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.4.0 ]

uses: ./.github/workflows/reusable-tests.yml
with:
Expand Down
4 changes: 2 additions & 2 deletions src/Collections/Sequences/MergeSort.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module {:options "-functionSyntax:4"} Seq.MergeSort {
import opened Relations

//Splits a sequence in two, sorts the two subsequences using itself, and merge the two sorted sequences using `MergeSortedWith`
function MergeSortBy<T>(a: seq<T>, lessThanOrEq: (T, T) -> bool): (result :seq<T>)
function MergeSortBy<T(!new)>(a: seq<T>, lessThanOrEq: (T, T) -> bool): (result :seq<T>)
requires TotalOrdering(lessThanOrEq)
ensures multiset(a) == multiset(result)
ensures SortedBy(result, lessThanOrEq)
Expand All @@ -31,7 +31,7 @@ module {:options "-functionSyntax:4"} Seq.MergeSort {
MergeSortedWith(leftSorted, rightSorted, lessThanOrEq)
}

function {:tailrecursion} MergeSortedWith<T>(left: seq<T>, right: seq<T>, lessThanOrEq: (T, T) -> bool) : (result :seq<T>)
function {:tailrecursion} MergeSortedWith<T(!new)>(left: seq<T>, right: seq<T>, lessThanOrEq: (T, T) -> bool) : (result :seq<T>)
requires SortedBy(left, lessThanOrEq)
requires SortedBy(right, lessThanOrEq)
requires TotalOrdering(lessThanOrEq)
Expand Down
24 changes: 12 additions & 12 deletions src/Collections/Sequences/Seq.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,11 @@ module {:options "-functionSyntax:4"} Seq {
}

/* inv(b, xs) ==> inv(FoldLeft(f, b, xs), []). */
lemma LemmaInvFoldLeft<A,B>(inv: (B, seq<A>) -> bool,
stp: (B, A, B) -> bool,
f: (B, A) -> B,
b: B,
xs: seq<A>)
lemma LemmaInvFoldLeft<A(!new),B(!new)>(inv: (B, seq<A>) -> bool,
stp: (B, A, B) -> bool,
f: (B, A) -> B,
b: B,
xs: seq<A>)
requires InvFoldLeft(inv, stp)
requires forall b, a :: stp(b, a, f(b, a))
requires inv(b, xs)
Expand Down Expand Up @@ -810,11 +810,11 @@ module {:options "-functionSyntax:4"} Seq {
}

/* inv([], b) ==> inv(xs, FoldRight(f, xs, b)) */
lemma LemmaInvFoldRight<A,B>(inv: (seq<A>, B) -> bool,
stp: (A, B, B) -> bool,
f: (A, B) -> B,
b: B,
xs: seq<A>)
lemma LemmaInvFoldRight<A(!new),B(!new)>(inv: (seq<A>, B) -> bool,
stp: (A, B, B) -> bool,
f: (A, B) -> B,
b: B,
xs: seq<A>)
requires InvFoldRight(inv, stp)
requires forall a, b :: stp(a, b, f(a, b))
requires inv([], b)
Expand Down Expand Up @@ -876,7 +876,7 @@ module {:options "-functionSyntax:4"} Seq {
}

/* Proves that any two sequences that are sorted by a total order and that have the same elements are equal. */
lemma SortedUnique<T>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool)
lemma SortedUnique<T(!new)>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool)
requires SortedBy(xs, R)
requires SortedBy(ys, R)
requires TotalOrdering(R)
Expand All @@ -896,7 +896,7 @@ module {:options "-functionSyntax:4"} Seq {
}

/* Converts a set to a sequence that is ordered w.r.t. a given total order. */
function SetToSortedSeq<T>(s: set<T>, R: (T, T) -> bool): (xs: seq<T>)
function SetToSortedSeq<T(!new)>(s: set<T>, R: (T, T) -> bool): (xs: seq<T>)
requires TotalOrdering(R)
ensures multiset(s) == multiset(xs)
ensures SortedBy(xs, R)
Expand Down
2 changes: 1 addition & 1 deletion src/Relations.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module {:options "-functionSyntax:4"} Relations {
max in s && forall x | x in s && R(max, x) :: R(x, max)
}

lemma LemmaNewFirstElementStillSortedBy<T>(x: T, s: seq<T>, lessThan: (T, T) -> bool)
lemma LemmaNewFirstElementStillSortedBy<T(!new)>(x: T, s: seq<T>, lessThan: (T, T) -> bool)
requires SortedBy(s, lessThan)
requires |s| == 0 || lessThan(x, s[0])
requires TotalOrdering(lessThan)
Expand Down

0 comments on commit e05139f

Please sign in to comment.