I'm reading a book on algorithms and I see they wrote the following step function to minimize the function $f(x)$, where the values of $x$ are infeasible if they are greater than $d$.
$$f_{\infty-step} = \begin{cases} f(x), & \text{if $x \le d$} \\ \infty, & \text{if $x \gt d$} \end{cases}$$
as $$ = f(x) + \infty(x \gt d)$$
Where I assume that the result of $(x \gt d)$ is $0$ or $1$, because they want to minimize the function $f(x)$ wrt $x$. But as far as I know, $\infty$ times $0$ is undefined. So is it correct to write it like this ? If yes, why so?
A lot of times when dealing with the extended real numbers $\mathbb{\overline R}:=\mathbb{R}\cup\{-\infty,\infty\}$ one defines
$$0\cdot \infty = 0.$$
Remember that $\infty$ in this context is just a formal symbol that we define to have some properties that we expect from infinity, i.e. it is not a number in the normal sense, and so we are also allowed to define it this way if it helps us. If we want to use your notation now we could then define
$$(x>d) := \chi_{(d,\infty)}(x),$$
where $\chi_A$ is what is often used instead to denote the characteristic function, which is defined so that $\chi_A(x)=1$ if $x\in A$ and $\chi_A(x)=0$ if $x\notin A$. Then, as we usually also define
$$a+\infty=\infty$$
for $a\neq -\infty$ we can write
$$f_{\infty-\mathrm{step}}(x)=f(x)+\infty\cdot(x>d).$$
Keep in mind that this is all quite non-standard however, and a piecewise definition as you also provided would probably be preferable in most cases.