9
 a + b = c
 c - a = b

Ok, now

 a & b = c
 c ?? a = b

which operator replace "??" ?
Thanks

3
  • 1
    So now you know that & doesn't have an inverse operation. Now see if you can generalize the problem: do any of the logical operators have inverses? Mar 26, 2014 at 14:45
  • Shame on me, I must use "Inverse" instead of "Reverse". Eric Lippert, your question is very important, why you don't post it?
    – Phiber
    Mar 26, 2014 at 15:03
  • 1
    I think he was suggesting it to you as an exercise. The short answer is "yes". If for any given a there are no two different values of b that map to the same c, then it has an inverse. The most famous example is probably XOR. The most trivial is a OP b = b.
    – timbo
    Mar 26, 2014 at 22:35

4 Answers 4

23

There is no such operator, because it will be ill-defined if it exists:

so, let a = 0, c = 0

we have

a & 0 = c
a & 1 = c

then, we should have

c ?? a = 0   and  c ?? a = 1

, but an operator/function cannot return two values given the same input/parameters.

0
22

It's impossible. This is because a & b is a lossy transformation.

You don't know whether any dropped 1 bits were part of a or b.

4
  • 1
    This is wrong. If you know c and a you can recover b.
    – Paul
    Mar 26, 2014 at 14:04
  • 4
    @Paulpro: I disagree. E.g. if c and a are both zero, then b can be anything. Methinks I keep my job; for the time being.
    – Bathsheba
    Mar 26, 2014 at 14:05
  • 1
    @Paulpro: we'll publish jointly.
    – Bathsheba
    Mar 26, 2014 at 14:07
  • 2
    I've been thinking about this some more - it's an interesting question - and I came to the conclusion that having a lossy transformation for certain values might not be enough reason that there is no reverse operator. For instance, multiplication has a reverse, but it is lossy for one of the operands == 0 (just like &&). I wonder if there is a three-valued logical operator a ? b where 0 ? . is undefined (just like 0/0) and 1 ? b is b. I haven't been able to find one. Mar 31, 2014 at 20:03
12

You can't.

0 && 0 == 0
1 && 0 == 0

To reverse this, you'd need an operator that gives back both 0 and 1.

(But if b == 1 you do of course know that a == c.)

0
0

No operator can replace "??" ! Only relation (logical relation !) b = (c=a)x2 + (not c) can replace ""??".

J.Kawecki: Logical Relations. Warsaw,2019 Druk24h.pl

1
  • I think your post might benefit from using stackoverflow.com/editing-help And please make more obvious what the last line contributes to the answer. It looks like a post signature, which is not appreciated on StackOverflow. That is what your profile is for.
    – Yunnosch
    Oct 15, 2022 at 7:16

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.