3 ms·
Actually addition is reversible, as long as you do it inline. The inverse of `a += b` is `a -= b`. An example of an action that's not reversible is masking: `a
by Strilanc 7y ago
Actually addition is reversible, as long as you do it inline. The inverse of `a += b` is `a -= b`.
An example of an action that's not reversible is masking: `a &= b`. But if you dig deep enough into the physics, you find that these kinds of irreversible actions are actually always implemented in a way analogous to the following:
// a &= b
acquire zero'd register z from environment
z ^= a & b
z ^= a
a ^= z
z ^= a
discard z into environment
Which can be reversed if you're able to get the discarded `z` register back.
- FakeComments 7y agoYou’re just hiding the loss: The loss in your operation occurs when you zero out z, and there’s no way to implement it without that loss. If it’s reversible, how do you zero out z, from the environment? The energy cost of a computer fundamentally comes from having to use energy and discard information (heat) in clearing z.
- H8crilA 7y agoSee also the Linear logic, a logic in which discarding information is disallowed: https://en.m.wikipedia.org/wiki/Linear_logic https://en.m.wikipedia.org/wiki/Linear_logic
- SamReidHughes 7y agoThe function (a,b) -> a+b is not reversible. The function a -> a+b is reversible, and so is (a,b) -> (a+b, b).