Converting this logic condition possible without programming?
Your logic can be rewritten much more simply as a table.

Signal DIP | Relay
-----------+-------
  0     0  |   off
  0     1  |   on
  1     0  |   on
  1     1  |   off


It now becomes clear that this is an XOR, exclusive OR, function.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. The XOR logic effectively acts as a buffer or inverter depending on the position of SW1.

XOR chips are available in all logic families. If you choose an XNOR (inverting) instead then tie R1 to V+ rather than ground.