Symmetric powers #
This file defines symmetric powers of a type. The nth symmetric power consists of homogeneous n-tuples modulo permutations by the symmetric group.
The special case of 2-tuples is called the symmetric square, which is
addressed in more detail in Data.Sym.Sym2.
TODO: This was created as supporting material for Sym2; it
needs a fleshed-out interface.
Tags #
symmetric powers
The nth symmetric power is n-tuples up to permutation. We define it
as a subtype of Multiset since these are well developed in the
library. We also give a definition Sym.sym' in terms of vectors, and we
show these are equivalent in Sym.symEquivSym'.
Instances For
Equations
- Sym.hasCoe α n = { coe := Sym.toMultiset }
Equations
- instDecidableEqSym = inferInstanceAs (DecidableEq { s : Multiset α // Multiset.card s = n })
This is the List.Perm setoid lifted to Vector.
See note [reducible non-instances].
Equations
- Vector.Perm.isSetoid α n = Setoid.comap Subtype.val (List.isSetoid α)
Instances For
Inserts an element into the term of Sym α n, increasing the length by one.
Equations
- Sym.«term_::ₛ_» = Lean.ParserDescr.trailingNode `Sym.term_::ₛ_ 67 68 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ::ₛ ") (Lean.ParserDescr.cat `term 67))
Instances For
This is the quotient map that takes a list of n elements as an n-tuple and produces an nth symmetric power.
Equations
- Sym.ofVector x = { val := ↑↑x, property := ⋯ }
Instances For
This is the quotient map that takes a list of n elements as an n-tuple and produces an nth symmetric power.
Equations
- Sym.instCoeVectorSym = { coe := fun (x : Vector α n) => Sym.ofVector x }
α ∈ s means that a appears as one of the factors in s.
Equations
- Sym.decidableMem a s = Multiset.decidableMem a ↑s
This is cons but for the alternative Sym' definition.
Equations
- Sym.«term_::_» = Lean.ParserDescr.trailingNode `Sym.term_::_ 1022 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " :: ") (Lean.ParserDescr.cat `term 0))
Instances For
Multisets of cardinality n are equivalent to length-n vectors up to permutations.
Equations
- Sym.symEquivSym' = Equiv.subtypeQuotientEquivQuotientSubtype (fun (l : List α) => List.length l = n) (fun (s : Multiset α) => Multiset.card s = n) ⋯ ⋯
Instances For
Equations
- Sym.instEmptyCollectionSymOfNatNatInstOfNatNat = { emptyCollection := 0 }
replicate n a is the sym containing only a with multiplicity n.
Equations
- Sym.replicate n a = { val := Multiset.replicate n a, property := ⋯ }
Instances For
Equations
- ⋯ = ⋯
Equations
- Sym.inhabitedSym n = { default := Sym.replicate n default }
Equations
- Sym.inhabitedSym' n = { default := Quotient.mk' (Vector.replicate n default) }
Equations
- Sym.instUniqueSym n = Unique.mk' (Sym α n)
Equations
- ⋯ = ⋯
Note: Sym.map_id is not simp-normal, as simp ends up unfolding id with Sym.map_congr
"Attach" a proof that a ∈ s to each element a in s to produce
an element of the symmetric power on {x // x ∈ s}.
Equations
- Sym.attach s = { val := Multiset.attach ↑s, property := ⋯ }
Instances For
Fill a term m : Sym α (n - i) with i copies of a to obtain a term of Sym α n.
This is a convenience wrapper for m.append (replicate i a) that adjusts the term using
Sym.cast.
Equations
- Sym.fill a i m = (Sym.cast ⋯) (Sym.append m (Sym.replicate (↑i) a))
Instances For
Remove every a from a given Sym α n.
Yields the number of copies i and a term of Sym α (n - i).
Equations
- Sym.filterNe a m = { fst := { val := Multiset.count a ↑m, isLt := ⋯ }, snd := { val := Multiset.filter (fun (x : α) => a ≠ x) ↑m, property := ⋯ } }
Instances For
Combinatorial equivalences #
Function from the symmetric product over Option splitting on whether or not
it contains a none.
Equations
- SymOptionSuccEquiv.encode s = if h : none ∈ s then Sum.inl (Sym.erase s none h) else Sum.inr (Sym.map (fun (o : { x : Option α // x ∈ s }) => Option.get ↑o ⋯) (Sym.attach s))
Instances For
Inverse of Sym_option_succ_equiv.decode.
Equations
Instances For
The symmetric product over Option is a disjoint union over simpler symmetric products.
Equations
- symOptionSuccEquiv = { toFun := SymOptionSuccEquiv.encode, invFun := SymOptionSuccEquiv.decode, left_inv := ⋯, right_inv := ⋯ }