leanprover-community / leanprover-community/mathlib4
deriving CommRing on InfiniteAdeleRing generates opaque _aux_* field definitions that defeat isDefEq at instances transparency
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 4.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Symptom
NumberField.InfiniteAdeleRing is a pi-type synonym
def InfiniteAdeleRing (K : Type*) [Field K] := (v : InfinitePlace K) → v.Completion
deriving CommRing, Inhabited, TopologicalSpace, IsTopologicalRing, Algebra K
deriving emits machine-generated auxiliary field definitions (…_aux_1, …_aux_13, …) for the structure fields. Downstream (e.g. ImperialCollegeLondon/FLT), instance-implicit unification then has to prove goals like
f i * g i =?= instCommRingInfiniteAdeleRing._aux_13 K f g i
f i + g i =?= instCommRingInfiniteAdeleRing._aux_1 K f g i
which fail at instances transparency (backward.isDefEq.respectTransparency := true, the default since Lean v4.29), because those _aux_* definitions are not reducible there. Tagging individual aux names @[implicit_reducible] is not viable (unstable names; fixing one shifts the failure). See FLT#1132 / FLT#889 for traces and the remaining local set_option workaround.
What does not work / is undesirable
| Approach | Why not |
|---|---|
inferInstanceAs (CommRing (Π …)) |
Still elaborates to _aux_* fields; MetaM canary stays false at instances |
abbrev InfiniteAdeleRing |
Fixes the mul canary, but inherits the full pi/NormedField hierarchy (sup norm). This file also installs a custom adelic product Norm (∏ v, ‖x v‖ ^ v.mult), so an abbrev creates a norm diamond |
Leaving deriving |
Status quo; forces downstream transparency escapes |
Proposed fix
Keep the semi-reducible def (so the custom product Norm stays the only norm API), drop deriving, and install only the algebraic/topological instances via transparent pi re-export:
instance : CommRing (InfiniteAdeleRing K) :=
show CommRing ((v : InfinitePlace K) → v.Completion) from inferInstance
-- same pattern for Inhabited, TopologicalSpace, IsTopologicalRing, Algebra
#print then shows have this := inferInstance; this (no _aux_*). MetaM canary on (f * g) i vs f i * g i for InfiniteAdeleRing ℚ: instances: true.
PR
https://github.com/leanprover-community/mathlib4/pull/42130
(Earlier #42120 used a similar instance shape but without the norm-boundary rationale and was closed; #42130 keeps def and documents why not abbrev.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the InfiniteAdeleRing definition and its deriving declaration, then review PR #42130 and the MetaM canary described in the issue. Done means instance-implicit equality succeeds at instances transparency without generated aux* fields, while the custom adelic product Norm remains the only norm API.
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
- Clearly specified
- Newbie friendliness
- 25/100