Skip to content

refactor: Hyps optimisations (experiment) - #572

Draft
alvinylt wants to merge 3 commits into
leanprover-community:masterfrom
ISTA-PLV:HypsOptimisation
Draft

refactor: Hyps optimisations (experiment)#572
alvinylt wants to merge 3 commits into
leanprover-community:masterfrom
ISTA-PLV:HypsOptimisation

Conversation

@alvinylt

@alvinylt alvinylt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

There are many ways to potentially optimise the Iris Proof Mode, especially regarding how the spatial and intuitionistic contexts are organised using Hyps in ProofMode/Expr.lean. To name a few:

  • The functions Hyps.spatialIVarIds and Hyps.intuitionisticIVarIds use list concatenation (++): quadratic complexity due to repeated copying of lists. This can easily be optimised using an accumulator (commit 24db6ec).
  • The function Hyps.add does not perform balancing. It will be interesting to see whether having a balanced tree enables notable optimisations. Otherwise, we might instead simply have two separate lists (as in Rocq), one for spatial hypotheses and another for intuitionistic hypotheses. This would avoid complications (e.g. in Hyps.buildAccuProof) such as having multiple trees representing the same context (with the same order of hypotheses).
  • Possibly some data structures for more efficient lookup of hypotheses (e.g. using Hyps.select) instead of repeated isDefEq.
  • Prevent hypotheses from shuffling around when IPM tactics are used.

It will also be helpful to think through how the optimisations can be evaluated.

Checklist

  • My code follows the mathlib naming and code style conventions
  • I have added my name to the authors section of any appropriate files

@alvinylt

alvinylt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Aug 6, 2026

Copy link
Copy Markdown

Benchmark results for 790a068 against 4d8eee8 are in. No significant results found. @alvinylt

  • 🟥 build//instructions: +3.7G (+0.22%)

Small changes (1🟥)

  • 🟥 build/module/Iris.ProofMode.Expr//instructions: +1.7G (+12.24%)

@markusdemedeiros markusdemedeiros added the experiment Ideas for features that may or may not work label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experiment Ideas for features that may or may not work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants