5
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ In case of such question do not hesitate to ask the teacher, assistant or professor to clarify what the question actually means. \$\endgroup\$ – Crowley Jul 18 '18 at 22:15
23
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I think the IFF is closer to what is meant in English. "(A lamp will light) IF (e ? f)." is satisfied when you just return truth as $A \rightarrow \top \equiv \top$. It can be argued that 'only if' implies a necessary condition so while there might be some other conditions (such as working power plant) the lamp must not be turned on unless the conditions are specified "(e ? f) IF (A lamp will light)". \$\endgroup\$ – Maciej Piechotka Jul 19 '18 at 9:15
  • \$\begingroup\$ @MaciejPiechotka quick, before your comment freezes, we use slash dollar here for tex, not just dollar. \$\endgroup\$ – Neil_UK Jul 19 '18 at 9:18
  • \$\begingroup\$ Unfortunatly I just read your comment. I meant \$ A \rightarrow \top \equiv \top \$. \$\endgroup\$ – Maciej Piechotka Jul 19 '18 at 20:51
10
\$\begingroup\$

As Neil_UK showed in his answer, it can be a bit open for interpretation. He has covered pretty much everything, so I can only help further by allowing you to see it visually.

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.

First let us look at the first condition:

  • Switches A and B are both on, but not both

schematic

simulate this circuit – Schematic created using CircuitLab

Now let us look at the second condition:

  • Either switch C or switch D is on, but not both

schematic

simulate this circuit

Great. We now have a circuit with 4 switches. But as you said, you now have 2 outputs. These can now be named E and F:

schematic

simulate this circuit

From here, it can get a bit open to interpretation, but you now have 2 choices. Did the question mean when both of these conditions exist? Meaning that A AND B, and C XOR D is the condition? Or did it mean A AND B, or C XOR D?

Let us look at your 2 possible circuits:

schematic

simulate this circuit

Now, looking at the wording:

A lamp will light only if the following happens:

To me, that sounds like it means the AND circuit is the one you want.

\$\endgroup\$
  • \$\begingroup\$ If anyone knows of a way to make some of these images smaller, by all means edit my answer! Seems a bit strange to have such small circuits in such a huge image! \$\endgroup\$ – MCG Jul 18 '18 at 9:50
  • 3
    \$\begingroup\$ append an "m" to the first 3 image urls: "i.stack.imgur.com/0psSy.png" -> "i.stack.imgur.com/0psSym.png" (again only 3 characters is too small to suggest) \$\endgroup\$ – Nick A Jul 18 '18 at 9:53
  • 1
    \$\begingroup\$ Brilliant! Thank you @NickA. That's useful to know! \$\endgroup\$ – MCG Jul 18 '18 at 9:55
  • 1
    \$\begingroup\$ Indeed! It's news to me too \$\endgroup\$ – Nick A Jul 18 '18 at 9:55
3
\$\begingroup\$

What @Neil_UK says is completely correct that the question is a little vague, but is seems to me that the lamp should light up if both the mentioned conditions are true. In that case take the output of the AND and OR gates that you already made, and put it through another AND gate. This final AND gate will then only activate if BOTH your conditions are met, and not just one.

For completeness, if you want the lamp to light up if either one of the conditions are met, then use a OR gate instead of AND for the final gate.

Hope this helps!

\$\endgroup\$
1
\$\begingroup\$

Thank you @Neil_UK, @Hein Wessels and @MCG, You all paved a proper road for me to take to get the answer, first of all, @Neil_UK helped me in reassuring that my first two gates (A AND B gate) and (C XOR D) and hinted that The last gate should be an (E AND F gate), @Hein Wessels reassured the last gate and @MCG displayed the logic circuits with two different possibilities and concluded a gate that I took to appreciation. I would like to thank all of you in taking your time and the extra mile in my question, this mainly is a text of appreciation but also the final answer.

I concluded that the answer is " (A AND B) + (C XOR D) = (E AND F)"

\$\endgroup\$
  • \$\begingroup\$ By the way, I did leave a final answer to the question in the last line and accepted the answer. \$\endgroup\$ – user63671 Jul 20 '18 at 17:42
0
\$\begingroup\$

How to get the answer might be simpler if one substitutes condition 1, for the first statement, and condition 2, for the second statement. With this substitution, then the requirement for the lamp to light reads: A lamp will light, only if... condition 1 AND condition 2 are true. The AND is implied by the "only if" portion of the statement. So, after meeting the requirements for each statement, you AND the results.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.