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
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
- sym2 α = quotient (sym2.rel.setoid α)
Declarations about membership #
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
- sym2.has_mem = {mem := sym2.mem α}
Given an element of the unordered pair, give the other element using classical.some
.
See also mem.other'
for the computable version.
Equations
Equations
- sym2.mem.decidable x z = quotient.rec_on_subsingleton z (λ (_x : α × α), sym2.mem.decidable._match_1 x _x)
- sym2.mem.decidable._match_1 x (y₁, y₂) = decidable_of_iff' (x = y₁ ∨ x = y₂) sym2.mem_iff
Equations
- sym2.is_diag.decidable_pred α = λ (z : sym2 α), quotient.rec_on_subsingleton z (λ (a : α × α), _.mpr (_inst_1 a.fst a.snd))
Declarations about symmetric relations #
Symmetric relations define a set on sym2 α
by taking all those pairs
of elements that are related.
Equations
- sym2.from_rel sym = quotient.lift (function.uncurry r) _
Equations
- sym2.from_rel.decidable_pred sym = λ (z : sym2 α), quotient.rec_on_subsingleton z (λ (x : α × α), h x.fst x.snd)
Equivalence to the second symmetric power #
The symmetric square is equivalent to length-2 vectors up to permutations.
Equations
- sym2.sym2_equiv_sym' = {to_fun := quotient.map (λ (x : α × α), ⟨[x.fst, x.snd], _⟩) sym2.sym2_equiv_sym'._proof_2, inv_fun := quotient.map from_vector sym2.sym2_equiv_sym'._proof_3, left_inv := _, right_inv := _}
The symmetric square is equivalent to the second symmetric power.
Equations
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
Given [decidable_eq α]
and [fintype α]
, the following instance gives fintype (sym2 α)
.
Equations
- sym2.rel.decidable_rel α = λ (x y : α × α), decidable_of_bool (sym2.rel_bool x y) _
Get the other element of the unordered pair using the decidable equality.
This is the computable version of mem.other
.