mathlib documentation

data.​sym2

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 a ∈ z for z : sym2 α, it does not appear to be possible, in general, to computably give the other element in the pair. For this, sym2.vmem a z is a Type-valued membership test that gives a way to obtain the other element with sym2.vmem.other.

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

@[instance]
def sym2.​rel.​setoid (α : Type u) :
setoid × α)

Equations
def sym2  :
Type uType 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

def sym2.​map {α : Type u_1} {β : Type u_2} :
(α → β)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 : α → β} :

Declarations about membership

def sym2.​mem {α : Type u} :
α → 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
@[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)

@[nolint]
def sym2.​vmem {α : Type u} :
α → sym2 αType u

This is a type-valued version of the membership predicate mem that contains the other element y of z such that z = ⟦(x, y)⟧. It is a subsingleton already, so there is no need to apply trunc to the type.

Equations
@[instance]
def sym2.​subsingleton {α : Type u} (x : α) (z : sym2 α) :
subsingleton {y // z = (x, y)}

Equations
  • _ = _
def sym2.​mk_has_vmem {α : Type u} (x y : α) :

The vmem version of mk_has_mem.

Equations
@[instance]
def sym2.​has_lift {α : Type u} {a : α} {z : sym2 α} :

Equations
def sym2.​vmem.​other {α : Type u} {a : α} {p : sym2 α} :
sym2.vmem a p → α

Given an element of a term of the symmetric square (using vmem), retrieve the other element.

Equations
theorem sym2.​vmem_other_spec {α : Type u} {a : α} {z : sym2 α} (h : sym2.vmem a z) :
z = (a, h.other)

The defining property of the other element is that it can be used to reconstruct the term of the symmetric square.

def sym2.​mem.​other {α : Type u} {a : α} {z : sym2 α} :
a z → α

This is the mem-based version of other.

Equations
theorem sym2.​mem_other_spec {α : Type u} {a : α} {z : sym2 α} (h : a z) :

theorem sym2.​other_is_mem_other {α : Type u} {a : α} {z : sym2 α} (h : sym2.vmem a z) (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.​elems_iff_eq {α : Type u} {x y : α} {z : sym2 α} :
x y(x z y z z = (x, y))

def sym2.​diag {α : Type u} :
α → 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} :
sym2 α → Prop

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

Equations
theorem sym2.​is_diag_iff_proj_eq {α : Type u} (z : α × α) :

@[instance]

Equations

Declarations about symmetric relations

def sym2.​from_rel {α : Type u} {r : α → α → Prop} :
symmetric rset (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

@[instance]
def sym2.​from_rel.​decidable_as_set {α : Type u} {r : α → α → Prop} (sym : symmetric r) [h : decidable_rel r] :
decidable_pred (λ (x : sym2 α), x sym2.from_rel sym)

Equations
@[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 // s.card = 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 α] :
α × αα × αbool

An algorithm for computing sym2.rel.

Equations
theorem sym2.​rel_bool_spec {α : Type u} [decidable_eq α] (x y : α × α) :

@[instance]
def sym2.​decidable_rel (α : Type u_1) [decidable_eq α] :

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

Equations