Are there dictionaries in math? Consider the following dictionary in the programming language Python:

D = {'A': 1, 'B': 2, 'C': 3}


It is saying that the value of A is 1, the value of B is 2, and the value of C is 3. It also has the property that D['A'] = 1 etc.

How would I write such thing in math? I was thinking about 

$$D = \{A = 1, B = 2, C = 3\}.$$

However, I am not sure if this is the right or best way to do such thing.

I would like to use the structure for taking sums: e.g. 'AAAA' is interpreted as $1+1+1+1$ etc. What kind of notation should I use?
A dictionary is just a function $\mathrm{Dict}\colon \mathrm{Keys} \rightarrow \mathrm{Values}\cup\{\epsilon\}$ where $\epsilon$ is a "null character" with the understanding that $\epsilon\notin\mathrm{Values}$.

For example, let $\mathrm{Keys}=\{A,B,C,...,Z\}$, and $\mathrm{Values}=\mathbb{Z}$. Then, in your case,

$$
\mathrm{Dict}(x)=\begin{cases}
1 &amp; \text{if }x=A\\
2 &amp; \text{if }x=B\\
3 &amp; \text{if }x=C\\
\epsilon &amp; \text{otherwise}
\end{cases}
$$
A dictionary is a partial function from the key space $K$ to the value space $V$, where $K$ is the set of all hashable objects, and $V$ is the set of all Python objects.

A partial function from $K$ to $V$ is a subset of $K\times V$ with the condition that for each $k\in K$ it contains at most one pair that has $k$ as first element. The difference to a function is that a function needs to have exactly one pair with $k$ as first element.

$K\times V$ is the set of pairs $(k,v)$ with $k\in K$ and $v\in V$.