mathlib documentation

data.opposite

Opposites #

In this file we define a type synonym opposite α := α, denoted by αᵒᵖ and two synonyms for the identity map, op : α → αᵒᵖ and unop : αᵒᵖ → α. If α is a category, then αᵒᵖ is the opposite category, with all arrows reversed.

@[irreducible]
def opposite (α : Sort u) :
Sort u

The type of objects of the opposite of α; used to define the opposite category.

In order to avoid confusion between α and its opposite type, we set up the type of objects opposite α using the following pattern, which will be repeated later for the morphisms.

  1. Define opposite α := α.
  2. Define the isomorphisms op : α → opposite α, unop : opposite α → α.
  3. Make the definition opposite irreducible.

This has the following consequences.

  • opposite α and α are distinct types in the elaborator, so you must use op and unop explicitly to convert between them.
  • Both unop (op X) = X and op (unop X) = X are definitional equalities. Notably, every object of the opposite category is definitionally of the form op X, which greatly simplifies the definition of the structure of the opposite category, for example.

(If Lean supported definitional eta equality for records, we could achieve the same goals using a structure with one field.)

Equations
Instances for opposite
def opposite.op {α : Sort u} :
α → αᵒᵖ

The canonical map α → αᵒᵖ.

Equations
Instances for opposite.op
def opposite.unop {α : Sort u} :
αᵒᵖ → α

The canonical map αᵒᵖ → α.

Equations
Instances for opposite.unop
@[simp]
theorem opposite.op_unop {α : Sort u} (x : αᵒᵖ) :
@[simp]
theorem opposite.unop_op {α : Sort u} (x : α) :
@[simp]
theorem opposite.op_inj_iff {α : Sort u} (x y : α) :
@[simp]
theorem opposite.unop_inj_iff {α : Sort u} (x y : αᵒᵖ) :
def opposite.equiv_to_opposite {α : Sort u} :
α αᵒᵖ

The type-level equivalence between a type and its opposite.

Equations
theorem opposite.op_eq_iff_eq_unop {α : Sort u} {x : α} {y : αᵒᵖ} :
theorem opposite.unop_eq_iff_eq_op {α : Sort u} {x : αᵒᵖ} {y : α} :
@[protected, instance]
def opposite.inhabited {α : Sort u} [inhabited α] :
Equations
@[protected, simp]
def opposite.rec {α : Sort u} {F : αᵒᵖSort v} (h : Π (X : α), F (opposite.op X)) (X : αᵒᵖ) :
F X

A recursor for opposite. Use as induction x using opposite.rec.

Equations

Test if e : expr is of type opposite α for some α.

Find the first hypothesis of type opposite _. Fail if no such hypothesis exist in the local context.

A version of induction x using opposite.rec which finds the appropriate hypothesis automatically, for use with local attribute [tidy] op_induction'. This is necessary because induction x is not able to deduce that opposite.rec should be used.