Skip to content

Commit a8c640a

Browse files
Merge branch 'main' into TestExecuteStatement
2 parents 1a4901d + 0ebc112 commit a8c640a

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/src/FilterExpr.dfy

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,42 +1109,10 @@ module DynamoDBFilterExpr {
11091109
1 + StringsFollowing(input[..|input|-1])
11101110
}
11111111

1112-
// generic version should be moved back to standard library
1113-
method HasSubString<T(==)>(haystack: seq<T>, needle: seq<T>)
1114-
returns (o: Wrappers.Option<nat>)
1115-
1116-
ensures o.Some? ==>
1117-
&& o.value <= |haystack| - |needle| && haystack[o.value..(o.value + |needle|)] == needle
1118-
&& (forall i | 0 <= i < o.value :: haystack[i..][..|needle|] != needle)
1119-
1120-
ensures |haystack| < |needle| ==> o.None?
1121-
1122-
ensures o.None? && |needle| <= |haystack| && |haystack| <= (UINT64_MAX_LIMIT-1) ==>
1123-
(forall i | 0 <= i <= (|haystack|-|needle|) :: haystack[i..][..|needle|] != needle)
1124-
{
1125-
SequenceIsSafeBecauseItIsInMemory(haystack);
1126-
SequenceIsSafeBecauseItIsInMemory(needle);
1127-
if |haystack| as uint64 < |needle| as uint64 {
1128-
return Wrappers.None;
1129-
}
1130-
1131-
var size : uint64 := |needle| as uint64;
1132-
var limit: uint64 := Add(|haystack| as uint64 - size, 1);
1133-
1134-
for index := 0 to limit
1135-
invariant forall i | 0 <= i < index :: haystack[i..][..size] != needle
1136-
{
1137-
if Sequence.SequenceEqual(seq1 := haystack, seq2 := needle, start1 := index, start2 := 0, size := size) {
1138-
return Wrappers.Some(index as nat);
1139-
}
1140-
}
1141-
return Wrappers.None;
1142-
}
1143-
11441112
// true if haystack contains needle
11451113
method seq_contains<T(==)>(haystack : seq<T>, needle : seq<T>) returns (ret : bool)
11461114
{
1147-
var result := HasSubString(haystack, needle);
1115+
var result := String.HasSubString(haystack, needle);
11481116
return result.Some?;
11491117
}
11501118

0 commit comments

Comments
 (0)