0
$\begingroup$

Here we have three binary variables $x_1$, $x_2$, $x_3$ $\in \{0,1\}$.
I want to find the form of the function $f(x_1, x_2, x_3)$ such that the following are satisfied:

if $\ x_1 = 0,\ x_2 = 0,\ x_3 = 0 \ $ then $\ f(x_1, x_2, x_3) = 6$
if $\ x_1 = 0,\ x_2 = 0,\ x_3 = 1 \ $ then $\ f(x_1, x_2, x_3) = 4$
if $\ x_1 = 0,\ x_2 = 1,\ x_3 = 0 \ $ then $\ f(x_1, x_2, x_3) = 5$
if $\ x_1 = 0,\ x_2 = 1,\ x_3 = 1 \ $ then $\ f(x_1, x_2, x_3) = 2$
if $\ x_1 = 1,\ x_2 = 0,\ x_3 = 0 \ $ then $\ f(x_1, x_2, x_3) = 5$
if $\ x_1 = 1,\ x_2 = 0,\ x_3 = 1 \ $ then $\ f(x_1, x_2, x_3) = 3$
if $\ x_1 = 1,\ x_2 = 1,\ x_3 = 0 \ $ then $\ f(x_1, x_2, x_3) = 4$
if $\ x_1 = 1,\ x_2 = 1,\ x_3 = 1 \ $ then $\ f(x_1, x_2, x_3) = 0$

I imagine it like having a "virtual sum" which starts at 1 and it is increased by 1 at each step in the sequence. Every time I see a zero, this virtual sum "becomes real" and is reset. For instance:

  • $\ x_1 = 1,\ x_2 = 1,\ x_3 = 0 \ $ After seeing the first one the virtual sum is 2. After the second one the virtual sum is 3. Finally there is a zero, so the virtual sum becomes 4, "becomes real" and is reset. The final result is 4.
  • $\ x_1 = 0,\ x_2 = 1,\ x_3 = 0 \ $ After seeing the first zero the sum is 2 and the virtual sum is reset to 1. After the second one the virtual sum is 2. Finally there is a zero, so the virtual sum is incremented at 3 and "becomes real". The final result is 2 + 3 = 5.
  • $\ x_1 = 1,\ x_2 = 1,\ x_3 = 1 \ $ We have three ones, so the virtual sum is 4 at the end of the sequence. However, since there are no zeroes it does not "become real" and the result is 0.
  • $\ x_1 = 0,\ x_2 = 0,\ x_3 = 0 \ $ We have three zeroes, so we get 2 at each step and the sum is 6.

I had already asked a similar question (Find the binary input function given the outputs), which was (brilliantly) solved. This is a generalisation in which the "virtual sum" starts from one rather then zero and that, with respect to the previous question, inverts the binary value of the variables $x_1$, $x_2$, $x_3$.

$\endgroup$

1 Answer 1

0
$\begingroup$

How about (completed) $$f(x_1,x_2,x_3) = 6\cdot (1-x_1)(1-x_2)(1-x_3) + 4\cdot (1-x_1)(1-x_2)x_3 \\+ 5\cdot (1-x_1)x_2(1-x_3) + 2\cdot (1-x_1)x_2x_3 +5\cdot x_1(1-x_2)(1-x_3) + 3\cdot x_1(1-x_2)x_3 + 4\cdot x_1x_2(1-x_3) + 0\cdot x_1x_2x_3.$$

$\endgroup$
3
  • $\begingroup$ Is the complete formula $f(x_1,x_2,x_3) = 6(1-x_1)(1-x_2)(1-x_3) + 4(1-x_1)(1-x_2)x_3 + 2(1-x_1)x_2x_3$? Because it doesn't work for many inputs. Try (0,1,0) for example. $\endgroup$
    – aprospero
    Commented Jan 16, 2019 at 16:26
  • $\begingroup$ No I guess you got the idea. You need to complete it. $\endgroup$
    – Wuestenfux
    Commented Jan 16, 2019 at 16:30
  • $\begingroup$ Oooh! I got the point. So it is enough to hardcode the output sequence I want and then simplify the expression. Wow, did not come into my mind! Also I can easily generalise at 4, 5 variables and search for a pattern. Thank you @Wuestenfux, really helpful! $\endgroup$
    – aprospero
    Commented Jan 16, 2019 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .