The symmetric square #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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.basic
). 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.
The universal property of sym2
is provided as sym2.lift
, which
states that functions from sym2 α
are equivalent to symmetric
two-argument functions from α
.
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
which is a special case of sym2.lift
.
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 α)
The universal property of sym2
; symmetric functions of two arguments are equivalent to
functions from sym2
. Note that when β
is Prop
, it can sometimes be more convenient to use
sym2.from_rel
instead.
Equations
- sym2.lift = {to_fun := λ (f : {f // ∀ (a₁ a₂ : α), f a₁ a₂ = f a₂ a₁}), quotient.lift (function.uncurry ↑f) _, inv_fun := λ (F : sym2 α → β), ⟨function.curry (F ∘ quotient.mk), _⟩, left_inv := _, right_inv := _}
A two-argument version of sym2.lift
.
Equations
- sym2.lift₂ = {to_fun := λ (f : {f // ∀ (a₁ a₂ : α) (b₁ b₂ : β), f a₁ a₂ b₁ b₂ = f a₂ a₁ b₁ b₂ ∧ f a₁ a₂ b₁ b₂ = f a₁ a₂ b₂ b₁}), quotient.lift₂ (λ (a : α × α) (b : β × β), f.val a.fst a.snd b.fst b.snd) _, inv_fun := λ (F : sym2 α → sym2 β → γ), ⟨λ (a₁ a₂ : α) (b₁ b₂ : β), F ⟦(a₁, a₂)⟧ ⟦(b₁, b₂)⟧, _⟩, left_inv := _, right_inv := _}
Membership and set coercion #
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.set_like = {coe := λ (z : sym2 α), {x : α | sym2.mem x z}, coe_injective' := _}
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
Note: sym2.map_id
will not simplify sym2.map id z
due to sym2.map_congr
.
Diagonal #
A predicate for testing whether an element of sym2 α
is on the diagonal.
Instances for sym2.is_diag
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 #
Equations
- sym2.from_rel.decidable_pred sym = λ (z : sym2 α), quotient.rec_on_subsingleton z (λ (x : α × α), h x.fst x.snd)
The inverse to sym2.from_rel
. Given a set on sym2 α
, give a symmetric relation on α
(see sym2.to_rel_symmetric
).
Equations
- sym2.to_rel s x y = (⟦(x, y)⟧ ∈ s)
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) _
The other element of an element of the symmetric square #
Get the other element of the unordered pair using the decidable equality.
This is the computable version of mem.other
.
Equations
- sym2.unique = unique.mk' (sym2 α)