# How to Implement a reversible OR operator with a Fredkin gate (controlled swap)?

How to implement a reversible OR operator with a Fredkin gate ?

To better see this, write the general action of a Fredkin on an input as following: $$\begin{pmatrix}a\\b\\ c\end{pmatrix}\mapsto \begin{pmatrix} a \\ (a c)\oplus[(1\oplus a)b] \\ (a b)\oplus[(1\oplus a)c] \end{pmatrix}.$$ Note that this is just rewriting the action of the Fredkin algebraically.
Then, if you use as input $$(a,b,1)$$, you get
$$\begin{pmatrix}a\\b\\ 1\end{pmatrix}\mapsto \begin{pmatrix} a \\ a\oplus[(1\oplus a)b] \\ (a b)\oplus(1\oplus a) \end{pmatrix},$$ which is what you want as soon as you notice that $$a \oplus b\oplus ab=a\,\operatorname{OR}\, b$$.