---
title: "Subsets of a Finite Set"
canonical: "https://docs.magma-maths.org/v2.30-1/Combinatorics/EnumerativeCombinatorics/subsets.html"
source: "https://docs.magma-maths.org/v2.30-1/Combinatorics/EnumerativeCombinatorics/subsets.md"
part: "Combinatorics"
chapter: "Enumerative Combinatorics"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Combinatorics", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/index-combinatorics.md"}
  - {"title": "Enumerative Combinatorics", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/EnumerativeCombinatorics/index-enumerative-combinatorics.md"}
prev: {"title": "Combinatorial Functions", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/EnumerativeCombinatorics/combinatorics.md"}
next: {"title": "Partitions, Words, and Young Tableaux", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/PartitionsWordsTableaux/index-partitions-words-tableaux.md"}
intrinsics:
  - {"name": "Subsets", "signature": "Subsets(S): SetEnum -> SetEnum"}
  - {"name": "Subsets", "signature": "Subsets(S, k): SetEnum, RngIntElt -> SetEnum"}
  - {"name": "Multisets", "signature": "Multisets(S, k): SetEnum, RngIntElt -> SetEnum"}
  - {"name": "Subsequences", "signature": "Subsequences(S, k): SetEnum, RngIntElt -> SetEnum"}
  - {"name": "Permutations", "signature": "Permutations(S): SetEnum -> SetEnum;"}
  - {"name": "Permutations", "signature": "Permutations(S, k): SetEnum, RngIntElt -> SetEnum;"}
examples:
  - "ex-676132"
---

# Subsets of a Finite Set

<a id="function-subsets-setenum"></a>
## `Subsets(S): SetEnum -> SetEnum`

The set of all subsets of the set $S$.

<a id="function-subsets-setenum-rngintelt"></a>
## `Subsets(S, k): SetEnum, RngIntElt -> SetEnum`

The set of subsets of the set $S$ of size $k$. If $k$ is larger than the cardinality of $S$ then the result will be empty.

<a id="function-multisets-setenum-rngintelt"></a>
## `Multisets(S, k): SetEnum, RngIntElt -> SetEnum`

The set of multisets consisting of $k$ not necessarily distinct elements of the set $S$.

<a id="function-subsequences-setenum-rngintelt"></a>
## `Subsequences(S, k): SetEnum, RngIntElt -> SetEnum`

The set of sequences of length $k$ with elements from the set $S$.

<a id="function-permutations-setenum"></a>
## `Permutations(S): SetEnum -> SetEnum;`

The set of permutations (stored as sequences) of the elements of the set $S$.

<a id="function-permutations-setenum-rngintelt"></a>
## `Permutations(S, k): SetEnum, RngIntElt -> SetEnum;`

The set of permutations (stored as sequences) of each of the subsets of the set $S$ of cardinality $k$.

<a id="example-ex-676132"></a>
## `Example: Petersen Graph as an Odd Graph (ex-676132)`

The use of Subsets is illustrated in the construction of the Petersen graph as the third Odd Graph. The $n$th Odd Graph has its vertices in correspondence with the $(n-1)$-element subsets of $\lbrace 1 \ldots 2n-1 \rbrace$, and an edge between two vertices if and only if their corresponding sets have empty intersection.

```magma
> V := Subsets( {1 .. 2*n-1}, n-1) where n is 3;
> V;
{
    { 1, 5 },
    { 2, 5 },
    { 1, 3 },
    { 1, 4 },
    { 2, 4 },
    { 3, 5 },
    { 2, 3 },
    { 1, 2 },
    { 3, 4 },
    { 4, 5 }
}
> E := { {u, v} : u,v in V | IsDisjoint(u, v) };
> Petersen := Graph< V | E >;
```
