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

[Merged by Bors] - chore: bump to std4 2022-12-05 #865

Closed
wants to merge 3 commits into from
Closed

Conversation

gebner
Copy link
Member

@gebner gebner commented Dec 6, 2022

No description provided.

@@ -61,7 +61,7 @@ Mario made the following analysis of uses in mathlib3:

universe u v

class IsSymmOp (α : Type u) (β : outParam (Type v)) (op : outParam (α → α → β)) : Prop where
class IsSymmOp (α : Type u) (β : Type v) (op : α → α → β) : Prop where
Copy link
Member Author

@gebner gebner Dec 6, 2022

Choose a reason for hiding this comment

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

This was obviously an error. The whole point of unbundled classes is that we can have more than one operation per type, and the out-param version only allowed a single commutative operation per type.

The error was indirectly flagged by the new dangerousInstances linter: it complained about the is_symm_op_of_is_commutative instance below, correctly pointing out that it used the non-out-param IsCommutative class (which may have more than one solution for the operation✝) to (nondeterministically) fill in the out-param of the IsSymmOp class.

✝ And even worse, instances for IsCommutative may rely on op not being a metavariable. This mismatch can result in nontermination of type class search.

@@ -141,7 +141,7 @@ variable {F α β} [i : FunLike F α β]

-- Give this a priority between `coe_fn_trans` and the default priority
-- `α` and `β` are out_params, so this instance should not be dangerous
-- Porting note: @[nolint dangerous_instance]
@[nolint dangerousInstance]
Copy link
Member Author

Choose a reason for hiding this comment

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

This nolint is actually unnecessary now. The new linter is much smarter than the old one (it understands out-params, and I've also taught it about the not-quite-out-params in CoeHead/CoeTail/Coe).

Copy link
Member

Choose a reason for hiding this comment

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

Was the dangerous instance linter also responsible for the change to the RBMap.keys coe? What makes that one dangerous?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the linter also flagged those. This particular case should be fine, since we don't have any other instances mentioning Keys. But if you added a hypothetical [Coe β β'] : Coe (Keys α β cmp) (Keys α β' cmp) instance, then you'd get nontermination.

The general rule for TC search is that we don't want to have any metavariables in non-out-params. Otherwise, you get goals like Group ?α and end up enumerating all groups.

Copy link
Member Author

Choose a reason for hiding this comment

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

This rule might be a bit on the cautious side, as it also rules out Coe (Fin n) Nat ✝️, which is in core. I'm open for other clear rules that rein in the coercion instances as well. But coercion instances are an easy way to break everything (including notations and macros, since they rely on coercions!). So we definitely need some strict linters here.

✝️ (which notably conflicts with a hypothetical Coe (Fin n) (Fin (n+1)))

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 inclined to follow the cautious rule until we find a compelling counterexample to examine and derive some rules from. (The Fin n -> Nat coe can be made into a CoeHead as well, I think.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it can and probably should.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, this breaks somewhat easily because we don't chain CoeHead.

@semorrison
Copy link
Contributor

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Dec 6, 2022
bors bot pushed a commit that referenced this pull request Dec 6, 2022
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Dec 6, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title chore: bump to std4 2022-12-05 [Merged by Bors] - chore: bump to std4 2022-12-05 Dec 6, 2022
@bors bors bot closed this Dec 6, 2022
@bors bors bot deleted the bumpstd22125 branch December 6, 2022 05:30
@digama0
Copy link
Member

digama0 commented Dec 6, 2022

bors merge

@bors
Copy link

bors bot commented Dec 6, 2022

Already running a review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants