Repository navigation
[WIP] kprove: apply the specification steps only to the spec's own modules - #4943
Draft
RaoulSchaffranek wants to merge 2528 commits into
Draft
RaoulSchaffranek wants to merge 2528 commits into
RaoulSchaffranek wants to merge 2528 commits into
Conversation
kprove applies the specification steps to the spec module and to every module it imports, which includes the whole kompiled definition. The definition modules are then replaced by their kompiled versions, so most of that work is discarded. The passes up to macro expansion still run on all modules, because macro expansion and ResolveFunctionWithConfig read the definition's macro and function rules in the form these passes give them, not in their kompiled form. Macro expansion and the later passes now skip the definition modules, which are replaced by their kompiled versions right after macro expansion. ModuleTransformer gets a `skipping` predicate: modules for which it holds are returned unchanged, together with their imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What is slow
kevm proveloads the claims of each spec file withkprove --dry-run --emit-json-spec(through pyk'sClaimLoader). On KEVM's CI this takes 18–37 s per spec file (median 24 s), about 4,000 s in total over KEVM's 159 spec files. Akprove --verboseprofile of one spec puts about three quarters of that time in the specification steps (KoreBackend.specificationSteps). These passes run on the spec module and on every module it imports, which for KEVM is the whole semantics. Right afterwards, every module of the kompiled definition is replaced by its kompiled version. So most of this work is thrown away.What this changes
propagateMacroToRulesstill run on all modules. Macro expansion andResolveFunctionWithConfigread the definition's macro rules and function rules in the form these passes give them. The kompiled form of those rules is different (for example, after constant folding, or after a function got its configuration argument), so it cannot be used instead.ModuleTransformergets askippingpredicate. A skipped module is returned unchanged, together with its imports.A first version replaced the definition modules before all passes. That changed the claims: a macro's right-hand side came out constant-folded, and calls to functions that use the configuration lost their configuration argument. It also changed the claims of one KEVM spec. This version keeps those passes on the definition modules.
What was checked
kprove --dry-run --emit-json-spec --allow-rules, called as pyk calls it. For 138 specs the JSON is byte-identical. For the other 21, the claims are identical but come out in a different order. Unpatchedkprovealready varies here: two unpatched runs give different claim orders for 42 of the 159 specs. The likely cause is thatAtt.Keyhashes a set ofClassobjects, whose hash codes change between JVM runs, and sentences are kept in hash sets.regression-new. All proof tests pass with the patchedkprove, as with the unpatched one: the 39 test directories with spec files thatmake proofsreaches, plus thepl-tutorialIMP++ proof (proof-testsis disabled). Their 244kprovecalls also emit the same claims (233 byte-identical, 11 in a different order).spec.kore.k-frontendunit tests (mvn -pl k-frontend test): 317 run, no failures, 2 skipped.Time per spec file
Sequential runs on an 8-core machine with a load average of 3–5. Wall time of
kprove --dry-run --emit-json-spec, two runs each:Still open
ResolveFunctionWithConfigread could recover part of that, but needs a careful argument.regression-newsuite (only the directories with proof tests), pyk's tests, and other users ofkprove(Kontrol, KMIR).--emit-json-specis not deterministic, with or without this change. This could be fixed separately.🤖 Generated with Claude Code