speed up Print Assumptions: walk stored proof term - #22425
Open
zeldovich wants to merge 2 commits into
Open
Conversation
This change speeds up Print Assumptions for large proofs that have a lot of shared terms. The motivation was a large Iris-based project where [Print Assumptions] on a single top-level theorem was almost half of the total build time of the whole project (6 minutes out of 13 minutes). [Print Assumptions] obtains every opaque body through [Global.force_proof], which applies the section discharge ([Discharge.cook_opaque_proofterm], once per enclosing section) before the command looks at the term. The discharge is a rebuild, and the rebuild destroys sharing. complexity/PrintAssumptionsSharing.v is a regression test for the walk itself: a proof whose stored DAG is 22 nodes and whose tree unfolding is over 4M, so the old walk is exponential in the size of the file. This also adds a test for the weird corner case of [Print Assumptions] that wasn't covered by existing tests (the "used in" annotation that [ax2ty] attaches to an axiom eliminated by a [match ... with end]).
SkySkimmer
reviewed
Aug 30, 2026
| walk would have grown is read by [assumptions] only through | ||
| [Option.has_some]. The one visible effect is on [ax2ty]: a | ||
| [match ... with end] that is one shared node reached along several paths | ||
| contributes one "used in" entry rather than one per path. |
Contributor
There was a problem hiding this comment.
This is a user visible change
Axiom f : False.
Definition bla := (let x := nat in match f return x with end, let y := bool in match f return y with end).
Print Assumptions bla.
(* master:
Axioms:
f : False
used in bla to prove
y
used in bla to prove
x
PR:
Axioms:
f : False
used in bla to prove
x
*)but IDK if that really matters considering y and x are not very informative without printing the local context.
Member
There was a problem hiding this comment.
If you do Require Import Coq.Compat.AdmitAxiom. and then admit a handful of sub goals, does this make it so that only one appears?
Contributor
Author
There was a problem hiding this comment.
I pushed a commit to preserve the old behavior. (I had assumed this is some weird feature that's not used, but clearly that's not true.) The fix is to avoid caching anything that produces one of these "used in" reports.
Member
There was a problem hiding this comment.
Preserve old behavior in terms of the "used in" output.
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.
This change speeds up Print Assumptions for large proofs that have a lot of shared terms. The motivation was a large Iris-based project where [Print Assumptions] on a single top-level theorem was almost half of the total build time of the whole project (6 minutes out of 13 minutes).
[Print Assumptions] obtains every opaque body through [Global.force_proof], which applies the section discharge ([Discharge.cook_opaque_proofterm], once per enclosing section) before the command looks at the term. The discharge is a rebuild, and the rebuild destroys sharing.
complexity/PrintAssumptionsSharing.v is a regression test for the walk itself: a proof whose stored DAG is 22 nodes and whose tree unfolding is over 4M, so the old walk is exponential in the size of the file.
This also adds a test for the weird corner case of [Print Assumptions] that wasn't covered by existing tests (the "used in" annotation that [ax2ty] attaches to an axiom eliminated by a [match ... with end]).