Skip to content

Evaluate impact of folding definitions#417

Draft
jcp19 wants to merge 6 commits into
masterfrom
claude/awesome-keller-ciZwp
Draft

Evaluate impact of folding definitions#417
jcp19 wants to merge 6 commits into
masterfrom
claude/awesome-keller-ciZwp

Conversation

@jcp19
Copy link
Copy Markdown
Collaborator

@jcp19 jcp19 commented May 26, 2026

No description provided.

claude added 3 commits May 26, 2026 12:20
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.
@jcp19 jcp19 changed the title Claude/awesome keller ci zwp Evaluate impact of folding definitions May 26, 2026
claude added 3 commits May 26, 2026 13:10
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants