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.Basic
). The equivalence is Sym2.equivSym
.
From the point of view that an unordered pair is equivalent to a
multiset of cardinality two (see Sym2.equivMultiset
), there is a
Mem
instance Sym2.Mem
, which is a Prop
-valued membership
test. Given h : a ∈ z
for z : Sym2 α
, then Mem.other h
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.fromRel
which is a special case of Sym2.lift
.
Notation #
The element Sym2.mk (a, b)
can be written as s(a, b)
for short.
Tags #
symmetric square, unordered pairs, symmetric powers
One can use attribute [local instance] Sym2.Rel.setoid
to temporarily
make Quotient
functionality work for α × α
.
Equations
- Sym2.Rel.setoid α = { r := Sym2.Rel α, iseqv := ⋯ }
Instances For
s(x, y)
is an unordered pair,
which is to say a pair modulo the action of the symmetric group.
It is equal to Sym2.mk (x, y)
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pretty printer defined by notation3
command.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependent recursion principal for Sym2
when the target is a Subsingleton
type.
See Quot.recOnSubsingleton
.
Equations
Instances For
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.fromRel
instead.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A two-argument version of Sym2.lift
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
mk a
as an embedding. This is the symmetric version of Function.Embedding.sectL
.
Instances For
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 α
.
Instances For
Given an element of the unordered pair, give the other element using Classical.choose
.
See also Mem.other'
for the computable version.
Equations
Instances For
Equations
- Sym2.Mem.decidable x z = Sym2.recOnSubsingleton z fun (x_1 : α × α) => match x_1 with | (fst, snd) => decidable_of_iff' (x = fst ∨ x = snd) ⋯
Note: Sym2.map_id
will not simplify Sym2.map id z
due to Sym2.map_congr
.
Partial map. If f : ∀ a, p a → β
is a partial function defined on a : α
satisfying p
,
then pmap f s h
is essentially the same as map f s
but is defined only when all members of s
satisfy p
, using the proof to apply f
.
Equations
Instances For
"Attach" a proof P a
that holds for all the elements of s
to produce a new Sym2 object
with the same elements but in the type {x // P x}
.
Equations
- s.attachWith h = Sym2.pmap Subtype.mk s h
Instances For
Diagonal #
Equations
- Sym2.IsDiag.decidablePred α z = Sym2.recOnSubsingleton z fun (a : α × α) => decidable_of_iff' (a.1 = a.2) ⋯
Declarations about symmetric relations #
Equations
- Sym2.fromRel.decidablePred sym z = Sym2.recOnSubsingleton z fun (x : α × α) => h x.1 x.2
The inverse to Sym2.fromRel
. Given a set on Sym2 α
, give a symmetric relation on α
(see Sym2.toRel_symmetric
).
Instances For
Mapping an unordered pair to an unordered list produces a multiset of size 2
.
The members of an unordered pair are members of the corresponding unordered list.
The members of an unordered pair are members of the corresponding finite set.
Mapping an unordered pair on the diagonal to a finite set produces a finset of size 1
.
Mapping an unordered pair off the diagonal to a finite set produces a finset of size 2
.
Equivalence to the second symmetric power #
The symmetric square is equivalent to length-2 vectors up to permutations.
Equations
Instances For
The symmetric square is equivalent to the second symmetric power.
Equations
Instances For
Given [DecidableEq α]
and [Fintype α]
, the following instance gives Fintype (Sym2 α)
.
Equations
- Sym2.instDecidableRel x✝¹ x✝ = decidable_of_iff' (x✝¹.1 = x✝.1 ∧ x✝¹.2 = x✝.2 ∨ x✝¹.1 = x✝.2 ∧ x✝¹.2 = x✝.1) ⋯
Equations
Equations
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.Mem.other' h = Sym2.rec (motive := fun (x : Sym2 α) => a ∈ x → α) (fun (s : α × α) (x : a ∈ Sym2.mk s) => Sym2.pairOther✝ a s) ⋯ z h