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

symm attribute error #855

Closed
winstonyin opened this issue Dec 5, 2022 · 2 comments
Closed

symm attribute error #855

winstonyin opened this issue Dec 5, 2022 · 2 comments

Comments

@winstonyin
Copy link
Collaborator

winstonyin commented Dec 5, 2022

The following code produces an error on the symm attribute:

import Mathlib.Algebra.Hom.Group
import Mathlib.Logic.Equiv.Basic

def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M) (h₁ : Function.LeftInverse g f)
    (h₂ : Function.RightInverse g f) : N →ₙ* M where
  toFun := g
  map_mul' x y :=
    calc
      g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
      _ = g (f (g x * g y)) := by rw [f.map_mul]
      _ = g x * g y := h₁ _

structure MulEquiv (M N : Type _) [Mul M] [Mul N] extends M ≃ N, M →ₙ* N

infixl:25 " ≃* " => MulEquiv

@[symm]
-- @[symm] attribute only applies to lemmas proving x ∼ y → y ∼ x, got {M : Type u_1} →
--  {N : Type u_2} → [inst : Mul M] → [inst_1 : Mul N] → M ≃* N → N ≃* M
def foo_symm {M N : Type _} [Mul M] [Mul N] (h : M ≃* N) : N ≃* M :=
  { h.toEquiv.symm with map_mul' := (h.toMulHom.inverse h.toEquiv.symm h.left_inv h.right_inv).map_mul }

It appears that trans is similarly having trouble recognising the structure of trans lemmas.

siddhartha-gadgil added a commit that referenced this issue Dec 5, 2022
the test was failing for dependent cases eg #855
@siddhartha-gadgil
Copy link
Collaborator

This has been narrowed, but some expertise is needed to make decisions on correcting this (or simply correcting the code - I gathered there are other issues). Will add details in a WIP PR.

bors bot pushed a commit that referenced this issue Dec 6, 2022
Fixes error I made: introducing a test for `symm` and `trans` attributes to check that the lemmas were "genuinely" symm/trans lemmas. However the tests had false positives, e.g. #855 (which has been added to the tests).

This short commit removes the tests. They were not present in `mathlib3` anyway and the worst that happens if a lemma is incorrectly labelled is that the `symm` tactic tries and fails with this.

As a warning it may be useful to have a test, but it should have no false positives. For now it seems the best approach is to drop the test.
bors bot pushed a commit that referenced this issue Dec 6, 2022
Fixes error I made: introducing a test for `symm` and `trans` attributes to check that the lemmas were "genuinely" symm/trans lemmas. However the tests had false positives, e.g. #855 (which has been added to the tests).

This short commit removes the tests. They were not present in `mathlib3` anyway and the worst that happens if a lemma is incorrectly labelled is that the `symm` tactic tries and fails with this.

As a warning it may be useful to have a test, but it should have no false positives. For now it seems the best approach is to drop the test.
@kmill
Copy link
Contributor

kmill commented May 12, 2023

It looks like symm doesn't report an error anymore so I'll close this issue.

import Mathlib.Algebra.Hom.Group
import Mathlib.Logic.Equiv.Basic

def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M) (h₁ : Function.LeftInverse g f)
    (h₂ : Function.RightInverse g f) : N →ₙ* M where
  toFun := g
  map_mul' x y :=
    calc
      g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
      _ = g (f (g x * g y)) := by rw [f.map_mul]
      _ = g x * g y := h₁ _

structure MulEquiv (M N : Type _) [Mul M] [Mul N] extends M ≃ N, M →ₙ* N

infixl:25 " ≃* " => MulEquiv

@[symm]
def foo_symm {M N : Type _} [Mul M] [Mul N] (h : M ≃* N) : N ≃* M :=
  { h.toEquiv.symm with map_mul' := (h.toMulHom.inverse h.toEquiv.symm h.left_inv h.right_inv).map_mul }

@kmill kmill closed this as completed May 12, 2023
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

No branches or pull requests

3 participants