Boolean algebra and logic circuits · A level · OCR H446 1.4.3, AQA 7517 4.6.5.1, Eduqas A500QS 1.2 · about 20 min
The identities, commutation, association, distribution, double negation and absorption, proved by truth table.
[1 mark]Which law is used in the step A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)?
[1 mark]What is A ∨ 1?
[1 mark]What does A ∨ (A ∧ B) simplify to?
[1 mark]What does A ∨ (¬A ∧ B) simplify to?
[1 mark]Which of these are true for every value of A, B and C?
Tick every answer that is true.
[1 mark]What does this program print?
count = 0
for a in [0, 1]:
for b in [0, 1]:
for c in [0, 1]:
if (a | (b & c)) != ((a | b) & c):
count = count + 1
print(count)Write equivalent(f, g). Its inputs f and g are functions of three bits, f(a, b, c), each returning 0 or 1. It tries all eight rows in binary order (a, then b, then c, each 0 then 1) and returns the first row where f and g give different results, as a tuple (a, b, c), or None if they agree on every row.
Then, for each (name, f, g) in the list laws, in order, print one line: <name>: equivalent if they agree, or <name>: not equivalent at A=<a> B=<b> C=<c> using the row equivalent returned. That makes six lines.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
laws = [
("distribution", lambda a, b, c: a & (b | c), lambda a, b, c: (a & b) | (a & c)),
("absorption", lambda a, b, c: a | (a & b), lambda a, b, c: a),
("association", lambda a, b, c: (a | b) | c, lambda a, b, c: a | (b | c)),
("OR over AND", lambda a, b, c: a | (b & c), lambda a, b, c: (a | b) & (a | c)),
("false friend", lambda a, b, c: a | (b & c), lambda a, b, c: (a | b) & c),
("half absorbed", lambda a, b, c: a & (a | b), lambda a, b, c: a | b),
]
def equivalent(f, g):
return NonePlan your program here, then type it in and press Run.
f and g only ever return 0 or 1, and use it to catch a function written with ~.