mathlib documentation

data.sym2

The symmetric square #

This file defines the symmetric square, which is α × α modulo swapping. This is also known as the type of unordered pairs.

More generally, the symmetric square is the second symmetric power (see data.sym). The equivalence is sym2.equiv_sym.

From the point of view that an unordered pair is equivalent to a multiset of cardinality two (see sym2.equiv_multiset), there is a has_mem instance sym2.mem, which is a Prop-valued membership test. Given h : a ∈ z for z : sym2 α, then h.other is the other element of the pair, defined using classical.choice. If α has decidable equality, then h.other' computably gives the other element.

Recall that an undirected graph (allowing self loops, but no multiple edges) is equivalent to a symmetric relation on the vertex type α. Given a symmetric relation on α, the corresponding edge set is constructed by sym2.from_rel.

Notation #

The symmetric square has a setoid instance, so ⟦(a, b)⟧ denotes a term of the symmetric square.

Tags #

symmetric square, unordered pairs, symmetric powers

inductive sym2.rel (α : Type u) :
α × αα × α → Prop
  • refl : ∀ (α : Type u) (x y : α), sym2.rel α (x, y) (x, y)
  • swap : ∀ (α : Type u) (x y : α), sym2.rel α (x, y) (y, x)

This is the relation capturing the notion of pairs equivalent up to permutations.

theorem sym2.rel.symm {α : Type u} {x y : α × α} :
sym2.rel α x ysym2.rel α y x
theorem sym2.rel.trans {α : Type u} {x y z : α × α} :
sym2.rel α x ysym2.rel α y zsym2.rel α x z
theorem sym2.rel.is_equivalence {α : Type u} :
@[protected, instance]
def sym2.rel.setoid (α : Type u) :
setoid × α)
Equations
def sym2 (α : Type u) :
Type u

sym2 α is the symmetric square of α, which, in other words, is the type of unordered pairs.

It is equivalent in a natural way to multisets of cardinality 2 (see sym2.equiv_multiset).

Equations
theorem sym2.eq_swap {α : Type u} {a b : α} :
(a, b) = (b, a)
theorem sym2.congr_right {α : Type u} {a b c : α} :
(a, b) = (a, c) b = c
theorem sym2.congr_left {α : Type u} {a b c : α} :
(b, a) = (c, a) b = c
def sym2.map {α : Type u_1} {β : Type u_2} (f : α → β) :
sym2 αsym2 β

The functor sym2 is functorial, and this function constructs the induced maps.

Equations
@[simp]
theorem sym2.map_id {α : Type u} :
theorem sym2.map_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {g : β → γ} {f : α → β} :
@[simp]
theorem sym2.map_pair_eq {α : Type u_1} {β : Type u_2} (f : α → β) (x y : α) :
sym2.map f (x, y) = (f x, f y)

Declarations about membership #

def sym2.mem {α : Type u} (x : α) (z : sym2 α) :
Prop

This is a predicate that determines whether a given term is a member of a term of the symmetric square. From this point of view, the symmetric square is the subtype of cardinality-two multisets on α.

Equations
@[protected, instance]
def sym2.has_mem {α : Type u} :
has_mem α (sym2 α)
Equations
theorem sym2.mk_has_mem {α : Type u} (x y : α) :
x (x, y)
theorem sym2.mk_has_mem_right {α : Type u} (x y : α) :
y (x, y)
def sym2.mem.other {α : Type u} {a : α} {z : sym2 α} (h : a z) :
α

Given an element of the unordered pair, give the other element using classical.some. See also mem.other' for the computable version.

Equations
@[simp]
theorem sym2.mem_other_spec {α : Type u} {a : α} {z : sym2 α} (h : a z) :
theorem sym2.eq_iff {α : Type u} {x y z w : α} :
(x, y) = (z, w) x = z y = w x = w y = z
@[simp]
theorem sym2.mem_iff {α : Type u} {a b c : α} :
a (b, c) a = b a = c
theorem sym2.mem_other_mem {α : Type u} {a : α} {z : sym2 α} (h : a z) :
theorem sym2.elems_iff_eq {α : Type u} {x y : α} {z : sym2 α} (hne : x y) :
x z y z z = (x, y)
@[ext]
theorem sym2.sym2_ext {α : Type u} (z z' : sym2 α) (h : ∀ (x : α), x z x z') :
z = z'
@[protected, instance]
def sym2.mem.decidable {α : Type u} [decidable_eq α] (x : α) (z : sym2 α) :
Equations
def sym2.diag {α : Type u} (x : α) :
sym2 α

A type α is naturally included in the diagonal of α × α, and this function gives the image of this diagonal in sym2 α.

Equations
def sym2.is_diag {α : Type u} (z : sym2 α) :
Prop

A predicate for testing whether an element of sym2 α is on the diagonal.

Equations
@[simp]
theorem sym2.diag_is_diag {α : Type u} (a : α) :
@[simp]
theorem sym2.is_diag_iff_proj_eq {α : Type u} (z : α × α) :
@[protected, instance]
Equations
theorem sym2.mem_other_ne {α : Type u} {a : α} {z : sym2 α} (hd : ¬z.is_diag) (h : a z) :

Declarations about symmetric relations #

def sym2.from_rel {α : Type u} {r : α → α → Prop} (sym : symmetric r) :
set (sym2 α)

Symmetric relations define a set on sym2 α by taking all those pairs of elements that are related.

Equations
@[simp]
theorem sym2.from_rel_proj_prop {α : Type u} {r : α → α → Prop} {sym : symmetric r} {z : α × α} :
@[simp]
theorem sym2.from_rel_prop {α : Type u} {r : α → α → Prop} {sym : symmetric r} {a b : α} :
(a, b) sym2.from_rel sym r a b
theorem sym2.from_rel_irreflexive {α : Type u} {r : α → α → Prop} {sym : symmetric r} :
irreflexive r ∀ {z : sym2 α}, z sym2.from_rel sym¬z.is_diag
theorem sym2.mem_from_rel_irrefl_other_ne {α : Type u} {r : α → α → Prop} {sym : symmetric r} (irrefl : irreflexive r) {a : α} {z : sym2 α} (hz : z sym2.from_rel sym) (h : a z) :
@[protected, instance]
def sym2.from_rel.decidable_pred {α : Type u} {r : α → α → Prop} (sym : symmetric r) [h : decidable_rel r] :
Equations

Equivalence to the second symmetric power #

def sym2.sym2_equiv_sym' {α : Type u_1} :
sym2 α sym.sym' α 2

The symmetric square is equivalent to length-2 vectors up to permutations.

Equations
def sym2.equiv_sym (α : Type u_1) :
sym2 α sym α 2

The symmetric square is equivalent to the second symmetric power.

Equations
def sym2.equiv_multiset (α : Type u_1) :
sym2 α {s // multiset.card s = 2}

The symmetric square is equivalent to multisets of cardinality two. (This is currently a synonym for equiv_sym, but it's provided in case the definition for sym changes.)

Equations
def sym2.rel_bool {α : Type u} [decidable_eq α] (x y : α × α) :

An algorithm for computing sym2.rel.

Equations
theorem sym2.rel_bool_spec {α : Type u} [decidable_eq α] (x y : α × α) :
@[protected, instance]
def sym2.rel.decidable_rel (α : Type u_1) [decidable_eq α] :

Given [decidable_eq α] and [fintype α], the following instance gives fintype (sym2 α).

Equations
def sym2.mem.other' {α : Type u} [decidable_eq α] {a : α} {z : sym2 α} (h : a z) :
α

Get the other element of the unordered pair using the decidable equality. This is the computable version of mem.other.

Equations
@[simp]
theorem sym2.mem_other_spec' {α : Type u} [decidable_eq α] {a : α} {z : sym2 α} (h : a z) :
@[simp]
theorem sym2.other_eq_other' {α : Type u} [decidable_eq α] {a : α} {z : sym2 α} (h : a z) :
theorem sym2.mem_other_mem' {α : Type u} [decidable_eq α] {a : α} {z : sym2 α} (h : a z) :
theorem sym2.other_invol' {α : Type u} [decidable_eq α] {a : α} {z : sym2 α} (ha : a z) (hb : sym2.mem.other' ha z) :
theorem sym2.other_invol {α : Type u} {a : α} {z : sym2 α} (ha : a z) (hb : sym2.mem.other ha z) :