Skip to content

Definitional eta for structures #777

@gebner

Description

@gebner

This is not intended as a bug report or feature request, but merely as a discussion point since this has come up on Zulip several times and Sebastian asked me to write this up.

Frequently people run into issues in mathlib where they would like a definitional eta-rule for structures. Concretely, we are talking about a rule that would make the following example provable by rfl:

example (x : α × β) : x = (x.1, x.2) := rfl
-- and analogously for other structures than Prod

These issues often arise with wrapper types, for examples opposites in category theory, or additive/multiplicative which swaps plus and times. With these wrappers, you want to avoid definitional equalities to prevent e.g. the wrong type class being used (i.e., αᵒᵖ should not be definitionally equal to α). However turning these into single-field structures is painful partly because of the missing eta rules. In Lean 3 we often used irreducible definitions for this (with local attribute [semireducible] when eta was desired), but this is neither pretty nor available in Lean 4.

Concretely, the following are examples of definitional equalities that would be nice to have:

  • s = { x | x ∈ s }
  • op (unop x) = x
  • to_dual (of_dual x) = x
  • e.symm.symm = e

Relevant Zulip discussions (non-exhaustive):

Other proof assistants that have eta for structures:

  • Coq has it for records if you enable Set Primitive Projections.
  • Agda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions