Skip to content

refactor: use Qq in free_union#433

Merged
chenson2018 merged 1 commit intomainfrom
eric-wieser/has-fresh
Mar 17, 2026
Merged

refactor: use Qq in free_union#433
chenson2018 merged 1 commit intomainfrom
eric-wieser/has-fresh

Conversation

@eric-wieser
Copy link
Copy Markdown
Collaborator

@eric-wieser eric-wieser commented Mar 17, 2026

This is faster, because it performs almost all the elaboration at compile-type, rather than when the elaborator is run.

I also took the liberty of removing the id applications that are presumably not intended.

@eric-wieser
Copy link
Copy Markdown
Collaborator Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 17, 2026

Benchmark results for a5b7654 against b39710e are in. There are no significant changes. @eric-wieser

  • build//instructions: -3.9G (-0.22%)

Small changes (1✅)

  • build/profile/lazy discriminator local search//wall-clock: +0s (-48.27%)

Comment on lines +109 to +115
for ldecl in ← getLCtx do
if !ldecl.isImplementationDetail then
let local_type ← ldecl.toExpr |> inferType >=> whnf
for map in maps do
if let Expr.forallE _ dom _ _ := ← inferType map then
if (←isDefEq local_type dom) then
finsets := finsets.push (mkApp map ldecl.toExpr)
if isDefEq local_type dom then
finsets := finsets.push (map.betaRev #[ldecl.toExpr])
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This could simplify to

Suggested change
for ldecl in ← getLCtx do
if !ldecl.isImplementationDetail then
let local_type ← ldecl.toExpr |> inferType >=> whnf
for map in maps do
if let Expr.forallE _ dom _ _ := ← inferType map then
if (←isDefEq local_type dom) then
finsets := finsets.push (mkApp map ldecl.toExpr)
if ← isDefEq local_type dom then
finsets := finsets.push (map.betaRev #[ldecl.toExpr])
for ldecl in ← getLCtx do
if !ldecl.isImplementationDetail then
for map in maps do
let finset ← try
mkAppM' map #[ldecl.toExpr]
catch _ =>
continue
finsets := finsets.push finset.headBeta

but lets leave that to a follow-up Pr so that it can be benchmarked separately.

Copy link
Copy Markdown
Collaborator

@chenson2018 chenson2018 left a comment

Choose a reason for hiding this comment

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

This is a lot easier to follow now, thanks!

@chenson2018 chenson2018 added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 9fbbd6a Mar 17, 2026
3 checks passed
m-ow pushed a commit to m-ow/cslib that referenced this pull request Mar 17, 2026
This is faster, because it performs almost all the elaboration at
compile-type, rather than when the elaborator is run.

I also took the liberty of removing the `id` applications that are
presumably not intended.
thomaskwaring pushed a commit to thomaskwaring/cslib_SKI that referenced this pull request Apr 6, 2026
This is faster, because it performs almost all the elaboration at
compile-type, rather than when the elaborator is run.

I also took the liberty of removing the `id` applications that are
presumably not intended.
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.

3 participants