~/ learn/ comp-456/ cards/ Exam Prep: Hand-Tracing & Past-Paper Drills
1 of 25

Truth-table generator: print all 4 rows for (¬P → ¬Q) and (P ∨ ¬Q), then a verdict line. This is the Q1 method on a real past-paper pair.

Truth-table generator: print all 4 rows for (¬P → ¬Q) and (P ∨ ¬Q), then a verdict line. This is the Q1 method on a real past-paper pair.

Answer

def implies(a, b): return (not a) or b def b(x): return 'T' if x else 'F' rows = [(True, True), (True, False), (False, True), (False, False)] left_col, right_col = [], [] print("P Q | (~P->~Q) | (P|~Q)") for P, Q in rows: left = implies(not P, not Q) right = P or (not Q) left_col.append(left) right_col.append(right) print(f"{b(P)} {b(Q)} | {b(left)} | {b(right)}") print("EQUIVALENT" if left_col == right_col else "NOT EQUIVALENT")

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/faafe441-119e-4090-b2f1-5bbf8fd128ff/flashcard utf-8 LF