leanprover-community / leanprover-community/mathlib4

[refl] tag depends on order of instance arguments

Open
#2,505 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

t-meta
Dominant language
Lean
Stars
4.2k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

The [refl] tag applies to refl theorems or definitions only if the instance arguments of the associated structure are ordered in a specific way, apparently, see also this Zulip thread. MWE testing some combinations:

import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Hom.Ring

structure RingEquiv0 (R S : Type _) [Mul R] [Mul S] [Add R] [Add S] extends R ≃ S, R ≃* S, R ≃+ S

structure RingEquiv1 (R S : Type _) [Mul S] [Mul R] [Add R] [Add S] extends R ≃ S, R ≃* S, R ≃+ S

structure RingEquiv2 (R S : Type _) [Mul R] [Mul S] [Add S] [Add R] extends R ≃ S, R ≃* S, R ≃+ S

structure RingEquiv3 (R S : Type _) [Mul R] [Add R] [Mul S] [Add S] extends R ≃ S, R ≃* S, R ≃+ S

structure RingEquiv4 (R S : Type _) [Mul R] [Add S] [Mul S] [Add R] extends R ≃ S, R ≃* S, R ≃+ S

@[refl] -- works
def RingEquiv0.refl [Mul α] [Add α] : RingEquiv0 α α := sorry

@[refl] -- works
def RingEquiv1.refl [Mul α] [Add α] : RingEquiv1 α α := sorry

@[refl] -- works
def RingEquiv2.refl [Mul α] [Add α] : RingEquiv2 α α := sorry

@[refl] /- @[refl] attribute only applies to lemmas proving x ∼ x, got {α : Type u_1} →
  [inst : Mul α] → [inst_1 : Add α] → RingEquiv3 α α -/
def RingEquiv3.refl [Mul α] [Add α] : RingEquiv3 α α := sorry

@[refl] /- @[refl] attribute only applies to lemmas proving x ∼ x, got {α : Type u_1} →
  [inst : Mul α] → [inst_1 : Add α] → RingEquiv4 α α -/
def RingEquiv4.refl [Mul α] [Add α] : RingEquiv4 α α := sorry

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied MWE using the imported Mathlib.Algebra.Group.Opposite and Mathlib.Algebra.Hom.Ring modules, comparing the five RingEquiv definitions and their [refl] declarations. Trace the [refl] attribute's validation entry point and determine why instance-argument order rejects RingEquiv3 and RingEquiv4. Done means the MWE's order variations are accepted consistently, with regression coverage for the failing cases.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.