We have two decision variables $x \in \mathbb{Z}^{0+}$ that is the main decision variable and $0 \leqslant y \leqslant 1$ that is an auxiliary decision variable.
Now based on the nature of the problem we are studying, we know that $$y = \frac{1}{x}, \\ x=0 \Leftrightarrow y=\emptyset, \\ x>0 \Leftrightarrow y\geqslant0. $$ Now the challenge is how to formulate the dynamics of these two decision variables in the constraints of a mathematical program. We have $x$ in the denominator and since at optimality $x$ can actually be zero, this would create a problem. Obviously, we cannot write $xy=1$ because if the optimal solution is that $x=0$, the equality would be violated.
Any suggestions would be much appreciated.
Assume we have an a priori upper bound $M$ (integer) on $x$. Introduce binary variables $z_0, z_1, \dots, z_M$, where $z_j=1$ if and only if $x=j$. Add the constraint $$x=\sum_{j=0}^M j*z_j$$ to define $x$ in terms of the new variables, and the constraint $$\sum_{j=0}^M z_j=1$$ to ensure that $x$ is uniquely determined. Finally, add the constraint $$y=\sum_{j=1}^M \frac{1}{j}*z_j$$to define $y$. Note that $x=0$ implies $y=0$ here.
There is no way to formulate a proper optimization model so as to make a variable "undefined" under certain circumstances. If letting $y=0$ when $x=0$ causes problems elsewhere in the model, you need to determine a numerical value for $y$ that can function as "undefined" in the remaining constraints.