# Set that keeps unique categories of objects

I would like to know if this type of special set operator exists, and if yes what is it called and if it has any other special properties.

Lets say I have this set $S$ of items. Like all sets, if the same item is added twice in the set, the set will not add it again. However, when adding an item, using this special operator, it also checks if it is 'better' than another item already in the set, and if yes it replaces it with the new item rather than letting both.

For a more concrete example:

$S_1 = \{apple, orange, pear\}$

$S_2 = \{betterApple, orange, banana\}$

$S = S_1 \cup_\succ S_2 = \{betterApple, orange, pear, banana\}$

So in this case $\cup_\succ$ checked some relationship, lets say $\succ$ where $betterApple \succ apple$, and if such a relationship existed it dropped $apple$ rather than allowing both in the set, keeping the stronger one in the set.

• Any dictionary does what you want, don't they? (I don't know of a corresponding mathematical construct.) – Raphael Apr 30 '14 at 17:39
• What is the structure of the partial order $\prec$? Does it have finite height, finite width, etc.? – D.W. Apr 30 '14 at 19:24
• @D.W. not sure what you mean about finite height and width. The $\succ$ binary relation just says that an item is larger, or better, or stronger than another item of the same type. However if such a relation does not exist this special union operator will add both to the set. – jbx May 1 '14 at 12:32
• @Raphael How is a dictionary applicable in this case? It is just a mapping from keys to values. It does not imply a partial order between some elements. – jbx May 1 '14 at 12:43

## 1 Answer

There is no official operation that accomplishes what you want, but you can always define an operation $\cup_{\succ}$ which does so. Just define the operation in words.

If for some reason you want a "physical" implementation, then here is one way. Each set is a collection of pairs, i.e. \begin{align*} S_1 &= \{ (apple,apple), (orange,orange), (pear,pear) \}, \\ S_2 &= \{ (apple,betterApple), (orange,orange), (banana,banana) \}. \end{align*} Furthermore, there is some partial order $\prec$ such that $(x,y),(z,w)$ are comparable iff $x = z$. When you take the union $S_1 \cup S_2$, you get $$S_1 \cup S_2 = \{ (apple,apple), (apple,betterApple), (orange,orange), (pear,pear), (banana,banana) \}.$$ Then you can define a function $$\phi(S) = \{ x \in S : \text{ no y \in S satisfies y \succ x } \}.$$ What you want is $\phi(S_1 \cup S_2)$.

• Thanks. Yes I just wanted to check if there exists some term which is widely known that achieves this. Its no problem to define $\succ$ as a partial function that takes two items of the same type and returns the stronger one. Or I could have a function $\phi(x, y) = \{\{x\} if x \succ y; \{y\} if y \succ; \{x,y\} otherwise \}$ – jbx May 1 '14 at 12:38