Filtering elements of a tuple

36 Views Asked by At

Note: I am beginner to this. Please go easy on me.

I have a tuple

$X = {(Y \times Z)}$ where, $Y \in \mathbb{N} \, \& \, Z\in \mathbb{N}$.

I want to write an expression to remove elements based on following conditions:

  1. There exist no two or more elements in X with same value for Y. I hope this definition is right, $\{ \forall x_1,x_2 \in X \mid \nexists \, x_1.y = x_2.y \}$.
  2. And if there exist two or more elements of X with same value for Y, then remove the elements, except the one with least value for Z.

    something like this.. $\{ \forall x_1,x_2 \in X \mid if(x_1.y = x_2.y) \, then \, X \setminus max(x_1.z,x_2.z) \} $ or

    Will this works,

    $Z_x:\{z \mid (y,z) \in Z \}$
    $Z^o: \{ (y,z) \mid (y,z) \in X \wedge z = min(Z_x) \} $
    $Z = Z \setminus Z^o$ ??

I have an another questions too:

How to formally define a function for tuples? I.e if the mapping is based on multiple values in the tuple.

Thanks for your time.