1
$\begingroup$

How can you formularize "if"-conditions in a language-agnostic way?

I'm talking about formulas like

$ x=\begin{cases} 2,&\text{ if } n \le 2 \lor m=3\\ 3,&\text{ if } n \gt 2 \land m=n \end{cases} $ Of course, everybody in the world will understand the "if", but is there a way to write it completely without using any "real world" language whatsoever?

  • 1
    It's merely for demonstration, no matter what the actual values are. The point of interest is the `if`, not the formula as such2012-05-07

2 Answers 2

5

If you absolutely insist, you can use Iverson brackets:

$x=\begin{cases} 2,&\text{ if } n \le 2 \lor m=3\\ 3,&\text{ if } n \gt 2 \land m=n \end{cases}$

is equivalent to

$x=2+[n>2][m=n]\;.$

But the first version is easier to read, and while I don't at all mind $\lor$ and $\land$, $\text{or}$ and $\text{and}$ are preferable for most audiences.

2

I was tought that if ... then is written in such form:

$ x>0 \Rightarrow y=2x $

which means if $x$ is greater than 0 then assign $2x$ to $y$.