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

[Merged by Bors] - feat(meta/univs): Add a reflect_name tactic, make reflected instances universe polymorphic #14766

Closed
wants to merge 4 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jun 16, 2022

The existing list.reflect instance only works for Type 0, this version works for Type u providing u is known.


Open in Gitpod

@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR awaiting-CI The author would like to see what CI has to say before doing more work. labels Jun 16, 2022
@eric-wieser eric-wieser requested a review from gebner June 16, 2022 11:53
@eric-wieser eric-wieser added the t-meta Tactics, attributes or user commands label Jun 16, 2022
⟨level.succ reflect_univ.{u}⟩

@[instance] meta def {u v} reflect_univ.max [reflected_univ.{u}] [reflected_univ.{v}] :
reflected_univ.{max u v} :=
Copy link
Member

Choose a reason for hiding this comment

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

I'm (happily) surprised that this works. I would have expected this to be a blanket instance, with Lean reasoning that u = max u u or u = max u 0.

do
tgt ← tactic.target,
`(reflected %%x) ← pure tgt,
expr.const name levels ← pure x,
Copy link
Member

Choose a reason for hiding this comment

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

It would be fairly straightforward to extend this tactic to applications as well and try apply_instance first, and then you don't need write the subst manually.

But I really don't want to encourage you to spend too much time on Lean 3 metaprogramming.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think trying apply_instance first is a good idea; as seen in the thread that started this, it can end up synthesizing an instance that doesn't type-check.

But I really don't want to encourage you to spend too much time on Lean 3 metaprogramming.

I think probably I'd rather leave this as is; it's all a rabbit hole that appeared while trying to refactor #14665, and this particular PR wasn't even needed by that refactor!

Copy link
Member

Choose a reason for hiding this comment

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

Okay then.

Comment on lines +571 to +572
((by reflect_name : reflected @vector.nil.{u}).subst `(α))
(λ n x xs ih, (by reflect_name : reflected @vector.cons.{u}).subst `(α) `(n) `(x) ih)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
((by reflect_name : reflected @vector.nil.{u}).subst `(α))
(λ n x xs ih, (by reflect_name : reflected @vector.cons.{u}).subst₄ `(α) `(n) `(x) ih)
(by resetI; reflect)
(λ n x xs ih, by resetI; reflect)

This is how it could look like if you extended reflect_name to applications.

@github-actions github-actions bot removed the awaiting-CI The author would like to see what CI has to say before doing more work. label Jun 16, 2022
@gebner
Copy link
Member

gebner commented Jun 24, 2022

bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Jun 24, 2022
bors bot pushed a commit that referenced this pull request Jun 24, 2022
… universe polymorphic (#14766)

The existing `list.reflect` instance only works for `Type 0`, this version works for `Type u` providing `u` is known.
@bors
Copy link

bors bot commented Jun 24, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(meta/univs): Add a reflect_name tactic, make reflected instances universe polymorphic [Merged by Bors] - feat(meta/univs): Add a reflect_name tactic, make reflected instances universe polymorphic Jun 24, 2022
@bors bors bot closed this Jun 24, 2022
@bors bors bot deleted the eric-wieser/reflect-universes branch June 24, 2022 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants