Skip to content

Defining invariant that CachedAnalysis must hold, update PrecondElim#704

Merged
MikaelMayer merged 49 commits intomainfrom
issue-702-defining-invariant-that-cachedanalysis-m
Apr 9, 2026
Merged

Defining invariant that CachedAnalysis must hold, update PrecondElim#704
MikaelMayer merged 49 commits intomainfrom
issue-702-defining-invariant-that-cachedanalysis-m

Conversation

@MikaelMayer
Copy link
Copy Markdown
Contributor

@MikaelMayer MikaelMayer commented Mar 30, 2026

Fixes #702

Problem

PrecondElim generates WF (well-formedness) checking procedures but did not update the cached call graph. This meant any downstream transform relying on the call graph would see stale data after PrecondElim.

Solution

  • Document the CachedAnalyses invariant: when the call graph is present, it must reflect the current program's procedure call structure. Transforms must update it or invalidate it.
  • Add CallGraph.addLeafNode for inserting nodes with no callees (updates both callees and callers maps to keep their key sets consistent).
  • Update PrecondElim to register generated precondition-WF procedures as leaf nodes in the call graph (they contain only assert/assume statements and make no procedure calls).
  • Replace the manual post-transform keepSet filtering in the selective verification pipeline with a second FilterProcedures.run pass. Since CallElim maintains the call graph precisely (via decrementEdge) and PrecondElim now registers WF procs as leaf nodes with noFilter := true, the call-graph closure is accurate after transforms and FilterProcedures works correctly — no manual filtering needed.
  • Extend filterProceduresPipelinePhase with a respectNoFilter parameter so both the initial and post-transform filter phases reuse the same helper.

Testing

All existing tests pass, including selective verification, NoFilterWFProc, CallElim, and InlineAssertionMetadata tests.

… call graph (#702)

PrecondElim generates WF procedures but did not update the cached call
graph, which prevented FilterProcedures from being used after PrecondElim
in the selective verification pipeline.

- Add CallGraph.addLeafNode for inserting nodes with no callees
- Update PrecondElim to register generated WF procedures in the call graph
- Move the second FilterProcedures.run after PrecondElim in the Verifier
- Document the CachedAnalyses call graph invariant
…ysis-m

# Conflicts:
#	Strata/Languages/Core/CallGraph.lean
#	Strata/Transform/PrecondElim.lean
…ysis-m

# Conflicts:
#	Strata/Languages/Core/Verifier.lean
@MikaelMayer

This comment has been minimized.

@MikaelMayer

This comment has been minimized.

@MikaelMayer

This comment has been minimized.

@MikaelMayer

This comment has been minimized.

Copy link
Copy Markdown
Contributor Author

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped PR. The invariant documentation is clear and the addLeafNode / addWFProcToCallGraph pattern is easy to follow. One issue: the recFuncBlock case is missing the call graph update.

Comment thread Strata/Transform/PrecondElim.lean
@MikaelMayer

This comment has been minimized.

CallElim maintains the call graph by decrementing edges when it inlines
contracts, so the call-graph closure is accurate after transforms.
Replace the manual keepSet filtering with a second FilterProcedures.run
call that targets the requested procedures plus their WF procedures.
@MikaelMayer

This comment has been minimized.

…edures.run

FilterProcedures.run follows the call-graph closure, which pulls prelude
functions (List_take, List_drop, etc.) back into the program after
CallElim. Use a simple HashSet filter on the exact target procedures
and their WF procedures to avoid verifying prelude helpers.
@MikaelMayer

This comment has been minimized.

Remove the manual keepSet filtering and reuse filterProceduresPipelinePhase
as a second pass after CallElim and PrecondElim. This works because:
- CallElim maintains the call graph via decrementEdge
- PrecondElim registers WF procedures as leaf nodes with noFilter := true
- FilterProcedures.run respects noFilter and uses call-graph closure
@MikaelMayer

This comment has been minimized.

…ysis-m

# Conflicts:
#	Strata/Languages/Core/Verifier.lean
The second FilterProcedures pass (after CallElim and PrecondElim) was
keeping WF procedures for prelude functions due to their noFilter flag,
causing extra body_calls obligations to appear in pyAnalyze test output.

Fix: add a respectNoFilter parameter to FilterProcedures.run and disable
it for the post-transform pass. The post-transform pass now explicitly
includes target WF procedure names via PrecondElim.wfProcName instead of
relying on noFilter.
Comment thread Strata/Languages/Core/Verifier.lean Outdated
MikaelMayer and others added 3 commits April 7, 2026 18:55
Add respectNoFilter parameter to filterProceduresPipelinePhase and
reuse it in corePipelinePhases instead of inline code.
…ysis-m

# Conflicts:
#	Strata/Languages/Core/Verifier.lean
Comment thread Strata/Languages/Core/CallGraph.lean Outdated
@aqjune-aws aqjune-aws marked this pull request as ready for review April 9, 2026 21:47
@aqjune-aws aqjune-aws requested a review from a team April 9, 2026 21:47
Comment thread Strata/Transform/PrecondElim.lean Outdated
@MikaelMayer MikaelMayer enabled auto-merge April 9, 2026 22:09
@MikaelMayer MikaelMayer added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 0ba1c97 Apr 9, 2026
15 checks passed
@MikaelMayer MikaelMayer deleted the issue-702-defining-invariant-that-cachedanalysis-m branch April 9, 2026 22:35
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.

Defining invariant that CachedAnalysis must hold, update PrecondElim

3 participants