Applying function over elements of multiset

179 Views Asked by At

Let $A$ be a multiset of tuples: $A = \{(a_1, a_2), (a_1, a_2), (a_3, a_4), (a_3, a_4), (a_3, a_4), (a_2, a_1), (a_2, a_1), (a_2, a_1), (a_2, a_1)\}$ and $\alpha: A \multimap N$ a multivalued function that maps all elements of $A$ onto the set of natural numbers.

Let's suppose, $\alpha$ mapped over each element in $A$ returns $\{2, 3, 1, 4, 2, 2, 1, 3, 8\}$. So $\alpha((a_1, a_2))=2$, $\alpha((a_1, a_2))=3$, $\alpha((a_3, a_4))=1$ $\dots$ $\alpha((a_2,a_1))=8$.

How can I define a function that returns a subset of $A$ that includes only tuples which are above a threshold $t=2$?

Would this notation be correct?

$\beta = \{ a \in A \ \land \alpha(a) > t \}$

$\beta = \{ (a_1, a_2), (a_3, a_4), (a_2, a_1), (a_2, a_1) \}$

Also, how can I define a function $\gamma$ that would return for each duplicate tuple in $A$ the one with the highest value of $\alpha$?

$\gamma = \text{max(} a \text{)} \ \text{for each} \ a \in A$

$\gamma = \{(a_1, a_2), (a_3, a_4), (a_2, a_1)\}$ (these tuples would return 3, 4, 8 when $\alpha$ is being applied)

1

There are 1 best solutions below

1
On

Multiset abstraction and set extensions of functions are your friends. Multiset abstraction is

$$ \{ a \mid a \in S \}$$

and multiset extension of the function $\alpha$ is

$$ \alpha(A) = \{ y \mid \exists a \in A. \alpha(a) = y \} $$

Now write

$$ \beta_t(A) = \{ a \in \alpha(A) \mid a \geq t \}$$

for the threshold function, where all operations involved are operations on multisets, and write

$$ \gamma(A) = \{ a \in \alpha(A) \mid a = \max \{ \alpha(B) \mid B \subseteq A, |B| \geq 2 \} \} $$