4-bit Subtractor

A 4-bit adder does not compute not \(a+b\) but actually \((a+b) mod 16\). Regarding this arithmetic operation, \(G = \{0,1\}^4 \) forms a group. For each \( a \in G\), there exists a unique inverse element \(-a\) concerning addition, and it satisfies the property \( a + (-a) = 0\) (where 0 denotes a bit pattern consisting only of zeros).

The practical application is that subtraction can be reduced to addition. To achieve this, it is only necessary to determine the corresponding bit pattern of \(b\) for any bit pattern \(a\). One can easily derive a rule for this: Adding the bit pattern 1111 to the bit pattern 0001 results in the bit pattern 0000. Adding the inverted bit pattern (in this case, 0101) to a bit pattern (for example, 1010) always results in 1111. If you additionally set Cin to 1, the result is always 0000.

Task

Implement a logic circuit for subtraction in CircuitVerse. Use a 4-bit wide NOT gate to invert the bit pattern of \(b\). Subtraction (analogous to addition) will then calculate \( (a - b) \bmod 16 \), not \(a - b\). Modify the circuit so that Cout indicates 0 when \(a - b = (a - b) \bmod 16\) holds. Otherwise, Cout should have the value 1.