Class 11Computer Science · Computer SystemsFull chapter

Boolean Logic

The whole chapter in one place — read it, then test yourself. Clear notes, a reference sheet, a practice quiz, and worked NCERT solutions & PYQs.

Why Computers Think in Two States

Quick answer Boolean logic works with exactly two values because a wire can hold only two reliable voltage levels, and every comparison, condition and truth table you will write in Python rests on that single fact.

One honest note before we start. Boolean logic is listed in the CBSE Class 11 Computer Science (083) syllabus under Unit 1, Computer Systems and Organisation. It does not have a chapter of its own in the NCERT Class 11 Computer Science textbook. So do not waste time hunting for "the NCERT chapter on Boolean logic" — there isn't one. The topic is examined straight from the syllabus line, and reference books cover it on their own. That is also why the exercise questions later in this chapter are written in the style a CBSE reference book sets, and are not quoted from any numbered NCERT chapter.

Why two values and not ten? Inside a chip, a signal is just a voltage on a wire. Voltages drift — with heat, with the length of the wire, with electrical noise from the motor of a fan sitting next to the machine. If we tried to represent ten digits as ten different voltage levels, a small drift would turn a 6 into a 7 and the machine would be wrong. So hardware designers gave up on ten levels and kept only two, placed as far apart as possible: close to 0 volts and close to the supply voltage. Now a drift of a few tenths of a volt changes nothing, because the two levels are nowhere near each other. We call the low one 0 and the high one 1. Everything else — Aadhaar numbers, UPI transactions, a Reel you scroll past — is built on top of those two states.

Two states also gave us a piece of luck. Mathematics for exactly two values already existed. George Boole worked it out in his 1854 book An Investigation of the Laws of Thought, long before electronics. In 1937 Claude Shannon, in his master's thesis at MIT, showed that Boole's algebra describes switching circuits exactly. That is the link between a school algebra topic and the chip in your phone.

The vocabulary you must get right.

  • A Boolean value (or truth value) is one of exactly two things: True or False.
  • A Boolean constant is a fixed truth value written directly: True, False (or 1, 0).
  • A Boolean variable is a name that holds one of those two values and nothing else. In circuit questions we call them A, B, C.
  • A logical statement (proposition) is a sentence that is definitely true or definitely false — "Riya scored 78" is one; "Riya scored well" is not, because "well" has no fixed cut-off.
  • A Boolean expression combines Boolean values using operators such as NOT, AND, OR.

Different books write the same two values in different clothes. All of these mean the same thing:

LogicPythonHardwareSwitch
1TrueHIGHON / closed
0FalseLOWOFF / open

Boolean values in Python. Python has a built-in type called bool with exactly two values, True and False. The capital letters matter — true is not defined and gives a NameError.

a = True
b = False
print(a, b)
print(type(a))
print(int(a), int(b))
print(True + True, True + False)

Real output:

True False

1 0
2 1

Look at the last line. True + True gave 2. That is not a bug. In Python bool is built on top of int, so True is 1 and False is 0 whenever arithmetic is involved. This is genuinely useful — it lets you count how many conditions are true just by adding them — but it also produces trick questions in exams, so remember it.

print(isinstance(True, int))
print(True == 1, False == 0)
True
True True

Truthiness: every value has a truth value. Python will happily treat non-Boolean values as True or False when a condition needs it. The rule is short: anything empty or zero counts as False, everything else counts as True.

print(bool(0), bool(1), bool(-7))
print(bool(0.0), bool(0.1))
print(bool(""), bool("0"), bool(" "))
print(bool([]), bool([0]))
False True True
False True
False True True
False True

Three of those catch students every year. bool(-7) is True — negative is not zero, so it is True. bool("0") is True — it is a string with one character in it, and a non-empty string is True regardless of what that character is. bool(" ") is True for the same reason: a space is a character. Only the truly empty string "" is False.

Worked example: turning a real rule into Boolean values. A school gives a merit certificate only if the student has passed and has at least 75% attendance. Take Riya: 78 marks, 68% attendance.

marks = 78
attendance = 68
P = marks >= 33
Q = attendance >= 75
print("P (passed)      :", P)
print("Q (attendance)  :", Q)
print("P and Q         :", P and Q)
print("P or  Q         :", P or Q)
print("not P           :", not P)
P (passed)      : True
Q (attendance)  : False
P and Q         : False
P or  Q         : True
not P           : False

Riya passed, so P is True. Her attendance is short, so Q is False. The certificate rule is P AND Q, which is False — no certificate. Notice what happened: a school rule written in English became two Boolean variables and one operator. That is the whole point of the subject.

The truth table. A Boolean expression has only finitely many possible inputs, so unlike ordinary algebra we can simply list every case and check. That list is a truth table. With n input variables there are 2n rows, because each variable independently takes 2 values.

n = 3
print("Variables:", n, "-> rows =", 2 ** n)
rows = 0
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            rows = rows + 1
            print(A, B, C)
print("Rows printed:", rows)
Variables: 3 -> rows = 8
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Rows printed: 8

Always write the rows in normal binary counting order — 00, 01, 10, 11 for two variables; 000, 001, 010, ... , 111 for three. Examiners expect that order, and it makes it obvious if you have skipped a row. Look at the eight lines the program printed: the nested for loops produced exactly that order for free, which is why we will use them for every table in this chapter.

Boolean values True / False (written 1 / 0 in logic) Exactly two. Python capitalises them — writing true gives a NameError.
bool() conversion bool(x) -> False only for 0, 0.0, '', [], (), {}, None Everything else is True, including -7, "0" and " ".
bool is a kind of int isinstance(True, int) -> True True acts as 1 and False as 0 in arithmetic, so True + True is 2.
Rows in a truth table rows = 2 ** n n = number of input variables. 2 inputs -> 4 rows, 3 -> 8, 4 -> 16.
Complement notation NOT A = A' = A-bar = not A CBSE answers normally use A' or the overbar; Python writes not A.
Row order 00, 01, 10, 11 (plain binary counting) Nested for loops over [0, 1] generate this order automatically.
Remember
  • Hardware uses two states because two widely separated voltage levels survive noise and drift; ten levels would not.
  • Python's bool has exactly two values, True and False, and bool is built on int — so True + True gives 2.
  • Anything empty or zero is False; everything else is True, including -7, "0" and a single space " ".
  • A truth table lists every possible input combination; n variables give 2**n rows, written in binary counting order.
  • Boolean logic is a CBSE syllabus topic under Unit 1 with no NCERT Class 11 chapter of its own.

The Three Basic Operators: NOT, AND, OR

Quick answer NOT, AND and OR are the three primitive Boolean operators from which every other gate is built; their truth tables, their algebraic notation and their Python behaviour including short-circuit evaluation are the core of Unit 1.

With two values there are only so many useful things you can do to them. Three operators cover the ground: NOT, AND and OR. Everything else in this chapter — NAND, NOR, XOR, whole processors — is these three, wired together.

NOT (complement, inverter). It has one input. It flips it. That's all.

print("A | NOT A")
print("--+------")
for A in [0, 1]:
    print(A, "|", int(not A))
A | NOT A
--+------
0 | 1
1 | 0

Written algebraically, NOT A is A' (some books put a bar over the A). Because flipping twice returns you to the start, (A')' = A. That is called the law of involution or double complement, and it is worth remembering because it lets you cancel pairs of bars in simplification questions.

AND (logical product). Output is 1 only when every input is 1. Think of two switches in series on the same wire: the bulb glows only if both are closed. Real example: a UPI payment goes through only if the PIN is correct AND the balance is enough. One failure kills it.

OR (logical sum). Output is 0 only when every input is 0 — equivalently, 1 if at least one input is 1. Two switches in parallel: the bulb glows if either one is closed. Real example: you can log in to a portal with your roll number OR your registered mobile number.

print("A B | A.B | A+B")
print("----+-----+----")
for A in [0, 1]:
    for B in [0, 1]:
        print(A, B, "|", int(A and B), " |", int(A or B))
A B | A.B | A+B
----+-----+----
0 0 | 0  | 0
0 1 | 0  | 1
1 0 | 0  | 1
1 1 | 1  | 1

Why the odd notation? AND is written like multiplication, A.B or just AB, and OR is written like addition, A + B. Boole picked those symbols because AND behaves exactly like multiplying: 0·0 = 0, 0·1 = 0, 1·1 = 1 — identical to the AND column. OR almost behaves like adding, and the one place it does not is the last row: in Boolean algebra 1 + 1 = 1, not 2. There is no value 2 to go to. Get that one exception into your head and the notation stops being confusing.

An aside that explains why only a handful of gates have names: with 2 inputs there are 4 rows in the truth table, and each row's output can independently be 0 or 1, so there are 24 = 16 different two-input Boolean functions in total. Only about six of them are useful enough to be given names and built as physical gates.

Precedence: which operator goes first. Just as × binds tighter than + in arithmetic, in Boolean work not binds tightest, then and, then or. Python follows the same order.

print(True and False)
print(True or False)
print(not True)
print(not True and False)
print(not (True and False))
print(True or False and False)
print((True or False) and False)
False
True
False
False
True
True
False

Read lines 4 and 5 together. not True and False is (not True) and False = False and False = False, because not grabs only the value immediately after it. not (True and False) is not False = True. Same words, brackets moved, opposite answer. Lines 6 and 7 make the same point for and versus or: True or False and False evaluates the and first, giving True or False = True, while the bracketed version gives False. In the exam, when in doubt, put brackets — you lose no marks for extra brackets and you lose the whole question for a missing one.

A Python-only detail: and / or do not return True or False. They return one of the actual operands. Python evaluates left to right and stops as soon as the answer is certain — this is called short-circuit evaluation.

print(5 and 0)
print(0 and 5)
print(5 or 0)
print(0 or 7)
print("" or "Guest")
n = 0
print(n != 0 and 100 // n > 5)
0
0
5
7
Guest
False

5 and 0 gave 0, not False. For and, Python checks the left side: 5 is truthy, so the answer depends entirely on the right side, and it hands back the right side unchanged. For 0 and 5, the left side is falsy, so the result is already decided and Python returns 0 without even looking at 5. or works the mirror image, which is why "" or "Guest" is the standard way to supply a default name.

Worked example: short-circuiting as a safety net. The last line above is the interesting one. n is 0, so n != 0 is False, so Python never evaluates 100 // n and there is no crash. Swap the two conditions and the protection disappears. Saved as guard.py and run, this is the real Python 3 output:

n = 0
print(100 // n > 5 and n != 0)
Traceback (most recent call last):
  File "guard.py", line 2, in 
    print(100 // n > 5 and n != 0)
          ~~~~^^~~
ZeroDivisionError: integer division or modulo by zero

That error is left here on purpose. In pure Boolean algebra A and B equals B and A (the commutative law), and the truth tables really are identical. In Python the values match but the behaviour does not, because one order divides by zero and the other never gets there. So the guard condition always goes first.

Do not confuse and with &. Python also has bitwise operators &, | and ^ which work on the individual bits of integers. They are not the same thing.

print(2 and 3)
print(2 & 3)
print(2 or 3)
print(2 | 3)
3
2
2
3

2 and 3 is 3 (short-circuit: 2 is truthy so return the right operand). 2 & 3 is 2, because 2 is binary 10, 3 is binary 11, and ANDing bit by bit gives 10 = 2. For 0/1 values the two agree, which is exactly why they are so easy to mix up.

NOT (complement) not A | A' 0' = 1 and 1' = 0. One input, one output. (A')' = A.
AND (logical product) A and B | A . B | AB Output 1 only when every input is 1. Series switches.
OR (logical sum) A or B | A + B Output 0 only when every input is 0. Note 1 + 1 = 1, not 2.
Precedence order not -> and -> or (highest to lowest) not binds only the value right after it. Use brackets when unsure.
Short-circuit and X and Y -> X if X is falsy, else Y Y is never evaluated when X is falsy — this is what prevents the crash.
Short-circuit or X or Y -> X if X is truthy, else Y Standard default-value idiom: name = entered or 'Guest'.
Remember
  • NOT flips a single input; AND gives 1 only when all inputs are 1; OR gives 0 only when all inputs are 0.
  • AND is written as a product (A.B) and OR as a sum (A+B), with the one exception that 1 + 1 = 1.
  • Precedence is not, then and, then or — so not True and False is False but not (True and False) is True.
  • Python's and/or return an operand, not a Boolean, and short-circuit: put the guard condition first or you may crash.
  • Bitwise &, | and ^ act on individual bits of integers and are a different thing from and, or, not.

Derived Gates: NAND, NOR, XOR

Quick answer NAND and NOR are simply AND and OR with the output inverted, XOR fires when its inputs differ, and NAND alone can build every other gate — which is why real chips are made mostly of NAND.

Once you have NOT, AND and OR, three more combinations turn up so often that they get their own names and their own gate symbols: NAND, NOR and XOR. A fourth, XNOR, is worth knowing as XOR's opposite.

  • NAND = NOT + AND. Take an AND gate and invert its output. So NAND gives 0 only when both inputs are 1, and 1 in every other case. Expression: (A.B)'.
  • NOR = NOT + OR. Take an OR gate and invert its output. NOR gives 1 only when both inputs are 0. Expression: (A+B)'.
  • XOR (exclusive OR) = 1 when the inputs are different. It is the "one or the other, but not both" gate. Symbol: A ⊕ B.
  • XNOR = NOT of XOR = 1 when the inputs are the same. It is an equality checker. Symbol: (A ⊕ B)'.

The names give away the construction. NAND is "Not AND", NOR is "Not OR". On a circuit diagram this is drawn as the AND or OR shape with a small circle (a "bubble") stuck on the output — the bubble always means "inverted here".

All four in one table, generated rather than copied:

print("A B | NAND | NOR | XOR | XNOR")
print("----+------+-----+-----+-----")
for A in [0, 1]:
    for B in [0, 1]:
        nand = int(not (A and B))
        nor  = int(not (A or B))
        xor  = int(A != B)
        xnor = int(A == B)
        print(A, B, "|  ", nand, " | ", nor, " | ", xor, " | ", xnor)
A B | NAND | NOR | XOR | XNOR
----+------+-----+-----+-----
0 0 |   1  |  1  |  0  |  1
0 1 |   1  |  0  |  1  |  0
1 0 |   1  |  0  |  1  |  0
1 1 |   0  |  0  |  0  |  1

Check it against the plain AND and OR table from the previous section. The AND column reads 0, 0, 0, 1 down the page and the NAND column reads 1, 1, 1, 0 — the same column with every entry flipped, row by row, each row staying where it is. The same holds for OR (0, 1, 1, 1) and NOR (1, 0, 0, 0). Be careful here: flipping each entry is not the same as turning the column upside down. Reading the AND column bottom-to-top gives 1, 0, 0, 0, which is the NOR column, not NAND — a genuinely costly slip in an exam. If you ever forget a NAND table, write the AND table and invert each output where it stands.

Worked example: three ways to write XOR, all the same. XOR is the one gate students define three different ways, so let us prove the definitions agree instead of trusting memory. The classical algebraic form is A'B + AB' — "A is 0 and B is 1, or A is 1 and B is 0". Python can express the same idea as A != B, and for integer 0/1 values as the bitwise A ^ B.

ok = True
for A in [0, 1]:
    for B in [0, 1]:
        xor_def = int((A and not B) or (not A and B))
        xor_ne  = int(A != B)
        xor_xop = A ^ B
        print(A, B, xor_def, xor_ne, xor_xop)
        if not (xor_def == xor_ne == xor_xop):
            ok = False
print("All three agree:", ok)
print("6 ^ 3 =", 6 ^ 3)
0 0 0 0 0
0 1 1 1 1
1 0 1 1 1
1 1 0 0 0
All three agree: True
6 ^ 3 = 5

The three columns after A and B are identical on every row, so all three forms are the same function. Note the caution though: ^ is the bitwise XOR. It matches only because our values are 0 and 1. On larger numbers it works bit by bit — the last line shows 6 ^ 3 is 5, since 110 XOR 011 = 101. In a written CBSE answer, use A'B + AB'.

XOR earns its keep in three places you will meet again: it is the sum bit of binary addition (0+0=0, 0+1=1, 1+0=1, 1+1=0 with a carry), it is how parity bits detect a single-bit error in transmitted data, and it is the core of the simplest encryption schemes, because XORing twice with the same key returns the original.

Universal gates: why factories mostly make NAND. A gate is called universal if you can build every other gate out of copies of it alone. NAND is universal. So is NOR. Here are the three NAND constructions you must be able to reproduce:

  • NOT: tie both inputs of one NAND together. A NAND A = (A.A)' = A' (using A.A = A).
  • AND: a NAND followed by a NAND-as-inverter. (A NAND B) NAND (A NAND B) = ((A.B)')' = A.B. Two gates.
  • OR: invert both inputs first, then NAND them. (A NAND A) NAND (B NAND B) = (A'.B')' = A + B by De Morgan. Three gates.
print("A B | NOT A | A.B | A+B   (all built only from NAND)")
print("----+-------+-----+----")
for A in [0, 1]:
    for B in [0, 1]:
        n1 = int(not (A and A))
        n2 = int(not (A and B))
        andAB = int(not (n2 and n2))
        nA = int(not (A and A))
        nB = int(not (B and B))
        orAB = int(not (nA and nB))
        print(A, B, "|   ", n1, " | ", andAB, " | ", orAB)
A B | NOT A | A.B | A+B   (all built only from NAND)
----+-------+-----+----
0 0 |    1  |  0  |  0
0 1 |    1  |  0  |  1
1 0 |    0  |  0  |  1
1 1 |    0  |  1  |  1

Every single not and and in that program appears in the fixed pattern not (x and y), that is, as a NAND — and the three columns come out exactly as the NOT, AND and OR tables. So NAND alone is enough.

Why this matters commercially. If one gate type can do everything, a fabrication plant can standardise on a single cell and repeat it millions of times, which is cheaper and easier to test than manufacturing many different gate types. NAND also happens to be compact in CMOS technology — a two-input CMOS NAND is built from four transistors — and it is naturally inverting, which suits the way CMOS transistors work. NOR is universal in exactly the same way (tie its inputs for NOT, and so on), and appears in the exam just as often, so learn both sets of constructions.

NAND not (A and B) | (A . B)' Output 0 only when both inputs are 1. Each AND output inverted in place.
NOR not (A or B) | (A + B)' Output 1 only when both inputs are 0. Each OR output inverted in place.
XOR A'B + AB' | A ⊕ B | A != B | A ^ B Output 1 when the inputs differ. It is the sum bit of binary addition.
XNOR (A ⊕ B)' | A'B' + AB | A == B Output 1 when the inputs are the same. An equality checker.
NOT from NAND A NAND A = A' Tie both inputs together. One gate. Works identically for NOR.
OR from NAND (A NAND A) NAND (B NAND B) = A + B Three NAND gates. Follows from De Morgan: (A'.B')' = A + B.
Remember
  • NAND is AND with the output inverted; NOR is OR with the output inverted — invert each entry where it stands, do not turn the column upside down.
  • XOR outputs 1 when the inputs differ: A'B + AB' = (A != B) = A ^ B, all verified to be identical.
  • XNOR is the opposite of XOR and acts as an equality checker.
  • NAND and NOR are universal gates: with NAND, NOT needs 1 gate, AND needs 2 and OR needs 3; with NOR the AND and OR counts swap.
  • Universality plus a compact four-transistor CMOS cell is why real chips are built largely from NAND gates.

Boolean Algebra and De Morgan's Laws

Quick answer A small set of laws lets you shrink a Boolean expression to an equivalent but cheaper one, and De Morgan's two laws — which break a complement over a bracket while swapping AND with OR — are the pair CBSE asks about most.

Two Boolean expressions are equivalent if they produce identical truth tables. That is the only test there is. And since the tables are finite, equivalence is always checkable — you never have to take it on faith, which is a luxury ordinary algebra does not give you.

Why bother shrinking expressions? Because every operator in the expression becomes a physical gate on the chip. Fewer gates means less silicon area, less power drawn from the battery, less heat, and a shorter chain of gates for the signal to travel through, which means a faster circuit. A simplification question is really a cost question.

The basic laws. Learn these as a block; almost every simplification is a sequence of them.

NameOR formAND form
IdentityA + 0 = AA . 1 = A
Null / DominanceA + 1 = 1A . 0 = 0
IdempotentA + A = AA . A = A
ComplementA + A' = 1A . A' = 0
Involution(A')' = Ano separate dual
CommutativeA + B = B + AA . B = B . A
AssociativeA + (B + C) = (A + B) + CA . (B . C) = (A . B) . C
DistributiveA + B.C = (A + B).(A + C)A . (B + C) = A.B + A.C
AbsorptionA + A.B = AA . (A + B) = A
RedundancyA + A'.B = A + BA . (A' + B) = A.B
De Morgan(A + B)' = A' . B'(A . B)' = A' + B'

Two of these deserve a second look. A + 1 = 1 feels wrong until you remember that OR means "at least one input is 1" — if one input is permanently 1, the output is permanently 1 whatever A does. And the first distributive law, A + B.C = (A + B).(A + C), is true in Boolean algebra but flatly false in ordinary arithmetic (2 + 3×4 is not (2+3)×(2+4)). Boolean algebra is not arithmetic wearing a hat; it is its own system that happens to borrow the symbols.

Notice how the table is arranged in pairs. That is the principle of duality: take any valid Boolean identity, swap every AND with OR and every 0 with 1, and you get another valid identity. It halves what you have to memorise.

Let us not just assert the single-variable laws — check them:

checks = {"A+0=A":True, "A+1=1":True, "A.0=0":True, "A.1=A":True,
          "A+A=A":True, "A.A=A":True, "A+A'=1":True, "A.A'=0":True,
          "(A')'=A":True}
for A in [0, 1]:
    if int(A or 0) != A: checks["A+0=A"] = False
    if int(A or 1) != 1: checks["A+1=1"] = False
    if int(A and 0) != 0: checks["A.0=0"] = False
    if int(A and 1) != A: checks["A.1=A"] = False
    if int(A or A) != A: checks["A+A=A"] = False
    if int(A and A) != A: checks["A.A=A"] = False
    if int(A or (not A)) != 1: checks["A+A'=1"] = False
    if int(A and (not A)) != 0: checks["A.A'=0"] = False
    if int(not (not A)) != A: checks["(A')'=A"] = False
for law in checks:
    print(law, "->", checks[law])
A+0=A -> True
A+1=1 -> True
A.0=0 -> True
A.1=A -> True
A+A=A -> True
A.A=A -> True
A+A'=1 -> True
A.A'=0 -> True
(A')'=A -> True

De Morgan's laws. These are the two the board asks about, so state them precisely:

  • First law: (A . B)' = A' + B' — the complement of a product is the sum of the complements.
  • Second law: (A + B)' = A' . B' — the complement of a sum is the product of the complements.

In plain words: break the bar and change the sign. When you push a NOT inside a bracket, every AND becomes an OR and every OR becomes an AND, and every variable picks up its own complement. The mistake worth guarding against is writing (A.B)' = A'.B' — that is wrong, and the truth table below shows exactly which rows it fails on.

You can also feel why it is true in ordinary language. "It is not the case that (I passed AND I have 75% attendance)" means "either I did not pass, OR I do not have 75% attendance" — one failure is enough. The AND turned into an OR because there are two separate ways for the AND to fail.

Worked example: verifying both laws by truth table. This is the standard 3-mark answer, so learn the layout.

print("A B | (A.B)' | A'+B' | (A+B)' | A'.B'")
print("----+--------+-------+--------+------")
law1 = True
law2 = True
for A in [0, 1]:
    for B in [0, 1]:
        L1 = int(not (A and B))
        R1 = int((not A) or (not B))
        L2 = int(not (A or B))
        R2 = int((not A) and (not B))
        print(A, B, "|   ", L1, "  |  ", R1, "  |   ", L2, "  |  ", R2)
        if L1 != R1:
            law1 = False
        if L2 != R2:
            law2 = False
print()
print("De Morgan 1  (A.B)' = A'+B'  holds:", law1)
print("De Morgan 2  (A+B)' = A'.B'  holds:", law2)
A B | (A.B)' | A'+B' | (A+B)' | A'.B'
----+--------+-------+--------+------
0 0 |    1   |   1   |    1   |   1
0 1 |    1   |   1   |    0   |   0
1 0 |    1   |   1   |    0   |   0
1 1 |    0   |   0   |    0   |   0

De Morgan 1  (A.B)' = A'+B'  holds: True
De Morgan 2  (A+B)' = A'.B'  holds: True

Column 3 matches column 4 on all four rows, and column 5 matches column 6 on all four rows. Both laws verified. Now look at the wrong version: is (A.B)' equal to A'.B'? Compare column 3 with column 6. On row 0 1 column 3 is 1 but column 6 is 0, and on row 1 0 the same thing happens. They differ, so the shortcut is false — and one counter-example row is already enough to disprove an identity.

De Morgan extends to any number of variables: (A + B + C)' = A'.B'.C'. Do not take that on trust either — run the same style of check across all eight rows of a three-variable table:

holds = True
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            L = int(not (A or B or C))
            R = int((not A) and (not B) and (not C))
            if L != R:
                holds = False
print("(A+B+C)' = A'.B'.C' holds:", holds)
(A+B+C)' = A'.B'.C' holds: True

Worked example: simplify A.B + A.B' + A'.B

  1. Group the first two terms, which share A: A.B + A.B' = A.(B + B') — distributive law.
  2. B + B' = 1 — complement law. So that part becomes A . 1 = A by identity.
  3. The expression is now A + A'.B.
  4. By the redundancy law, A + A'.B = A + B.

Three AND gates, two OR gates and two inverters collapse into a single OR gate. Verify:

print("A B | AB+AB'+A'B | A+B")
print("----+------------+----")
same = True
for A in [0, 1]:
    for B in [0, 1]:
        left  = int((A and B) or (A and not B) or ((not A) and B))
        right = int(A or B)
        print(A, B, "|      ", left, "     | ", right)
        if left != right:
            same = False
print("Simplification correct:", same)
A B | AB+AB'+A'B | A+B
----+------------+----
0 0 |       0      |  0
0 1 |       1      |  1
1 0 |       1      |  1
1 1 |       1      |  1
Simplification correct: True

Where De Morgan actually helps you in code. A condition like not (marks >= 33 and attendance >= 75) is hard to read. De Morgan's first law rewrites it as marks < 33 or attendance < 75 — "failed, or short on attendance" — which reads the way a teacher would say it, and drops the bracket and the not entirely. The last worked exercise at the end of this chapter runs both versions over a failing, a borderline and a comfortable value of each field and prints the two columns side by side, so you can see for yourself that they agree on all nine combinations.

De Morgan's first law (A . B)' = A' + B' Complement of a product = sum of the complements. NOT (A AND B) = A' OR B'.
De Morgan's second law (A + B)' = A' . B' Complement of a sum = product of the complements. Extends to any number of variables.
Absorption law A + A.B = A and A.(A + B) = A The second term is redundant — it never turns on a row that A had not already turned on.
Redundancy law A + A'.B = A + B The workhorse of 2-mark simplification questions. Dual: A.(A' + B) = A.B.
Distributive laws A.(B + C) = A.B + A.C and A + B.C = (A + B).(A + C) The second one is true in Boolean algebra but false in ordinary arithmetic.
Principle of duality swap AND with OR, and 0 with 1 Every valid Boolean identity stays valid after the swap. Halves the memorising.
Remember
  • Two expressions are equivalent exactly when their truth tables match — and truth tables are finite, so equivalence is always checkable.
  • De Morgan 1: (A.B)' = A' + B'. De Morgan 2: (A+B)' = A' . B'. Break the bar, change the sign.
  • (A.B)' = A'.B' is WRONG — it fails on the rows 0 1 and 1 0, and one bad row disproves an identity.
  • Key simplifiers: absorption A + A.B = A, redundancy A + A'.B = A + B, and the complement law B + B' = 1 that drives both.
  • A + B.C = (A+B).(A+C) is valid in Boolean algebra although false in ordinary arithmetic — Boolean algebra is its own system.

Reading and Building Logic Circuits

Quick answer A logic circuit is a Boolean expression drawn as wired gates; you convert circuit to expression by labelling gate outputs left to right, and expression to circuit by starting from the innermost bracket.

A logic circuit (or logic diagram) is a Boolean expression drawn as a picture. Inputs enter on the left, gates sit in the middle, the output leaves on the right. Two skills are examined: reading a given circuit to write its expression, and drawing a circuit for a given expression. Both are mechanical once you know the steps.

Standard gate symbols, described in words so you can recognise them in a question paper:

GateSymbol shapeExpression
NOTTriangle pointing right with a small bubble on the tipA'
ANDFlat back, rounded front like a capital DA . B
ORCurved back, pointed front like a shieldA + B
NANDAND shape with a bubble on the output(A . B)'
NOROR shape with a bubble on the output(A + B)'
XOROR shape with an extra curved line at the backA ⊕ B

The bubble is the key to reading a diagram fast: a bubble anywhere means "invert at this point". A wire may also split and feed two gates — that is called fan-out, and it is perfectly legal. What is never legal is joining the outputs of two gates onto one wire.

Worked example 1: circuit to expression. A and B go into an OR gate. The OR output goes into a NOT gate. The NOT output and input C go into an AND gate, whose output is F.

Level 1          Level 2           Level 3

A ---+
     +--[ OR ]--+
B ---+          |
                +--[ NOT ]--+
                            |
                            +--[ AND ]-- F
C --------------------------+

Method: label every gate output as you move left to right, then substitute back.

  1. Output of the OR gate: T1 = A + B
  2. Output of the NOT gate: T2 = T1' = (A + B)'
  3. Output of the AND gate: F = T2 . C = (A + B)' . C

Note that this two-gate combination — OR followed by NOT — is exactly a NOR gate, so the same circuit can be redrawn with one NOR gate instead of two gates. Now the truth table. Three inputs, so eight rows, in binary counting order:

print("A B C | (A+B)' | F = (A+B)'.C")
print("------+--------+-------------")
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            t = int(not (A or B))
            F = int(t and C)
            print(A, B, C, "|   ", t, "   |      ", F)
A B C | (A+B)' | F = (A+B)'.C
------+--------+-------------
0 0 0 |    1    |       0
0 0 1 |    1    |       1
0 1 0 |    0    |       0
0 1 1 |    0    |       0
1 0 0 |    0    |       0
1 0 1 |    0    |       0
1 1 0 |    0    |       0
1 1 1 |    0    |       0

F is 1 on exactly one row, A=0, B=0, C=1. That makes sense from the expression: you need A and B both off for the NOR to give 1, and C on for the AND to pass it through. Keeping the intermediate column (A+B)' in the table is what earns method marks — never jump straight to the final column.

Worked example 2: expression to circuit, and why simplifying pays. Draw a circuit for F = A.(B + C). Start from the innermost bracket: an OR gate takes B and C; its output and A go into an AND gate. Two gates, two levels.

The distributive law says this equals A.B + A.C, which needs two AND gates and one OR gate — three gates for the same job. Same truth table, more hardware:

print("A B C | A.(B+C) | A.B + A.C")
print("------+---------+----------")
same = True
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            L = int(A and (B or C))
            R = int((A and B) or (A and C))
            print(A, B, C, "|    ", L, "   |     ", R)
            if L != R:
                same = False
print("Distributive law holds:", same)
A B C | A.(B+C) | A.B + A.C
------+---------+----------
0 0 0 |     0    |      0
0 0 1 |     0    |      0
0 1 0 |     0    |      0
0 1 1 |     0    |      0
1 0 0 |     0    |      0
1 0 1 |     1    |      1
1 1 0 |     1    |      1
1 1 1 |     1    |      1
Distributive law holds: True

Identical columns, so the two circuits are interchangeable. If you were manufacturing this, you would pick the two-gate version. This is the whole business case for Boolean simplification.

Worked example 3: the half adder. Here is a circuit that does something real. Add two single bits: 0+0=0, 0+1=1, 1+0=1, and 1+1=10 in binary, which is a sum bit of 0 with a carry of 1. Look at the required columns and you will recognise them — the sum column is XOR, the carry column is AND.

A --+
    +--[ XOR ]-- SUM
B --+

A --+
    +--[ AND ]-- CARRY
B --+

The same two input wires A and B feed both gates; they are drawn twice above only for clarity. That is fan-out, not duplication of the inputs.

print("A B | SUM | CARRY")
print("----+-----+------")
for A in [0, 1]:
    for B in [0, 1]:
        s = int(A != B)
        c = int(A and B)
        print(A, B, " | ", s, " |  ", c)
A B | SUM | CARRY
----+-----+------
0 0  |  0  |   0
0 1  |  1  |   0
1 0  |  1  |   0
1 1  |  0  |   1

Two gates. That is binary addition of one bit, and chaining circuits like this is literally how the adder inside a processor is built.

Worked example 4: designing from a requirement (SOP method). A safety valve must open when at least two of its three sensors A, B and C report danger. This is the majority or 2-of-3 circuit.

The Sum of Products method turns any truth table into an expression: for every row where the output is 1, write one AND term with each variable included plain if it is 1 in that row and complemented if it is 0; then OR all those terms together. Here, though, there is a shortcut — "at least two are 1" means at least one of the three pairs is both-1, so F = A.B + B.C + A.C.

print("A B C | F (at least 2 of 3)")
print("------+--------------------")
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            F = int((A and B) or (B and C) or (A and C))
            print(A, B, C, "|         ", F)
A B C | F (at least 2 of 3)
------+--------------------
0 0 0 |          0
0 0 1 |          0
0 1 0 |          0
0 1 1 |          1
1 0 0 |          0
1 0 1 |          1
1 1 0 |          1
1 1 1 |          1

F is 1 on exactly the four rows that have two or more 1s, and 0 on the four rows that have one or none. The circuit needs three 2-input AND gates feeding one 3-input OR gate — four gates, two levels. Using two 2-input OR gates instead would make it five gates and three levels, and three levels is slightly slower, because the signal must pass through one more gate before the output settles.

Circuit -> expression label each gate output T1, T2, ... left to right, then substitute back Always show the intermediate columns in the truth table for method marks.
Expression -> circuit innermost bracket = first level of gates Number of levels = longest gate chain = the propagation delay.
Sum of Products (SOP) one AND term per row where F = 1, all ORed together In that row, a variable equal to 0 is written complemented, equal to 1 is written plain.
Half adder SUM = A ⊕ B , CARRY = A . B Adds two single bits: 1 + 1 = 10 in binary, so SUM 0 and CARRY 1.
Majority (2-of-3) circuit F = A.B + B.C + A.C Output 1 when at least two of the three inputs are 1. Four gates, two levels.
NOR built into a circuit OR gate followed by NOT gate = one NOR gate Spotting these pairs is how you reduce a drawn circuit's gate count.
Remember
  • To read a circuit, label each gate's output left to right and substitute back at the end; to draw one, start from the innermost bracket.
  • A bubble on a gate symbol always means "invert here" — that is the only difference between AND/NAND and OR/NOR.
  • Fan-out (one wire feeding several gates) is fine; joining two gate outputs onto one wire is not.
  • Half adder: SUM = A XOR B, CARRY = A . B — two gates that perform one-bit binary addition.
  • SOP design: one AND term per row where the output is 1 (complement the variables that are 0 in that row), all ORed together.

The formula sheet

Every formula in this chapter, in one place — screenshot it before your exam.

True / False (written 1 / 0 in logic)
Boolean values
bool(x) -> False only for 0, 0.0, '', [], (), {}, None
bool() conversion
isinstance(True, int) -> True
bool is a kind of int
rows = 2 ** n
Rows in a truth table
NOT A = A' = A-bar = not A
Complement notation
00, 01, 10, 11 (plain binary counting)
Row order
not A | A'
NOT (complement)
A and B | A . B | AB
AND (logical product)
A or B | A + B
OR (logical sum)
not -> and -> or (highest to lowest)
Precedence order
X and Y -> X if X is falsy, else Y
Short-circuit and
X or Y -> X if X is truthy, else Y
Short-circuit or
not (A and B) | (A . B)'
NAND
not (A or B) | (A + B)'
NOR
A'B + AB' | A ⊕ B | A != B | A ^ B
XOR
(A ⊕ B)' | A'B' + AB | A == B
XNOR
A NAND A = A'
NOT from NAND
(A NAND A) NAND (B NAND B) = A + B
OR from NAND
(A . B)' = A' + B'
De Morgan's first law
(A + B)' = A' . B'
De Morgan's second law
A + A.B = A and A.(A + B) = A
Absorption law
A + A'.B = A + B
Redundancy law
A.(B + C) = A.B + A.C and A + B.C = (A + B).(A + C)
Distributive laws
swap AND with OR, and 0 with 1
Principle of duality
label each gate output T1, T2, ... left to right, then substitute back
Circuit -> expression
innermost bracket = first level of gates
Expression -> circuit
one AND term per row where F = 1, all ORed together
Sum of Products (SOP)
SUM = A ⊕ B , CARRY = A . B
Half adder
F = A.B + B.C + A.C
Majority (2-of-3) circuit
OR gate followed by NOT gate = one NOR gate
NOR built into a circuit

Test yourself

Tap an answer to check it instantly — you'll see why it's right, and what to revise if it isn't.

0 correct · 0/12 answered
Q1

What is the output of the following code?print(not 0 and not "")

Q2

What is the output of the following code?x = 5y = 0print(x and y)

Q3

What is the output of the following code?print(3 or 5 and 0)

Q4

What is the output of the following code?a = 10b = 20print(a > b or not (a == 10))

Q5

What is the output of the following code?print(True + True + False)

Q6

What is the output of the following code?count = 0 for A in [0, 1]: for B in [0, 1]: if (A or B) and not (A and B): count = count + 1 print(count)

Q7

What is the output of the following code?print(bool("False"))

Q8

According to De Morgan's laws, (A + B)' is equal to:

Q9

For a 2-input NAND gate, in how many of the four input combinations is the output 0?

Q10

Which single gate gives output 1 only when its two inputs are different?

Q11

For the circuit F = (A . B)' + C with three inputs, on how many of the eight rows is F equal to 0?

Q12

Simplify the Boolean expression A + A'.B

NCERT solutions & previous-year questions

Step-by-step model answers — tap a question to reveal the full solution.

NCERT questions 6

1 Draw the truth table for the Boolean expression F = A'B + AB' and name the single logic gate that is equivalent to it.Truth tables and gate identification

Build the table one column at a time — never jump straight to F, because the intermediate columns carry the method marks.

ABA'B'A'BAB'F = A'B + AB'
0011000
0110101
1001011
1100000

Reading the F column: the output is 1 exactly on the two rows where A and B are different (0 1 and 1 0), and 0 on the two rows where they are the same. That is the definition of the XOR gate. So F = A'B + AB' = A XOR B.

Verification in Python (the last column checks against the built-in bitwise XOR operator, which agrees with logical XOR because the values here are only 0 and 1):

print("A B | A'B | AB' | F = A'B + AB' | A XOR B")
for A in [0, 1]:
    for B in [0, 1]:
        t1 = int((not A) and B)
        t2 = int(A and (not B))
        F = int(t1 or t2)
        print(A, B, "| ", t1, " | ", t2, " |      ", F, "      | ", A ^ B)
A B | A'B | AB' | F = A'B + AB' | A XOR B
0 0 |  0  |  0  |       0       |  0
0 1 |  1  |  0  |       1       |  1
1 0 |  0  |  1  |       1       |  1
1 1 |  0  |  0  |       0       |  0

The F column and the XOR column are identical on all four rows, confirming the identification.

2 State De Morgan's laws. Verify the first law, (A . B)' = A' + B', using a truth table.De Morgan's laws

Statement.

  • First law: (A . B)' = A' + B' — the complement of a product equals the sum of the individual complements.
  • Second law: (A + B)' = A' . B' — the complement of a sum equals the product of the individual complements.

In words: when a complement is pushed inside a bracket, every AND becomes an OR, every OR becomes an AND, and each variable takes its own complement.

Verification of the first law.

ABA.BLHS = (A.B)'A'B'RHS = A' + B'
0001111
0101101
1001011
1110000

The LHS column and the RHS column agree on all four rows, so the law is proved. Hence (A.B)' = A' + B'.

Python check of both laws at once:

law1 = True
law2 = True
for A in [0, 1]:
    for B in [0, 1]:
        if int(not (A and B)) != int((not A) or (not B)):
            law1 = False
        if int(not (A or B)) != int((not A) and (not B)):
            law2 = False
print("De Morgan 1  (A.B)' = A'+B'  holds:", law1)
print("De Morgan 2  (A+B)' = A'.B'  holds:", law2)
De Morgan 1  (A.B)' = A'+B'  holds: True
De Morgan 2  (A+B)' = A'.B'  holds: True

Common error to avoid: writing (A.B)' = A'.B'. On the row A = 0, B = 1 the true LHS is 1 but A'.B' = 1.0 = 0, so that version is false.

3 Simplify the Boolean expression A.B + A.B' + A'.B using Boolean laws, and verify the answer with a truth table.Expression simplification

Step-by-step simplification. Name the law at each step — that is what the marking scheme looks for.

  1. A.B + A.B' + A'.B
  2. = A.(B + B') + A'.B [distributive law, taking A common from the first two terms]
  3. = A.1 + A'.B [complement law: B + B' = 1]
  4. = A + A'.B [identity law: A.1 = A]
  5. = A + B [redundancy law: A + A'.B = A + B]

Answer: A + B. The original needed 3 AND gates, 2 OR gates and 2 NOT gates; the simplified form needs a single OR gate.

Verification.

ABA.BA.B'A'.BSum of the threeA + B
0000000
0100111
1001011
1110011
same = True
for A in [0, 1]:
    for B in [0, 1]:
        left  = int((A and B) or (A and not B) or ((not A) and B))
        right = int(A or B)
        print(A, B, "|      ", left, "     | ", right)
        if left != right:
            same = False
print("Simplification correct:", same)
0 0 |       0      |  0
0 1 |       1      |  1
1 0 |       1      |  1
1 1 |       1      |  1
Simplification correct: True

Identical columns, so the simplification is valid. If you prefer, note that only the row 0 0 gives 0 — which is precisely the OR gate.

4 In a logic circuit, inputs A and B are fed to a NAND gate. The output of the NAND gate and a third input C are fed to an OR gate, whose output is F. Write the Boolean expression for F and draw its truth table.Logic circuits — circuit to expression

The circuit.

A ---+
     +--[ NAND ]--+
B ---+            |
                  +--[ OR ]-- F
C ----------------+

Deriving the expression. Label the gate outputs from left to right:

  1. NAND gate output: T = (A . B)'
  2. OR gate output: F = T + C
  3. Substituting back: F = (A . B)' + C

Truth table. Three inputs, so 23 = 8 rows.

ABCA.BT = (A.B)'F = T + C
000011
001011
010011
011011
100011
101011
110100
111101

The five printed columns below are A, B, C, then T, then F.

for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            print(A, B, C, int(not (A and B)), int((not (A and B)) or C))
0 0 0 1 1
0 0 1 1 1
0 1 0 1 1
0 1 1 1 1
1 0 0 1 1
1 0 1 1 1
1 1 0 0 0
1 1 1 0 1

Observation: F is 0 on exactly one row, A = 1, B = 1, C = 0. That is the only case where the NAND turns off and C is not there to hold the OR gate up.

5 Show that NOR is a universal gate by realising the NOT, OR and AND gates using NOR gates only. State how many NOR gates each realisation needs.Universal gates

A gate is universal if the three basic gates NOT, AND and OR can all be built from copies of it alone. If that is possible, then since every Boolean expression is made of NOT, AND and OR, every circuit whatsoever can be built from that one gate.

1. NOT using 1 NOR gate. Tie both inputs together and feed A to both.

A NOR A = (A + A)' = A' [using the idempotent law A + A = A]

A ---+
     +--[ NOR ]-- A'
A ---+

2. OR using 2 NOR gates. A NOR gate already inverts, so invert it back with a second NOR wired as a NOT.

Let T = A NOR B = (A + B)'. Then T NOR T = T' = ((A + B)')' = A + B [involution law]

3. AND using 3 NOR gates. Invert both inputs first, then NOR them.

(A NOR A) = A' and (B NOR B) = B'. Then A' NOR B' = (A' + B')' = (A')' . (B')' = A . B [De Morgan's second law, then involution]

Verification — every operation below is written strictly as not (x or y), that is, as a NOR:

print("A B | NOTA | A+B | A.B")
for A in [0, 1]:
    for B in [0, 1]:
        nA = int(not (A or A))
        nB = int(not (B or B))
        t  = int(not (A or B))
        orAB = int(not (t or t))
        andAB = int(not (nA or nB))
        print(A, B, "|  ", nA, " | ", orAB, " | ", andAB)
A B | NOTA | A+B | A.B
0 0 |   1  |  0  |  0
0 1 |   1  |  1  |  0
1 0 |   0  |  1  |  0
1 1 |   0  |  1  |  1

The three columns match the standard NOT, OR and AND truth tables exactly. Hence NOR is universal, needing 1 gate for NOT, 2 for OR and 3 for AND. (NAND is universal in the same way, with 1 gate for NOT, 2 for AND and 3 for OR — note the AND and OR counts swap over.)

6 Simplify the Boolean expression (A + B) . (B + C) and state how many gates the simplified circuit needs.Expression simplification and gate count

Step-by-step simplification.

  1. (A + B).(B + C)
  2. = A.B + A.C + B.B + B.C [multiply out, using the distributive law]
  3. = A.B + A.C + B + B.C [idempotent law: B.B = B]
  4. = (B + B.C) + B.A + A.C [rearranged by the commutative law]
  5. = B + B.A + A.C [absorption law: B + B.C = B]
  6. = B + A.C [absorption law again: B + B.A = B]

Answer: B + A.C.

A quicker route is the dual of the distributive law, A + B.C = (A + B).(A + C). Reading it right to left with A replaced by B gives (B + A).(B + C) = B + A.C directly, in one step.

Gate count. The original (A + B).(B + C) needs 2 OR gates and 1 AND gate = 3 gates. The simplified B + A.C needs 1 AND gate and 1 OR gate = 2 gates, and still only 2 levels, so it is cheaper with no loss of speed.

B ---------------+
                 +--[ OR ]-- F
A ---+           |
     +--[ AND ]--+
C ---+

Verification over all 8 rows — the five printed columns are A, B, C, then the original, then the simplified form:

ok = True
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            L = int((A or B) and (B or C))
            R = int(B or (A and C))
            print(A, B, C, L, R)
            if L != R: ok = False
print("Equal:", ok)
0 0 0 0 0
0 0 1 0 0
0 1 0 1 1
0 1 1 1 1
1 0 0 0 0
1 0 1 1 1
1 1 0 1 1
1 1 1 1 1
Equal: True

Previous-year board questions 4

Q1 State De Morgan's second law and verify it using a truth table. Board pattern — 2 marks

Statement. De Morgan's second law states that the complement of a sum is equal to the product of the complements:

(A + B)' = A' . B'

That is, NOT (A OR B) = (NOT A) AND (NOT B). Intuitively: "neither A nor B" is the same as "not A, and also not B".

Verification.

ABA + BLHS = (A + B)'A'B'RHS = A' . B'
0001111
0110100
1010010
1110000

The LHS column and the RHS column are identical on all four rows, therefore (A + B)' = A' . B'. Hence proved.

law2 = True
for A in [0, 1]:
    for B in [0, 1]:
        if int(not (A or B)) != int((not A) and (not B)):
            law2 = False
print("De Morgan 2  (A+B)' = A'.B'  holds:", law2)
De Morgan 2  (A+B)' = A'.B'  holds: True

Extension often asked as a follow-up: the law works for any number of variables — (A + B + C)' = A'.B'.C'. The three-variable version of this same check is run in full in the Boolean algebra section, and it also prints True.

Q2 Draw the logic circuit for the Boolean function F(A, B) = A.B' + A'.B and name the single logic gate that can replace the whole circuit. Board pattern — 2 marks

Reading the expression. There are two product terms, so two AND gates, and they are summed, so one OR gate. Each product needs one complemented input, so two NOT gates. Total: 5 gates in 3 levels.

Level 1        Level 2          Level 3

A -----------------+
                   +--[ AND ]--+
B ---[ NOT ]--B'---+           |
                               +--[ OR ]-- F
A ---[ NOT ]--A'---+           |
                   +--[ AND ]--+
B -----------------+

Truth table.

ABA'B'A.B'A'.BF
0011000
0110011
1001101
1100000

Identification. F is 1 exactly when A and B differ. That is the XOR (exclusive OR) gate, so all five gates can be replaced by one XOR gate: F = A XOR B.

The four printed columns below are A, B, the derived F, and Python's bitwise XOR of A and B.

for A in [0, 1]:
    for B in [0, 1]:
        F = int((A and not B) or ((not A) and B))
        print(A, B, F, A ^ B)
0 0 0 0
0 1 1 1
1 0 1 1
1 1 0 0

The derived F column and Python's XOR operator agree on every row, confirming the identification. This is a good example of why simplification matters: 5 gates and 3 levels become 1 gate and 1 level.

Q3 A circuit has three inputs A, B and C. Its output F is 1 when at least two of the three inputs are 1, and 0 otherwise. Write the truth table, derive the Boolean expression, and state the number of gates required. Board pattern — 3 marks

Truth table. Three inputs, so 8 rows. Count the number of 1s in each row and put F = 1 where that count is 2 or 3.

ABCNumber of 1sF
00000
00110
01010
01121
10010
10121
11021
11131

Deriving the expression (Sum of Products). Write one AND term for each row where F = 1, complementing any variable that is 0 in that row:

F = A'BC + AB'C + ABC' + ABC

Simplifying. The last term ABC can be reused three times, since A + A = A allows a term to be duplicated freely:

  1. F = A'BC + ABC + AB'C + ABC + ABC' + ABC
  2. = BC(A' + A) + AC(B' + B) + AB(C' + C) [distributive law]
  3. = BC.1 + AC.1 + AB.1 [complement law]
  4. F = A.B + B.C + A.C [identity law]

Gate count. Three 2-input AND gates feeding one 3-input OR gate = 4 gates in 2 levels. If only 2-input OR gates are available, two of them are needed instead of one, giving 5 gates in 3 levels — slightly slower because the signal passes through one extra gate.

A ---+
     +--[ AND ]--+
B ---+           |
B ---+           |
     +--[ AND ]--+--[ OR ]-- F
C ---+           |
A ---+           |
     +--[ AND ]--+
C ---+
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            F = int((A and B) or (B and C) or (A and C))
            print(A, B, C, "|         ", F)
0 0 0 |          0
0 0 1 |          0
0 1 0 |          0
0 1 1 |          1
1 0 0 |          0
1 0 1 |          1
1 1 0 |          1
1 1 1 |          1

The simplified expression reproduces the required truth table exactly.

Q4 A school portal uses the condition not (marks >= 33 and attendance >= 75) to decide whether to show a warning. Apply De Morgan's law to rewrite this condition so that no complement is applied to a bracket, and show that the two forms are equivalent. Board pattern — 2 marks

Applying the law. Let P stand for marks >= 33 and Q for attendance >= 75. The condition is (P . Q)'. By De Morgan's first law:

(P . Q)' = P' + Q'

Now the complement of a comparison is just the opposite comparison: the complement of marks >= 33 is marks < 33, and the complement of attendance >= 75 is attendance < 75. Also, the AND becomes an OR. So:

marks < 33 or attendance < 75

Read aloud, this says "warn if the student failed, or is short on attendance" — which is exactly the intended meaning, and is far easier to read than the original.

Two mistakes to avoid. Do not keep the and — writing marks < 33 and attendance < 75 would warn only students who fail on BOTH counts, which is a different and much smaller group. And do not forget to flip the comparisons: not (marks >= 33) is marks < 33, not marks <= 33, because 33 itself is a pass.

Verification — testing every combination of a failing, borderline and comfortable value for each field. The four printed columns are marks, attendance, the original condition and the rewritten one:

same = True
for marks in [20, 33, 90]:
    for attendance in [50, 75, 100]:
        L = not (marks >= 33 and attendance >= 75)
        R = (marks < 33) or (attendance < 75)
        print(marks, attendance, L, R)
        if L != R:
            same = False
print("Rewrite is equivalent:", same)
20 50 True True
20 75 True True
20 100 True True
33 50 True True
33 75 False False
33 100 False False
90 50 True True
90 75 False False
90 100 False False
Rewrite is equivalent: True

The two columns match on all nine test cases, including the boundary case marks = 33 and attendance = 75, where both correctly give False (no warning).

Part of Priodemy for School

Interactive CBSE lessons, Class 8–12 — free with every school on Priodemy EduSuite. Explore more chapters and labs on the Priodemy for School hub.

Ask AI