Skip to content

[Merged by Bors] - fix: reintroduce to_fun_as_coe as simp lemma#931

Closed
kbuzzard wants to merge 15 commits intomasterfrom
kbuzzard-to-fun-as-coe
Closed

[Merged by Bors] - fix: reintroduce to_fun_as_coe as simp lemma#931
kbuzzard wants to merge 15 commits intomasterfrom
kbuzzard-to-fun-as-coe

Conversation

@kbuzzard
Copy link
Copy Markdown
Member

@kbuzzard kbuzzard commented Dec 9, 2022

This is a proposed fix for the broken simp calls in #922. See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60simp.60.20calls.20broken.20in.20mathlib4.23922/near/314783451 for more details. Note that to_fun_as_coe was a syntactic tautology when it was ported, but this is no longer the case because we now have FunLike.

@kbuzzard kbuzzard added the WIP Work in progress label Dec 9, 2022
@kbuzzard kbuzzard added awaiting-review and removed WIP Work in progress labels Dec 9, 2022
@kbuzzard
Copy link
Copy Markdown
Member Author

kbuzzard commented Dec 9, 2022

OK so adding to_fun_as_coe_apply made the linter go nuts because @[simps] is generating lemmas which aren't in simp normal form now. It's also not generating the additive versions of the lemmas, and furthermore the autoporter is not generating the #aligns for simps-generated lemmas anyway, so I am fixing several problems at once here.

In an ideal world, someone (unfortunately not me) will make @[simps] generate lemmas which don't mention toFun, and will also make @[to_additive, simps] work, and someone (unfortunately also not me) will make the autoporter generate #align statements for all the lemmas generated by @[simps] . This PR can be thought of as a workaround for all of these issues. Even if it's thought of as not a good idea to make to_fun_as_coe a simp lemma, the rest of this PR is still independently of some use while we wait for these fixes (which I've not opened issues for).

@kim-em
Copy link
Copy Markdown
Contributor

kim-em commented Dec 12, 2022

I don't think it's a good idea to proceed with this. I suggest a work-around for having simps produce the right lemmas at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.40.5Bsimps.5D.20making.20lemmas.20not.20in.20simp.20normal.20form/near/315268553

@kim-em kim-em added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Dec 12, 2022
@kbuzzard
Copy link
Copy Markdown
Member Author

If we don't simp away toFun to a coercion, then what do we do with examples like the following?

import Mathlib.Algebra.Group.WithOne.Basic

/-
from mathlib:

@[simp, to_additive]
theorem MulHom.coe_mk [Mul M] [Mul N] (f : M → N) (hmul) : (MulHom.mk f hmul : M → N) = f := rfl
-/
-- this goal shows up in the middle of a chain of rewrites done by `simp`
example [Mul α] [Mul β] (e : α ≃* β) (x : α) :
    Function.comp (↑(MulEquiv.toMulHom (MulEquiv.symm e)))
      (↑(MulEquiv.toMulHom e)) x = x := by
  -- goal contains no `toFun`
  rw [MulHom.coe_mk] -- this lemma contains no `toFun` and is a `simp` lemma
  -- goal now contains `MulHom.toFun` (the first `↑`)
  sorry

I don't know how to stop simp creating goals which mention toFun and right now it doesn't know what to do with them.

@kbuzzard
Copy link
Copy Markdown
Member Author

I don't understand why this is tagged awaiting-author -- I don't know what I am supposed to do with it. I'll change it back to awaiting-review. My understanding is that the community is happy with the idea that e.toFun is not the simp normal form. So now we either tell simp to change e.toFun into the simp normal form, or we absolutely guarantee that simp never produces an e.toFun term, which I don't know how to do (see previous example, which simp produced and which caused ported simp proofs to break in #922 -- see the second point in the first post). I don't really understand the disadvantage of telling simp what e.toFun should look like. If I'm supposed to be doing something, let me know!

@kbuzzard kbuzzard added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Dec 12, 2022
@kbuzzard kbuzzard added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Dec 15, 2022
@kbuzzard kbuzzard added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Dec 18, 2022
@kim-em
Copy link
Copy Markdown
Contributor

kim-em commented Dec 20, 2022

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Dec 20, 2022
bors bot pushed a commit that referenced this pull request Dec 20, 2022
This is a proposed fix for the broken simp calls in #922. See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60simp.60.20calls.20broken.20in.20mathlib4.23922/near/314783451 for more details. Note that `to_fun_as_coe` was a syntactic tautology when it was ported, but this is no longer the case because we now have `FunLike`.
@bors
Copy link
Copy Markdown

bors bot commented Dec 20, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title fix: reintroduce to_fun_as_coe as simp lemma [Merged by Bors] - fix: reintroduce to_fun_as_coe as simp lemma Dec 20, 2022
@bors bors bot closed this Dec 20, 2022
@bors bors bot deleted the kbuzzard-to-fun-as-coe branch December 20, 2022 06:14
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.

3 participants