Logic & Its Applications
Propositional logic, predicates and quantifiers, and Boolean algebra โ the language every other topic on this exam is written in. Master this and the rest follows.
1.1 Propositional Logic
A proposition is a declarative sentence that is either true or false โ never both, never neither. Everything in this course either is one, is a combination of them, or quantifies over them.
Examples of propositions (โ) and non-propositions (โ)
- โ "$2 + 3 = 5$" โ true.
- โ "$7$ is an odd number." โ true.
- โ "Every even integer $> 2$ is the sum of two primes." โ Goldbach's conjecture; nobody knows the truth value yet, but it has one, so it counts.
- โ "$x + 1 = 3$" โ depends on $x$; this is a predicate, not a proposition.
- โ "Close the window." โ a command, not declarative.
- โ "What time is it?" โ a question.
Logical connectives
We build complex propositions from simpler ones using connectives. Memorize these โ they are the building blocks of everything.
| Symbol | Name | Read as | When it's true |
|---|---|---|---|
| $\lnot p$ | Negation | "not $p$" | $p$ is false |
| $p \land q$ | Conjunction | "$p$ and $q$" | both true |
| $p \lor q$ | Disjunction (inclusive) | "$p$ or $q$" | at least one true |
| $p \oplus q$ | XOR | "$p$ xor $q$" | exactly one true |
| $p \to q$ | Implication | "if $p$ then $q$" | except when $p=T, q=F$ |
| $p \leftrightarrow q$ | Biconditional | "$p$ iff $q$" | both have same value |
The implication is the tricky one
$p \to q$ is only false when $p$ is true and $q$ is false. If $p$ is false, the implication is vacuously true โ "If the moon is cheese, then I'm a billionaire" is a true statement, because the antecedent is false. This is the rule that confuses students most.
Truth tables for the connectives
| $p$ | $q$ | $\lnot p$ | $p\land q$ | $p\lor q$ | $p\oplus q$ | $p\to q$ | $p\leftrightarrow q$ |
|---|---|---|---|---|---|---|---|
| T | T | F | T | T | F | T | T |
| T | F | F | F | T | T | F | F |
| F | T | T | F | T | T | T | F |
| F | F | T | F | F | F | T | T |
Building truth tables for compound propositions
To find the truth value of any compound proposition, you build a truth table over all combinations of the variables. With $n$ atomic propositions, you get $2^n$ rows.
Worked Example. Construct the truth table for $(p \land q) \to (p \lor q)$.
| $p$ | $q$ | $p\land q$ | $p\lor q$ | $(p\land q)\to(p\lor q)$ |
|---|---|---|---|---|
| T | T | T | T | T |
| T | F | F | T | T |
| F | T | F | T | T |
| F | F | F | F | T |
Always true โ this is a tautology. Notice that the antecedent $p \land q$ logically implies the consequent $p \lor q$.
Tautologies, contradictions, contingencies
- Tautology: true for every truth assignment. e.g. $p \lor \lnot p$.
- Contradiction: false for every assignment. e.g. $p \land \lnot p$.
- Contingency: sometimes true, sometimes false.
Logical equivalences โ your toolkit
Two compound propositions $\varphi$ and $\psi$ are logically equivalent ($\varphi \equiv \psi$) if they have the same truth value under every assignment. Equivalently, $\varphi \leftrightarrow \psi$ is a tautology.
| Name | Equivalence |
|---|---|
| Identity | $p \land T \equiv p$, $\;\;p \lor F \equiv p$ |
| Domination | $p \lor T \equiv T$, $\;\;p \land F \equiv F$ |
| Idempotent | $p \lor p \equiv p$, $\;\;p \land p \equiv p$ |
| Double negation | $\lnot(\lnot p) \equiv p$ |
| Commutative | $p \lor q \equiv q \lor p$, etc. |
| Associative | $(p\lor q)\lor r \equiv p\lor(q\lor r)$ |
| Distributive | $p \land (q \lor r) \equiv (p\land q) \lor (p \land r)$ |
| De Morgan | $\lnot(p\land q)\equiv \lnot p\lor\lnot q$, $\;\;\lnot(p\lor q)\equiv \lnot p\land\lnot q$ |
| Absorption | $p \lor (p\land q)\equiv p$ |
| Negation | $p \lor \lnot p \equiv T$, $\;\;p \land \lnot p \equiv F$ |
| Implication | $p \to q \equiv \lnot p \lor q$ |
| Contrapositive | $p \to q \equiv \lnot q \to \lnot p$ |
| Biconditional | $p\leftrightarrow q \equiv (p\to q)\land(q\to p)$ |
The two equivalences you must memorize
Implication as disjunction: $p \to q \equiv \lnot p \lor q$. This single rewrite unlocks half of all simplification problems.
De Morgan: negation distributes by flipping $\land \leftrightarrow \lor$.
Satisfiability
Unsatisfiable: no assignment makes it true (i.e., it's a contradiction).
Useful facts that you can be asked to prove:
- $\varphi$ is unsatisfiable $\iff$ $\lnot\varphi$ is a tautology.
- $\varphi$ is a tautology $\iff$ $\lnot\varphi$ is unsatisfiable.
Worked Example. Is $(p \lor \lnot q) \land (\lnot p \lor q) \land (\lnot p \lor \lnot q)$ satisfiable?
Solution. Try $p = F$: then $\lnot p = T$ kills the second and third clauses easily. The first clause requires $p \lor \lnot q$, i.e. $\lnot q$, so $q = F$. Check: clause 1 = $F\lor T = T$ โ, clause 2 = $T \lor F = T$ โ, clause 3 = $T\lor T = T$ โ. Satisfiable with $p=F, q=F$.
Sudoku as a SAT problem
A classic application. We encode the rules of Sudoku as a compound proposition over Boolean variables. For an $n \times n$ Sudoku using digits $\{1,\ldots,n\}$, define $$p(i,j,k) = \text{โcell }(i,j)\text{ contains digit }k\text{โ}.$$ Then the rules become:
- Every cell has at least one number. $$\bigwedge_{i,j}\bigvee_k p(i,j,k)$$
- Each row $i$ contains digit $k$. The single-row condition is $\bigvee_j p(i,j,k)$; combining over all $i$ and $k$: $$\bigwedge_i \bigwedge_k \bigvee_j p(i,j,k)$$
- Each column $j$ contains digit $k$. $$\bigwedge_j \bigwedge_k \bigvee_i p(i,j,k)$$
- Each 3ร3 block (for 9ร9) contains each digit. For each block $B$ and each $k$: $$\bigvee_{(i,j)\in B} p(i,j,k)$$
- No cell has two numbers. $$\bigwedge_{i,j} \bigwedge_{k \neq k'} \lnot(p(i,j,k) \land p(i,j,k'))$$
1.2 Predicate Logic & Quantifiers
Propositions alone can't say things like "every integer has a successor." For that we need predicates and quantifiers.
The two quantifiers
- Universal $\forall x\, P(x)$ โ "for all $x$ in the domain, $P(x)$ is true." True iff $P$ holds for every element.
- Existential $\exists x\, P(x)$ โ "there exists an $x$ such that $P(x)$." True iff at least one element makes $P$ true.
Domain matters
$\forall x\,(x^2 \geq 0)$ is true if the domain is $\mathbb{R}$, but $\forall x\,(2x > x)$ is false on $\mathbb{R}$ (try $x = 0$ or $x < 0$) and true on positive reals. Always state your domain.
Nested quantifiers
Order matters when you mix $\forall$ and $\exists$.
Let $L(x,y)$ mean "$x$ loves $y$" with domain = all people.
- $\forall x\, \exists y\, L(x,y)$ โ "Everyone loves someone (not necessarily the same person)."
- $\exists y\, \forall x\, L(x,y)$ โ "There is someone whom everyone loves." Much stronger!
- $\forall x\, \forall y\, L(x,y)$ โ "Everyone loves everyone."
- $\exists x\, \exists y\, L(x,y)$ โ "Some pair loves each other (or themselves)."
Rule of thumb: swapping $\forall \exists$ to $\exists \forall$ makes a stronger statement. The implication $\exists y \forall x \to \forall x \exists y$ always holds; the reverse does not.
Negating quantified statements
Two formulas you must know cold (sometimes called the quantifier De Morgan rules):
$\lnot \exists x\, P(x) \;\equiv\; \forall x\, \lnot P(x)$
Pushing a negation through a quantifier flips the quantifier and negates the body. Apply repeatedly to negate nested statements.
Worked Example. Negate: "Every student in this class has taken some math course."
Formally: $\forall x\, \exists y\, (\text{Student}(x) \to \text{Took}(x,y))$.
Negation: $\exists x\, \forall y\, (\text{Student}(x) \land \lnot \text{Took}(x,y))$. In English: "There is a student in this class who has not taken any math course."
Translating English to predicate logic
Strategy:
- Identify the variables and their domain.
- Define predicates (with clear meaning).
- Read the English carefully โ "only if", "unless", "some", "every", "no" all carry quantifier meaning.
- Watch for hidden conditionals. "Every dog barks" is really $\forall x\,(\text{Dog}(x) \to \text{Barks}(x))$ โ not $\forall x\,(\text{Dog}(x) \land \text{Barks}(x))$, which would say everything is a barking dog.
"Only if" trap
"$p$ only if $q$" means $p \to q$, NOT $q \to p$. "$p$ if $q$" means $q \to p$. "$p$ if and only if $q$" means both.
1.3 Boolean Algebra & Computer Architecture
Boolean algebra is propositional logic in different clothing. We use $1$ for $T$, $0$ for $F$, and the connectives are written:
| Logic | Boolean | Gate |
|---|---|---|
| $p \land q$ | $pq$ or $p \cdot q$ | AND |
| $p \lor q$ | $p + q$ | OR |
| $\lnot p$ | $\bar p$ | NOT |
| $p \oplus q$ | $p\bar q + \bar p q$ | XOR |
Sum-of-products (SOP) & Product-of-sums (POS)
SOP / DNF: a sum (OR) of minterms โ one minterm per row of the truth table where the function is 1.
Maxterm: a sum of literals, one for each variable. POS / CNF: a product of maxterms โ one per row where the function is 0.
How to write the SOP. Build the truth table. For each row where $F = 1$, write the minterm using each variable directly if it's 1 in that row, negated if it's 0. Then OR all the minterms.
Worked Example. $F(x,y,z) = x + yz$. Truth table:
| $x$ | $y$ | $z$ | $F$ | Minterm (when $F=1$) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | โ |
| 0 | 0 | 1 | 0 | โ |
| 0 | 1 | 0 | 0 | โ |
| 0 | 1 | 1 | 1 | $\bar x y z$ |
| 1 | 0 | 0 | 1 | $x\bar y\bar z$ |
| 1 | 0 | 1 | 1 | $x\bar y z$ |
| 1 | 1 | 0 | 1 | $xy\bar z$ |
| 1 | 1 | 1 | 1 | $xyz$ |
SOP: $F = \bar x y z + x\bar y\bar z + x\bar y z + xy\bar z + xyz$.
Karnaugh Maps (K-Maps) โ minimizing SOP
A K-map is a 2D grid layout of a truth table where adjacent cells differ in exactly one variable (Gray code ordering). Group adjacent 1s into rectangles of size $2^k$ to eliminate variables.
Rules for grouping
- Groups must be rectangular and contain $1, 2, 4, 8, \ldots$ cells (powers of 2).
- Each group must contain only $1$s.
- Groups should be as large as possible (each doubling eliminates one variable).
- Every $1$ must be covered by at least one group; use the fewest groups possible.
- K-maps wrap around โ left โ right, top โ bottom edges are adjacent.
K-map layout (3 variables)
| $yz=00$ | $yz=01$ | $yz=11$ | $yz=10$ | |
|---|---|---|---|---|
| $x=0$ | $\bar x\bar y\bar z$ | $\bar x\bar y z$ | $\bar x y z$ | $\bar x y\bar z$ |
| $x=1$ | $x\bar y\bar z$ | $x\bar y z$ | $x y z$ | $x y\bar z$ |
Note the column ordering $00,01,11,10$ (Gray code).
Worked Example. Minimize $f(x,y,z) = xy\bar z + x\bar y z + \bar x y z + \bar x \bar y \bar z$ using a K-map.
Fill the map:
| $yz=00$ | $yz=01$ | $yz=11$ | $yz=10$ | |
|---|---|---|---|---|
| $x=0$ | 1 | 0 | 1 | 0 |
| $x=1$ | 0 | 1 | 0 | 1 |
Notice all four 1s are isolated โ no two are adjacent. So no simplification beats the original. Each 1 must stay as its own minterm. Minimized form is the original. This is the XOR pattern: $f = x \oplus y \oplus z$ when an odd number of the three are 1.
When K-map gives no reduction
If 1s form a "checkerboard," your function is an XOR/XNOR โ common in parity circuits. Don't try to force it; report it as XOR.
Representing arithmetic with propositional logic
A favorite exam question: given a 4-bit number $x$ with bits $x_3 x_2 x_1 x_0$ (LSB first), write a proposition checking arithmetic properties.
- $x \geq 8$: $x_3$ (the high bit must be 1).
- $x$ divisible by $4$: $\lnot x_0 \land \lnot x_1$ (low two bits are 0).
- $x$ divisible by $2$: $\lnot x_0$.
- $x$ is a power of $2$: exactly one $x_i$ is true. Express via "at least one is true AND for each pair at most one is true," or just enumerate: $(x_0\land\lnot x_1\land\lnot x_2\land\lnot x_3)\lor(\lnot x_0\land x_1\land\lnot x_2\land\lnot x_3)\lor\ldots$
- $x = y$: $(x_0\leftrightarrow y_0)\land(x_1\leftrightarrow y_1)\land(x_2\leftrightarrow y_2)\land(x_3\leftrightarrow y_3)$.
- $x = 2y$: shifting $y$ left by 1: $\lnot x_0 \land (x_1 \leftrightarrow y_0) \land (x_2 \leftrightarrow y_1) \land (x_3 \leftrightarrow y_2) \land \lnot y_3$ (so $y \leq 7$, else overflow).
Interactive tools
Two small tools to help you check your work without flipping back and forth โ build a truth table from a proposition, or minimize a Boolean expression on a K-map.
Use letters for variables, and ! or ~ for NOT, & AND, | OR, ^ XOR, -> implies, <-> iff. Parentheses supported. Up to 5 variables.
Click cells to toggle 0/1. Variables: rows = wx, columns = yz, both in Gray code. Minimal SOP appears below.
Problem Bank โ Logic
Drawn from DPP 1โ4, Logic worksheets, and the midsem paper. Try each on paper first; reveal the solution to check your reasoning.
Construct a truth table for $p \oplus (p \lor q)$.
Goal: Construct the truth table for the compound proposition $p \oplus (p \lor q)$ and simplify the resulting expression.
Step-by-Step Evaluation:
- Identify Variables: There are two variables ($p$ and $q$), which requires $2^2 = 4$ rows to cover all truth assignments.
- Evaluate $p \lor q$ (Conjunction): $p \lor q$ is true in all rows except when both $p$ and $q$ are false.
- Evaluate $p \oplus (p \lor q)$ (Exclusive OR): The exclusive OR operation $\oplus$ evaluates to true if and only if its two operands have different truth values.
| $p$ | $q$ | $p\lor q$ | $p\oplus(p\lor q)$ |
|---|---|---|---|
| T | T | T | F |
| T | F | T | F |
| F | T | T | T |
| F | F | F | F |
Conclusion: Looking at the final column, the output is true only when $p$ is false ($F$) and $q$ is true ($T$). Therefore, the compound proposition is logically equivalent to $\lnot p \land q$. โ
Translate to propositional logic: "You can borrow the rare book only if you are a faculty member and have a valid ID." Let $F$ = faculty, $I$ = ID, $B$ = borrow.
Goal: Translate the English statement into a formal propositional logic statement using the variables provided.
Step-by-Step Translation:
- Analyze the Connective: The statement uses the conditional construct "only if". Recall that the proposition "$p \text{ only if } q$" translates to $p \to q$. The condition following "only if" represents a necessary condition and forms the consequent (on the right of the arrow).
- Identify Necessary Condition: "you are a faculty member and have a valid ID" is the necessary condition. This is translated as a conjunction: $(F \land I)$.
- Identify Antecedent: "You can borrow the rare book" is the antecedent: $B$.
- Formulate Implication: Combining these yields: $$B \to (F \land I)$$
Common Pitfall Note: Avoid writing $(F \land I) \to B$. This represents the converse ("if you are a faculty member and have a valid ID, you can borrow the book"), which is not implied by the original statement. โ
Which of the following is NOT a tautology?
- $(a\to b)\land(b\to c) \to (a\to c)$
- $(a\leftrightarrow c)\to(\lnot b \to (a\land c))$
- $(a\land b\land c)\to(c\lor a)$
- $a \to (b \to a)$
Goal: Determine which of the four given compound propositions is not a tautology by finding a counterexample (a truth assignment that makes the statement false).
Analysis of Options:
- Option (a): This is the Law of Hypothetical Syllogism. It states that implication is transitive, which is a fundamental tautology.
- Option (c): The antecedent is $a \land b \land c$. If this conjunction is true, then both $a$ and $c$ must be true. Therefore, the consequent $c \lor a$ must also be true. This implication is always true, so it is a tautology.
- Option (d): The expression is equivalent to $\lnot a \lor (\lnot b \lor a) \equiv (\lnot a \lor a) \lor \lnot b \equiv T \lor \lnot b \equiv T$. Since it simplifies to $T$, it is a tautology.
- Option (b): Let's test for a truth assignment that makes this implication false ($T \to F = F$):
- To make the consequent $(\lnot b \to (a \land c))$ false, we must have $\lnot b = T$ (meaning $b = F$) and $a \land c = F$.
- To make the antecedent $(a \leftrightarrow c)$ true, $a$ and $c$ must share the same truth value.
- Since $a \land c = F$ and they must have the same value, we set $a = F$ and $c = F$.
- Substitute $a=F, b=F, c=F$ into the full expression: $$\text{Antecedent: } F \leftrightarrow F \equiv T$$ $$\text{Consequent: } \lnot F \to (F \land F) \equiv T \to F \equiv F$$ $$\text{Implication: } T \to F \equiv F$$
Conclusion: The truth assignment $a = F, b = F, c = F$ makes option (b) false. Thus, (b) is not a tautology. Answer: (b). โ
Determine whether $(p \to q) \land (p \to \lnot q) \land (\lnot p \to q) \land (\lnot p \to \lnot q)$ is satisfiable.
Goal: Determine if there exists at least one truth assignment to the variables $p$ and $q$ that makes the compound proposition true.
Step-by-Step Analysis:
- Simplify individual clauses using implication-to-disjunction equivalence ($a \to b \equiv \lnot a \lor b$):
- $C_1: p \to q \equiv \lnot p \lor q$
- $C_2: p \to \lnot q \equiv \lnot p \lor \lnot q$
- $C_3: \lnot p \to q \equiv p \lor q$
- $C_4: \lnot p \to \lnot q \equiv p \lor \lnot q$
- Evaluate cases for assignment of variable $p$:
- Case 1 ($p = T$): Under this assignment, the first two clauses reduce: $$C_1 \land C_2 \equiv (F \lor q) \land (F \lor \lnot q) \equiv q \land \lnot q \equiv F$$ Since the conjunction contains a contradiction ($F$), the entire statement is false for $p = T$.
- Case 2 ($p = F$): Under this assignment, the last two clauses reduce: $$C_3 \land C_4 \equiv (F \lor q) \land (F \lor \lnot q) \equiv q \land \lnot q \equiv F$$ Similarly, this evaluates to false for $p = F$.
Conclusion: No assignment of truth values to $p$ and $q$ can satisfy the compound proposition. Therefore, the expression is unsatisfiable (a contradiction). โ
Show that the negation of an unsatisfiable proposition is a tautology, and conversely.
Goal: Prove that a compound proposition $\varphi$ is unsatisfiable if and only if its negation $\lnot\varphi$ is a tautology.
Proof:
- Part 1: Negation of an unsatisfiable proposition is a tautology.
- Assume $\varphi$ is unsatisfiable. By definition, under any truth assignment $v$, the valuation of $\varphi$ is false: $$v(\varphi) = F \quad \text{for all assignments } v.$$
- By definition of the negation operator, we evaluate the negation $\lnot\varphi$: $$v(\lnot\varphi) = \lnot(v(\varphi)) = \lnot(F) = T \quad \text{for all assignments } v.$$
- Since $v(\lnot\varphi) = T$ for every possible truth assignment, $\lnot\varphi$ is a tautology.
- Part 2: Negation of a tautology is unsatisfiable.
- Assume $\varphi$ is a tautology. By definition, under any truth assignment $v$, the valuation of $\varphi$ is true: $$v(\varphi) = T \quad \text{for all assignments } v.$$
- Evaluating the negation $\lnot\varphi$: $$v(\lnot\varphi) = \lnot(v(\varphi)) = \lnot(T) = F \quad \text{for all assignments } v.$$
- Since $v(\lnot\varphi) = F$ for every possible truth assignment, $\lnot\varphi$ is unsatisfiable. โ
$x,y$ are Boolean (0 or 1). Translate the C-style condition "if (x * (1 - y)) + ((1 - x) * y) ..." into propositional logic.
Goal: Translate the arithmetic expression `(x * (1 - y)) + ((1 - x) * y)` over binary variables $x, y \in \{0, 1\}$ into standard propositional logic operators.
Step-by-Step Translation:
- Translate multiplication and subtraction:
- In binary arithmetic, multiplication represents the logical AND ($\land$) operation: $a \cdot b = 1 \iff a=1 \land b=1$.
- The term $(1 - z)$ represents the logical NOT ($\lnot$) operation: $1 - z = 1 \iff z = 0$.
- Evaluate the two terms:
- Term 1: $x \cdot (1 - y) \equiv x \land \lnot y$.
- Term 2: $(1 - x) \cdot y \equiv \lnot x \land y$.
- Translate addition:
- Addition of these two binary terms yields: $(x \land \lnot y) + (\lnot x \land y)$.
- Since the two terms cannot both be 1 simultaneously (as $x$ cannot be both 0 and 1), the sum is either 0 or 1. Thus, addition behaves as a logical disjunction ($\lor$) or exclusive-OR ($\oplus$).
- Combine terms: $$ (x \land \lnot y) \lor (\lnot x \land y) $$
Conclusion: The expression evaluates to 1 when exactly one of $x$ or $y$ is 1. Therefore, it translates to the logical exclusive-OR: $x \oplus y$. โ
$x \in \{0,\ldots,15\}$ with bits $x_3x_2x_1x_0$. Write a proposition asserting that $x$ is divisible by 5.
Goal: Write a boolean expression over the bits $x_3, x_2, x_1, x_0$ that evaluates to true if and only if the integer $x$ represented by the bits is a multiple of 5.
Step-by-Step Analysis:
- Identify multiples of 5: In the range $\{0, \ldots, 15\}$, the multiples of 5 are:
- $0 = 0000_2$ (bits: $x_3=0, x_2=0, x_1=0, x_0=0$)
- $5 = 0101_2$ (bits: $x_3=0, x_2=1, x_1=0, x_0=1$)
- $10 = 1010_2$ (bits: $x_3=1, x_2=0, x_1=1, x_0=0$)
- $15 = 1111_2$ (bits: $x_3=1, x_2=1, x_1=1, x_0=1$)
- Identify patterns in bits:
- In all four numbers, compare $x_3$ and $x_1$: they are always equal ($0=0$, $0=0$, $1=1$, $1=1$). This can be written as $(x_3 \leftrightarrow x_1)$.
- Compare $x_2$ and $x_0$: they are also always equal ($0=0$, $1=1$, $0=0$, $1=1$). This can be written as $(x_2 \leftrightarrow x_0)$.
Conclusion: The boolean expression asserting divisibility of $x$ by 5 is: $$\text{Div}_5(x) = (x_3 \leftrightarrow x_1) \land (x_2 \leftrightarrow x_0)$$ To prove this holds for no other numbers, we can verify that any of the other 12 numbers fails this condition (e.g. $1 = 0001_2$ has $x_2=0, x_0=1$, which fails). โ
Express in predicate logic: "Some students have never been asked a question by a faculty member." Use $S(x)$ = "$x$ is a student," $F(x)$ = "$x$ is a faculty member," $A(x,y)$ = "$x$ has asked $y$ a question."
Goal: Translate the given English sentence into a formal predicate logic expression using the provided predicates.
Step-by-Step Translation:
- Identify the Subject ("Some students"): This indicates an existential quantifier over the students: $$\exists x \, (S(x) \land \dots)$$ We use $\land$ because we are asserting both that $x$ is a student, and that $x$ satisfies the rest of the property.
- Translate the Property ("have never been asked a question by a faculty member"):
- "For all faculty members $y$, $y$ has not asked $x$ a question."
- This is formalized as: $\forall y \, (F(y) \to \lnot A(y, x))$. We use $\to$ here because the condition "never asked" applies only if $y$ is actually a faculty member.
- Combine Quantifiers: $$\exists x \, (S(x) \land \forall y \, (F(y) \to \lnot A(y, x)))$$
- Alternative formulation: We can also write "there does not exist a faculty member who asked $x$ a question": $$\exists x \, (S(x) \land \lnot \exists y \, (F(y) \land A(y, x)))$$ Both are logically equivalent. โ
Express the negation, in quantifiers and in English: "There is a student in this class who has taken every mathematics course offered at this school."
Goal: Formalize the English statement, apply the negation operator using quantifier laws, and translate the negated statement back into natural English.
Step-by-Step Derivation:
- Formalize the original statement: Let $S(x)$ = "$x$ is a student in this class," $C(y)$ = "$y$ is a mathematics course offered at this school," and $T(x,y)$ = "$x$ has taken $y$." $$\varphi = \exists x \, (S(x) \land \forall y \, (C(y) \to T(x, y)))$$
- Apply Negation: $$\lnot \varphi = \lnot \exists x \, (S(x) \land \forall y \, (C(y) \to T(x, y)))$$ Apply the quantifier negation rule ($\lnot \exists \equiv \forall \lnot$): $$\equiv \forall x \, \lnot (S(x) \land \forall y \, (C(y) \to T(x, y)))$$ Apply De Morgan's Law to the conjunction: $$\equiv \forall x \, (\lnot S(x) \lor \lnot \forall y \, (C(y) \to T(x, y)))$$ Apply quantifier negation ($\lnot \forall \equiv \exists \lnot$): $$\equiv \forall x \, (\lnot S(x) \lor \exists y \, \lnot (C(y) \to T(x, y)))$$ Recall that $\lnot(a \to b) \equiv a \land \lnot b$: $$\equiv \forall x \, (\lnot S(x) \lor \exists y \, (C(y) \land \lnot T(x, y)))$$ Rewrite disjunction back to conditional ($a \to b \equiv \lnot a \lor b$): $$\equiv \forall x \, (S(x) \to \exists y \, (C(y) \land \lnot T(x, y)))$$
- Translate back to English: "For every student in this class, there is some mathematics course offered at this school that they have not taken." โ
Suresh: "In every region there is a town where all inhabitants are happy." Which sentence correctly negates this?
- There is a region where there is a town where all inhabitants are happy.
- In every region in all towns all inhabitants are happy.
- In every region there is a town where at least one inhabitant is unhappy.
- There is a region where in all towns at least one inhabitant is unhappy.
Goal: Negate Suresh's statement formally and select the matching English sentence.
Step-by-Step Negation:
- Formalize Suresh's statement: Let $r$ denote a region, $t$ denote a town in region $r$ ($t \in r$), $i$ denote an inhabitant of town $t$ ($i \in t$), and $H(i)$ mean "$i$ is happy." $$\varphi = \forall r \, \exists t \in r \, \forall i \in t \, H(i)$$
- Negate the formal statement step-by-step: $$\lnot\varphi = \lnot \left[ \forall r \, \exists t \in r \, \forall i \in t \, H(i) \right]$$ $$\equiv \exists r \, \lnot \left[ \exists t \in r \, \forall i \in t \, H(i) \right]$$ $$\equiv \exists r \, \forall t \in r \, \lnot \left[ \forall i \in t \, H(i) \right]$$ $$\equiv \exists r \, \forall t \in r \, \exists i \in t \, \lnot H(i)$$
- Translate the result back to English: "There is a region ($\exists r$) where, in all towns in that region ($\forall t \in r$), there is at least one inhabitant who is unhappy ($\exists i \in t \, \lnot H(i)$)."
Conclusion: This matches option (d). โ
Translate using $P(x)$="hummingbird," $Q(x)$="large," $R(x)$="lives on honey," $S(x)$="richly colored":
(a) All hummingbirds are richly colored.
(b) No large birds live on honey.
(c) Birds that do not live on honey are dull in color.
(d) Hummingbirds are small. (conclusion)
Goal: Translate each English premise and the conclusion into predicate logic statements over the domain of all birds.
Step-by-Step Translation:
- (a) All hummingbirds are richly colored. "For all birds $x$, if $x$ is a hummingbird, then $x$ is richly colored." $$\forall x \, (P(x) \to S(x))$$
- (b) No large birds live on honey. "For all birds $x$, if $x$ is large, then $x$ does not live on honey." $$\forall x \, (Q(x) \to \lnot R(x))$$
- (c) Birds that do not live on honey are dull in color. "For all birds $x$, if $x$ does not live on honey, then $x$ is not richly colored (dull)." $$\forall x \, (\lnot R(x) \to \lnot S(x))$$ (Note: Contrapositively, this is equivalent to $\forall x \, (S(x) \to R(x))$).
- (d) Hummingbirds are small. (conclusion) "Small" means "not large". "For all birds $x$, if $x$ is a hummingbird, then $x$ is not large." $$\forall x \, (P(x) \to \lnot Q(x))$$ โ
Find the sum-of-products expansion of $F(x,y,z) = (x+z)y$.
Goal: Expand the Boolean function $F(x,y,z) = (x+z)y$ into its canonical Sum-of-Products (SOP) form, where each term (minterm) contains all three variables.
Step-by-Step Algebraic Expansion:
- Apply the distributive law: $$F = (x+z)y = xy + yz$$
- Expand $xy$ to include $z$: Multiply by $(z + \bar{z})$ (since $z + \bar{z} = 1$): $$xy = xy(z + \bar{z}) = xyz + xy\bar{z}$$
- Expand $yz$ to include $x$: Multiply by $(x + \bar{x})$: $$yz = yz(x + \bar{x}) = xyz + \bar{x}yz$$
- Combine terms (OR them together) and remove duplicates: $$F = (xyz + xy\bar{z}) + (xyz + \bar{x}yz)$$ $$F = xyz + xy\bar{z} + \bar{x}yz$$
Conclusion: The canonical sum-of-products expansion is: $$F = xyz + xy\bar{z} + \bar{x}yz$$ โ
Use a K-map to find the minimal SOP for $xy + x\bar y + \bar x y + \bar x \bar y$.
Goal: Simplify the 2-variable Boolean expression $F = xy + x\bar y + \bar x y + \bar x \bar y$ using a Karnaugh Map.
Step-by-Step Minimization:
- Draw and fill the 2-variable K-map:
$y=0$ ($\bar{y}$) $y=1$ ($y$) $x=0$ ($\bar{x}$) 1 ($\bar x \bar y$) 1 ($\bar x y$) $x=1$ ($x$) 1 ($x \bar y$) 1 ($xy$) - Identify Groups: All 4 cells contain 1s. We can group all 4 cells into a single rectangular block of size $2^2 = 4$.
- Determine Simplified Term: A group of size 4 in a 2-variable K-map covers the entire grid. Since all variables change state across the group, they are all eliminated.
Conclusion: The minimal SOP is: $$F = 1$$ This indicates the function is a tautology (always evaluates to 1). โ
Minimize $f(x,y,z) = xy\bar z + x\bar y z + \bar x y z + \bar x \bar y \bar z$ using a K-map.
Goal: Find the minimal Sum-of-Products (SOP) form for the Boolean function $f(x,y,z)$ using a 3-variable K-map.
Step-by-Step Minimization:
- Set up Gray Code grid columns for $yz$: Columns are ordered as $00, 01, 11, 10$.
- Plot the minterms on the grid:
$yz=00$ $yz=01$ $yz=11$ $yz=10$ $x=0$ 1 ($\bar x\bar y\bar z$) 0 1 ($\bar x y z$) 0 $x=1$ 0 1 ($x\bar y z$) 0 1 ($xy\bar z$) - Attempt Grouping:
- Notice that the 1s are arranged in a "checkerboard" pattern.
- Recall that adjacent cells include wrap-around (leftmost and rightmost columns). Even considering wrap-around, no two 1s share an edge.
- Hence, we cannot form any groups of size 2 or larger. Each minterm must remain isolated in a group of size 1.
Conclusion: No algebraic simplification is possible. The minimal SOP is the original four-term expression: $$f(x,y,z) = xy\bar z + x\bar y z + \bar x y z + \bar x \bar y \bar z$$ (Note: In terms of standard logic gates, this represents the 3-input exclusive-OR operation: $f = x \oplus y \oplus z$). โ
For 4ร4 Sudoku with digits $\{1,2,3,4\}$ and predicate $p(i,j,k)$ = "cell $(i,j)$ contains $k$", write:
(a) WFF for Rule 1: every row contains $\{1,2,3,4\}$ exactly once.
(b) WFF for Rule 2: every column contains $\{1,2,3,4\}$ exactly once.
(c) WFF for Rule 3: every 2ร2 subgrid contains $\{1,2,3,4\}$ exactly once.
(d) WFF asserting no cell has more than one number.
Goal: Formulate the constraints of a 4ร4 Sudoku puzzle as Well-Formed Formulas (WFFs) using the defined predicate $p(i,j,k)$.
Formulations:
- (a) Rule 1 (Rows): Every row $i$ must contain every digit $k$ (at least once), and no digit $k$ can appear in two different columns $j$ and $j'$ of row $i$: $$\bigwedge_{i=1}^{4}\bigwedge_{k=1}^{4}\left[\left(\bigvee_{j=1}^{4} p(i,j,k)\right) \land \bigwedge_{j \neq j'} \lnot(p(i,j,k) \land p(i,j',k))\right]$$
- (b) Rule 2 (Columns): Every column $j$ must contain every digit $k$, and no digit $k$ can appear in two different rows $i$ and $i'$ of column $j$: $$\bigwedge_{j=1}^{4}\bigwedge_{k=1}^{4}\left[\left(\bigvee_{i=1}^{4} p(i,j,k)\right) \land \bigwedge_{i \neq i'} \lnot(p(i,j,k) \land p(i',j,k))\right]$$
- (c) Rule 3 (2ร2 subgrids): There are four subgrids, indexed by $(a,b) \in \{0,1\} \times \{0,1\}$, where subgrid $(a,b)$ covers rows $\{2a+1, 2a+2\}$ and columns $\{2b+1, 2b+2\}$. For each subgrid and each digit $k$, $k$ must appear: $$\bigwedge_{a=0}^{1}\bigwedge_{b=0}^{1}\bigwedge_{k=1}^{4}\left[ \left(\bigvee_{i=2a+1}^{2a+2}\bigvee_{j=2b+1}^{2b+2} p(i,j,k)\right) \land \bigwedge_{(i,j) \neq (i',j')} \lnot\big(p(i,j,k) \land p(i',j',k)\big) \right]$$ where the second conjunction is over distinct pairs of cells $(i,j)$ and $(i',j')$ in the same subgrid.
- (d) No cell has more than one number: For any cell $(i,j)$, if it contains $k$, it cannot contain any other digit $k'$: $$\bigwedge_{i=1}^{4}\bigwedge_{j=1}^{4}\bigwedge_{k \neq k'} \lnot(p(i,j,k) \land p(i,j,k'))$$ โ
Show that $\lnot(p \to q) \equiv p \land \lnot q$ using equivalences (not a truth table).
Goal: Prove the logical equivalence $\lnot(p \to q) \equiv p \land \lnot q$ step-by-step, citing the logical law used in each transition.
Proof:
| Expression | Justification |
|---|---|
| $\lnot(p \to q)$ | Start |
| $\equiv \lnot(\lnot p \lor q)$ | Implication Law (since $a \to b \equiv \lnot a \lor b$) |
| $\equiv \lnot(\lnot p) \land \lnot q$ | De Morgan's Law (negation distributes over disjunction by flipping to conjunction) |
| $\equiv p \land \lnot q$ | Double Negation Law (since $\lnot\lnot a \equiv a$) |
Hence, the equivalence is proved. โ
Explain how a $4 \times 4$ Sudoku puzzle can be modeled as a Satisfiability problem; mention the types of logical constraints needed.
Goal: Describe the mapping of a 4ร4 Sudoku puzzle into a propositional satisfiability (SAT) framework.
SAT Model Formulation:
- Variables: We introduce $4 \times 4 \times 4 = 64$ binary variables. Define $p(i, j, k) = T$ if cell $(i, j)$ contains the digit $k \in \{1, 2, 3, 4\}$, and $F$ otherwise.
- Constraints (expressed in Conjunctive Model Form, CNF):
- Cell-Fill Constraint: Every cell $(i,j)$ must contain at least one digit: $$\bigwedge_{i=1}^4 \bigwedge_{j=1}^4 \left(p(i,j,1) \lor p(i,j,2) \lor p(i,j,3) \lor p(i,j,4)\right)$$
- Cell-Uniqueness Constraint: A cell $(i,j)$ cannot contain more than one digit: $$\bigwedge_{i,j}\bigwedge_{k \neq k'} \left(\lnot p(i,j,k) \lor \lnot p(i,j,k')\right)$$
- Row Constraints: Each row $i$ must contain each digit $k$ at least once: $$\bigwedge_{i=1}^4 \bigwedge_{k=1}^4 \left( \bigvee_{j=1}^4 p(i,j,k) \right)$$
- Column Constraints: Each column $j$ must contain each digit $k$ at least once: $$\bigwedge_{j=1}^4 \bigwedge_{k=1}^4 \left( \bigvee_{i=1}^4 p(i,j,k) \right)$$
- Subgrid Constraints: Each of the four 2ร2 subgrids must contain each digit $k$: $$\bigwedge_{\text{grid } B}\bigwedge_{k=1}^4 \left( \bigvee_{(i,j) \in B} p(i,j,k) \right)$$
- Givens (Hints): For any pre-filled cell $(i, j)$ with a known value $K$, add the unit clause clause: $$(p(i, j, K))$$
- Solving: The conjunction of all these clauses forms a CNF formula. A SAT solver is run on this formula. The puzzle is solvable if and only if the formula is satisfiable, and any satisfying truth assignment directly corresponds to a valid solved Sudoku grid. โ
Show that $(p\to q)\land(\lnot q\to\lnot p)$ is a tautology.
Goal: Analyze the compound proposition $(p \to q) \land (\lnot q \to \lnot p)$ to determine if it is a tautology, and explain the correct mathematical context.
Analysis:
- Apply the Contrapositive Law: Recall that an implication is logically equivalent to its contrapositive: $$\lnot q \to \lnot p \equiv p \to q$$
- Substitute back into the expression: $$(p \to q) \land (\lnot q \to \lnot p) \equiv (p \to q) \land (p \to q)$$
- Apply the Idempotent Law ($a \land a \equiv a$): $$\equiv p \to q$$
- Evaluate truth value: The proposition simplifies to $p \to q$, which is false when $p = T$ and $q = F$. Since it is not true for all assignments, the expression is a contingency, not a tautology.
Correct Formulation Note: The question likely intended to ask about the biconditional statement rather than the conjunction: $$(p \to q) \leftrightarrow (\lnot q \to \lnot p)$$ Since $p \to q \equiv \lnot q \to \lnot p$, the biconditional $A \leftrightarrow B$ between two equivalent statements is indeed a tautology (always evaluates to true). โ
- Implication direction: "only if" $\Rightarrow$ arrow points to the right of "only if". "$p$ if $q$" $\Rightarrow$ $q \to p$.
- Negate quantifiers: $\lnot\forall = \exists\lnot$, $\lnot\exists = \forall\lnot$.
- Empty domain trick: $\forall x\, P(x)$ is vacuously true; $\exists x\, P(x)$ is vacuously false.
- K-map ordering: always use Gray code (00, 01, 11, 10) โ adjacent cells must differ in one variable.
- For SAT, build a truth table when you can; for problems with $\leq 3$ variables it's the safest method.