Logic circuits and logic expressions

Computer Science · Boolean logic. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

A logic circuit is several gates joined together, where the output of one gate becomes an input of the next. A logic expression describes the same thing in writing, for example X = (A AND B) OR NOT C. You must be able to move between a problem statement, an expression, a circuit and a truth table.

From a problem statement, turn the words into operators: "and" gives AND, "or" gives OR, "not" gives NOT, "one or the other but not both" gives XOR. Use brackets to show which part is worked out first.

From a circuit, start at the inputs and write the output of each gate as you move towards the final output.

In simpler words

A logic circuit joins several gates. The output of one gate goes into the next. A logic expression writes the same thing in words, like (A AND B) OR NOT C. You turn words into gates: and is AND, or is OR, not is NOT. Brackets show what happens first. Work from the inputs towards the output.

An everyday comparison

A logic circuit is like a factory line where each station does one job and passes its result to the next. Brackets in an expression are like saying which station comes first. The comparison stops working because each gate gives only 1 or 0, and the gate done last in the expression is the one that gives the final output.

Rules to remember

Common mistake

Leaving out brackets changes the meaning: (A AND B) OR C is not the same as A AND (B OR C). Also check exactly what NOT applies to: NOT A OR B inverts only A, but NOT (A OR B) inverts the whole OR.

In the exam

From a statement, turn each condition into an input, adding NOT where the condition is 0, and write the logic expression with brackets. Draw one gate for each operator, with bracketed parts nearest the inputs and the last operation at the output. Label inputs and the output. Check NOT applies to the correct part. From a truth table, join 1-rows with OR.

Worked example

A light L switches on (L = 1) when it is dark (D = 1) and either movement is detected (M = 1) or the manual switch is on (S = 1). Write the logic expression for L.

  1. "Movement or the manual switch" gives M OR S.
  2. This must be true together with darkness, so join it to D with AND.
  3. Brackets keep the OR part together: L = D AND (M OR S).
  4. Check: D = 0, M = 1, S = 1 gives 0 AND 1 = 0, so the light stays off in daylight, as required.

Answer: L = D AND (M OR S)

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Logic gatesTruth tables →Take a Computer Science test