Electronic – Help in the closing of a logic circuit

logic-gates

I'm currently studying logic circuits for my exams and came across a question "7. An electrical circuit is set up with four switches. A lamp will light only if the following happens:

  • Switches A and B are both on.
  • Either Switch C or Switch D is on, but not both.

Draw a logic circuit to represent this. I made a AND gate for A and B, made an XOR gate for C and D but don't know how to close the circuit into one output as I now have two outputs. I hope you guys understand my situation and help with it, Thank you. If this is the wrong site please lead me to the correct site, please.

Best Answer

This is an English language problem. You've been given a specification in natural language, and are struggling to turn it into explicit logic.

Switches A and B are both on.

You've used an AND gate for this, correct, that clause is (a AND b), let's call this partial result e.

Either Switch C or Switch D is on, but not both.

You've used an XOR gate for this, correct, that clause is (c XOR d), let's call this partial result f.

So far, you've reduced the whole expression to ...

A lamp will light only if the following happens: e ? f

Now, does 'only if' mean it lights if e AND f, or does it mean e OR f?

This is why engineers get themselves into trouble, accepting a job with a specification written in English, and then realising they don't actually know what it's asking until they come to implement it. 'Only if' sounds a bit logiccy doesn't it.

'Only if' is not used in logic. There is a term 'if and only if', usually expressed as IFF. However, IFF is a biconditional, it's designed to express a truth about a system, rather than as a formula for getting a result from inputs. For instance 'I have a brother IFF my sibling is male'. (Something) IFF (conditional).

As you're trying to make a logic formula work, it clearly doesn't mean IFF, but IF. So we have ...

(A lamp will light) IF (e ? f).

The IF still hasn't clarified whether that ? should be AND or OR, or even something else. English is not precise enough. It could mean either of those.

Let's put the 'only' back in again, to see if it helps to qualify whether it's AND or OR.

A lamp will light ONLY if BOTH the following happens: e ? f

A lamp will light ONLY if EITHER the following happens: e ? f

As a native English speaker, the first one sounds reasonable, if unusual, but the second one sounds really odd. If English wasn't my first language, then I may not come to that conclusion.

This may be a question designed to test whether you can spot ambiguities like this, and say that the question is underdetermined.

However, if I was taking an examination, and believed that there 'was only one correct answer', then I'd plump for AND, that's my best reading of the English.

If I was implementing a product from a customer's specification, I would go back to them and ask them if that's what they really meant.