Representing boolean ternary conditional operator by the composition of boolean binary functions

483 Views Asked by At

Recently i was thinking about reprecentation of ternary conditional operator in programming:

"a ? b : c" means "if (a) then b else c".

Obviously it's equivalent to $(a \land b) \lor (\lnot a \land c)$.

Can we go more and represent any boolen f(x,y,z) as follows?

let $f(x,y,0) = g(x,y)$; and $f(x,y,1) = h(x,y)$;

$f(x,y,z) = z?f(x,y,1):f(x,y,0) = (g(x,y) \land \lnot z)) \lor (h(x,y) \land z) $

Can we go slightly more and get this representaion?

$f(x_1,...,x_n) = \bigvee \limits _{a_1,...a_n = \{0,1\}} {(f(a_1,...a_n) \land (x_1 \leftrightarrow a_1) \land ... \land (x_n \leftrightarrow a_n))} $

So, since $x \leftrightarrow y = (x \land y) \lor (\lnot x \land \lnot y)$, we can representi any *-ary function, given by it's truth table $f(a_1,...a_n)$, as the composition of classical binary functions.

Where i went wrong?