Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

wip(data/subtype_instances): introduce closed_under predicate typeclasses - #7834

Open
eric-wieser wants to merge 1 commit into
masterfrom
eric-wieser/subtype.closed_under-measurable
Open

wip(data/subtype_instances): introduce closed_under predicate typeclasses#7834
eric-wieser wants to merge 1 commit into
masterfrom
eric-wieser/subtype.closed_under-measurable

Conversation

@eric-wieser

Copy link
Copy Markdown
Member

This seemed like it would be a nice generalization, but typeclass inference gets completely stuck in finding these new instances.

This is a more general version of #7833, with the hope of expanding the typeclasses to be used with submonoid etc in a future PR.


Open in Gitpod

Comment on lines +492 to +551
/-- Typeclass inference can't find this without a large amount of help :(. -/
example [semiring β] [has_measurable_add₂ β] [has_measurable_mul₂ β]:
semiring (subtype (measurable : (α → β) → Prop)) :=
begin
/- `id _` lets us see why typeclass inference is failing. -/
refine @subtype.closed_under.subtype.semiring _ _ _ (id _) sorry sorry sorry,
convert measurable.subtype.closed_under_zero,
-- uh oh: `mul_zero_class.to_has_zero (α → β) = pi.has_zero`
swap,
apply_instance,
refl,
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Here's where everything goes wrong

@awainverse

Copy link
Copy Markdown
Collaborator

I think you can generalize these to an arbitrary number of inputs with arity. Also, I'm trying to do something similar in spirit at #7762.

@eric-wieser

Copy link
Copy Markdown
Member Author

That PR looks good and I was already aware of it, but I think that approach would make the typeclass problem worse.

@eric-wieser
eric-wieser force-pushed the eric-wieser/subtype.closed_under-measurable branch from 8fb8837 to 38a5388 Compare June 10, 2021 06:44
@github-actions github-actions Bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Aug 11, 2021
@kim-em kim-em added the too-late This PR was ready too late for inclusion in mathlib3 label Jul 16, 2023
@eric-wieser
eric-wieser requested a review from a team as a code owner October 16, 2023 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

merge-conflict Please `git merge origin/master` then a bot will remove this label. RFC Request for comment too-late This PR was ready too late for inclusion in mathlib3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants