How would one solve this boolean algebraic equation?

119 Views Asked by At

During software testing I needed to find at least one solution for this:

(a or (b and c)) != ((a or b) and c)

Where all variables are boolean.

I can (and did) solve it with brute-force (if you can call so few combinations brute-force):

for a in (True, False):
    for b in (True, False):
        for c in (True, False):
            if (a or (b and c)) != ((a or b) and c):
                print a, b, c

Which yields two solutions:

True True False
True False False

I'm curious if theres a way to solve this algebraically? And if so can somebody please show the process.

1

There are 1 best solutions below

0
On

Surely this can be solved algebraically. We have $$a \lor bc \ne (a\lor b)c$$ $$a \lor bc \ne ac \lor bc$$

If $bc=true$ they will be equal. So we get:

\begin{cases} bc=false \\ a\ne ac \\ \end{cases}

From second follows that $a \ne false$ and $c = false$. Since $c = false$, $b$ may have any value. So we get those solutions.