Evaluate impact of folding definitions#417
Draft
jcp19 wants to merge 6 commits into
Draft
Conversation
Prevent git from CRLF-normalizing binary files (corrupting PNGs etc.) and preserve CRLF for .bat files. Renormalize doc/make.bat blob.
Python rewriter that inlines the `Bytes` predicate at every call site: - Replaces `sl.Bytes(s, a, b)` / `slices.Bytes(...)` / bare `Bytes(...)` with the predicate body, parenthesised. - Propagates fractions through `acc(Bytes(...), p)`. - Deletes statement-level `fold` / `unfold` lines. - Collapses `unfolding Bytes(...) in e` to `e`. - In .go files, only rewrites inside Gobra annotations (`// @` and `/*@ ... @*/`). - `--specs-only` skips function bodies (used for slices.gobra where the helpers' own bodies must continue to use the predicate).
Run tools/inline_bytes.py over the verified spec surface (router/, pkg/, private/, verification/). The `Bytes` predicate is no longer named in caller specs; each invocation has been replaced by its body, with fractions propagated through enclosing `acc(...)` and statement-level fold/unfold lines removed. The predicate definition itself stays in verification/utils/slices/slices.gobra so the helper functions (SplitByIndex_Bytes, CombineAtIndex_Bytes, Reslice_Bytes, ...) can continue to fold/unfold it internally; only those helpers' specs were rewritten, not their bodies.
The previous pass only recognised bare `fold` / `unfold` at the start of an annotation line. Lines like `// @ ghost defer fold sl.Bytes(...)` and `// @ defer unfold acc(sl.Bytes(...), R21)` slipped through, leaving behind an inlined forall body where Gobra expected a predicate access (\"Translation of predicateAccess (0<=0&&...) failed\"). The line-deletion detector now skips optional `ghost ` and `defer ` prefixes before looking for `fold` / `unfold`. Reran the rewriter on the six affected files.
The helper existed to provide a `Bytes(nil, 0, 0)` predicate instance.
After inlining, that instance becomes a body containing `cap(nil)` and
`&nil[i]`, which Gobra rejects ("expected an array or slice type, but
got nil"). The inlined assertion at caller sites is vacuously true
(the forall ranges over an empty interval), so the helper is no longer
useful.
Removed:
- func NilAcc_Bytes in verification/utils/slices/slices.gobra
- the 6 `sl.NilAcc_Bytes()` calls in router/dataplane.go
The helpers in verification/utils/slices/slices.gobra (and the test file)
were previously fold/unfolding the `Bytes` predicate internally to
discharge their own postconditions. With the specs now expressing the
predicate body inline, the predicate access isn't held when the body
runs, and Gobra rejected the `unfolding Bytes(...) in s[i]` form in
`GetByte` ("Permission to Bytes(s, start, end) might not suffice").
Reran the rewriter on slices.gobra / slices_test.gobra without
--specs-only to drop those fold/unfold/unfolding statements. The
asserts that establish address equivalences (Reslice_Bytes,
Unslice_Bytes loop, PermsImplyIneq*) are preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.