0

Consider the following boolean expression with a nested ternary expression:

$$(\text{if $a < 0$ then $-a$ else $a$}) < 3$$

I can "see" that it can be reduced to:

$$a > -3 \land a < 3$$

However, I can't figure out the algebraic rules I need to apply in order to arrive at the reduced expression.

I got as far as:

$$(\text{if $a < 0$ then $-a$ else $a$}) < 3$$ $$\text{if $a < 0$ then $-a < 3$ else $a < 3$}$$ $$\text{if $a < 0$ then $a > -3$ else $a < 3$}$$ $$(a < 0 \land a > -3) \lor (\lnot(a < 0) \land a < 3)$$ $$(a < 0 \land a > -3) \lor (a \ge 0 \land a < 3)$$

But that's where I'm stuck. I think somewhere in between I should arrive at:

$$(a < 0 \lor a \ge 0) \lor (a > -3 \land a < 3)$$

Or maybe:

$$(a < 0 \lor a \ge 0) \land (a > -3 \land a < 3)$$

Because then the term $(a < 0 \lor a \ge 0)$ would cancel out. So I tried my way backwards from there, but I still no luck.

I feel like I'm missing something quite simple.

2 Answers2

1

You are almost there:

From:

$$(a < 0 \land a > -3) \lor (a \ge 0 \land a < 3)$$

Distribute (FOIL, basically):

$$(a < 0 \lor a \ge 0) \land (a < 0 \lor a < 3) \land (a > -3 \lor a < 3) \land (a > -3 \lor a \ge 0)$$

Now, as you say, $(a < 0 \lor a \ge 0)$ is a mathetical truth, and so can be ignored:

$$ (a < 0 \lor a < 3) \land (a > -3 \lor a < 3) \land (a > -3 \lor a \ge 0)$$

Also, since $a < 0$ implies $a<3$, the term $(a < 0 \lor a < 3)$ reduces to the weakest claim, i.e. to $a < 3$. Likewise, $(a > -3 \lor a \ge 0)$ reduces to $a > -3$:

$$ a < 3 \land (a > -3 \lor a < 3) \land a > -3 $$

Finally, if $a < 3$ and $a > -3$, then certainly $(a > -3 \lor a < 3)$, so that middle term can be completely removed, leaving you with:

$$ a < 3 \land a > -3 $$

Now, note that this transformation was not a purely logical transformation, but that is because the equivalence between your original statement and the statement $ a < 3 \land a > -3 $ is indeed 'merely' a mathematical equivalence, and not a logical one. For, example, $(a < 0 \lor a \ge 0)$ is a mathematical truth, and not a logical one.

Bram28
  • 100,612
  • 6
  • 70
  • 118
  • Thanks for the detailed explanation! Your point about logical vs mathematical truth seems interesting. Do you have some pointers where I could read up on that? – Good Night Nerd Pride Aug 22 '19 at 07:01
  • 1
    @GoodNightNerdPride No pointers, really. Just remember that in logic, only the purely logical operators, like $\land$, $\lor$, $\neg$, or $\forall$ have a fixed meaning. A mathematical relationship, like $<$, however, is in the eyes of logic 'just some 2-place relationship'. And even the constant $0$ is 'just some object from some domain' – Bram28 Aug 23 '19 at 17:52
0

\begin{equation} (a < 0 \land a > -3) \lor (a \ge 0 \land a < 3) \\ (a < 0 \lor a \ge 0) \land (a < 0 \lor a < 3) \land (a > -3 \lor a \ge 0) \land (a > -3 \lor a < 3) \\ 1 \land (a < 3) \land (a > -3) \land 1 \\ (a < 3) \land (a > -3) \end{equation}

RobPratt
  • 45,619