Skip to content

Commit

Permalink
Fix dirent proof
Browse files Browse the repository at this point in the history
  • Loading branch information
tchajed committed Jan 12, 2024
1 parent 7889de0 commit efc002d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/fs/dir/dirent.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,24 @@ module DirEntries
decode_null_terminated(s)
}

lemma {:induction s1} decode_nullterm_prefix(s1: seq<byte>, s2: seq<byte>)
// NOTE: without induction false, performance is awful
lemma {:induction false} decode_nullterm_prefix(s1: seq<byte>, s2: seq<byte>)
decreases |s1|
requires forall i | 0 <= i < |s1| :: s1[i] != 0
ensures decode_null_terminated(s1 + s2) == s1 + decode_null_terminated(s2)
{
if s1 == [] {
assert s1 + s2 == s2;
} else {
assert (s1 + s2)[1..] == s1[1..] + s2;
assert s1[0] != 0 as byte;
calc {
decode_null_terminated(s1 + s2);
[(s1 + s2)[0]] + decode_null_terminated((s1 + s2)[1..]);
{ assert (s1 + s2)[1..] == s1[1..] + s2; }
[s1[0]] + decode_null_terminated(s1[1..] + s2);
{ decode_nullterm_prefix(s1[1..], s2); }
s1 + decode_null_terminated(s2);
}
}
}

Expand Down

0 comments on commit efc002d

Please sign in to comment.