TITLE: Are there dictionaries in math?
QUESTION [51 upvotes]: 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?

REPLY [4 votes]: 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$.