~/ learn/ comp-456/ cards/ Logic & truth-table drills
1 of 4

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/c8dd5aa7-e75b-4340-94ab-fa9d3e6eb4e1/flashcard utf-8 LF