Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradeoff of defining types as subobjects #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

YaelDillies
Copy link
Collaborator


## Typeclass search

In the Subobject design, all instances about `circle` are actually about `↥circle` where `↥` is [`CoeSort.coe`](https://leanprover-community.github.io/mathlib4_docs/find/?pattern=CoeSort.coe#doc). Eg `Foo circle` is secretly `Foo ↥circle`. This makes the head symbol be `CoeSort.coe`, meaning that typeclass search will try unifying *every* `Foo ↥someSubobject` instance with `Foo ↥circle`. In doing so, it will try unifying *every* subobject `someSubobject` with a `Foo` instance with `circle`. This is potentially really expensive.
Copy link
Member

Choose a reason for hiding this comment

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

Is this still the case in Lean 4? I thought discrimination trees avoided this...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very much so. Else why would leanprover-community/mathlib4#12386 have achieved anything perf-wise? The problem I believe is that the discr tree key is [CoeSort.coe, *]

Copy link
Contributor

@adomani adomani left a comment

Choose a reason for hiding this comment

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

Thanks for writing this!

posts/tradeoff-of-defining-types-as-subobjects.md Outdated Show resolved Hide resolved
posts/tradeoff-of-defining-types-as-subobjects.md Outdated Show resolved Hide resolved
@@ -0,0 +1,122 @@
---
author: 'Yaël Dillies'
category: 'Papers'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what to put here

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