Propositional Logic
Propositional Logic Study Guide
1. What is Propositional Logic?
Also known as propositional calculus or Boolean logic.
Developed by George Boole in the 19th century.
Used in AI, computer science, and program verification.
Deals with propositions (statements that are either true or false).
Key components:
Syntax: Defines how formulas are structured.
Semantics: Defines the meaning (truth value) of formulas.
Inference Rules: Define how to derive new truths from existing ones.
2. Logical Symbols & Syntax
Logical Operators
Symbol | Meaning |
|---|---|
¬P | NOT P |
P∧Q | P AND Q |
P∨Q | P OR Q |
P⇒Q | P IMPLIES Q |
P⇔Q | P IF AND ONLY IF Q |
Forming Well-Defined Sentences
Atomic sentences: Single propositions (e.g., P, Q, R).
Compound sentences: Built using logical operators (e.g., ¬P∨Q\neg P \vee Q).
Parentheses: Used for grouping to clarify meaning.
Precedence order:
NOT (¬\neg)
AND (∧\wedge)
OR (∨\vee)
IMPLICATION (⇒\Rightarrow)
BICONDITIONAL (⇔\Leftrightarrow)
Example Sentences
¬P∨(Q∧R)
(P⇒Q)∧(Q⇒R)
3. Truth Tables
Basic Truth Tables:
P | Q | P∧Q | P∨Q | P⇒Q | P⇔Q |
|---|---|---|---|---|---|
T | T | T | T | T | T |
T | F | F | T | F | F |
F | T | F | T | T | F |
F | F | F | F | T | T |
Implication (P⇒QP \Rightarrow Q) Key Rule:
It is only false when P is true and Q is false.
Otherwise, it is always true.
Example Truth Table Calculation
For (P∨Q)⇒R:
P | Q | R | P∨QP \vee Q | (P∨Q)⇒R(P \vee Q) \Rightarrow R |
|---|---|---|---|---|
T | T | T | T | T |
T | F | F | T | F |
F | T | T | T | T |
F | F | T | F | T |
F | F | F | F | T |
4. Conjunctive Normal Form (CNF)
CNF is a set of clauses where each clause is a disjunction of literals.
Literal: A variable (e.g., P) or its negation (¬P\neg P).
Clause: Disjunction (OR) of literals (e.g., P∨¬QP \vee \neg Q).
Example conversion to CNF:
Original: P⇒QP \Rightarrow Q
Step 1: Replace ⇒\Rightarrow with ¬P∨Q\neg P \vee Q
CNF: ¬P∨Q\neg P \vee Q
Example Transformation
Convert (P∨(Q∧R))⇒S(P \vee (Q \wedge R)) \Rightarrow S to CNF:
Replace Implication: ¬(P∨(Q∧R))∨S\neg (P \vee (Q \wedge R)) \vee S
Apply De Morgan’s Laws: (¬P∧¬(Q∧R))∨S(\neg P \wedge \neg (Q \wedge R)) \vee S
Distribute Negations: (¬P∧(¬Q∨¬R))∨S(\neg P \wedge (\neg Q \vee \neg R)) \vee S
Distribute OR over AND: (¬P∨S)∧(¬Q∨¬R∨S)(\neg P \vee S) \wedge (\neg Q \vee \neg R \vee S)
5. DPLL Algorithm for Satisfiability
Input: A set of CNF clauses.
Output: A satisfying assignment or failure.
Key Steps:
Unit Propagation: If a clause has one literal, assign it that value.
Pure Literal Elimination: If a variable appears with only one sign, assign it accordingly.
Choose a Variable and Recur: Try setting a variable to true; if failure, try false.
Backtrack if Necessary.
Example Walkthrough
Given clauses:
P∨Q∨¬RP \vee Q \vee \neg R
¬P∨Q∨R\neg P \vee Q \vee R
¬Q∨¬R\neg Q \vee \neg R
Assign P = true (removes clause 1).
Clause 2 simplifies to Q∨RQ \vee R.
Assign Q = false, which makes clause 3 true.
Assign R = true to satisfy clause 2.
Solution: P=T,Q=F,R=TP = T, Q = F, R = T.
6. Search Algorithms: Depth-First vs. Random Probing
Depth-First Search (DFS) for N-Queens
Place queens column by column, backtracking on conflicts.
Pros: Systematic, guaranteed solution.
Cons: Slow for large boards.
Random Probing for N-Queens
Randomly place queens in non-attacked rows.
Restart on failure instead of backtracking.
Pros: Much faster, takes advantage of many solutions.
Cons: No guarantee of finding a solution quickly.
7. Summary of Key Takeaways
Propositional logic forms the basis for reasoning in AI.
Syntax & semantics determine logical validity.
Truth tables define logical operator meanings.
CNF is required for efficient SAT solving.
DPLL efficiently finds satisfying assignments.
Search techniques like DFS and Random Probing vary in efficiency.
Practice Questions
Convert (A⇒B)∧(B⇒C)to CNF.
{¬A ∨ B,
¬B ∨ C}
Construct a truth table for (P∨Q)⇒R.
P
Q
R
P∨Q
(P∨Q)⇒R
¬(PvQ) ∨ R,
T
T
T
T
T
T
F
F
T
F
F
T
T
T
T
F
F
T
T
T
Solve a simple SAT problem using the DPLL algorithm.
{¬A ∨ B,
¬B ∨ C}
Let A = True
Remove A in ¬A ∨ B (Clause 1)
Add A to S
Clause 1 is now singleton atom B
Let B = True
Clause 1 satisfied
Remove B from ¬B ∨ C (Clause 2)
Add B to S
Clause 2 is now singleton atom C
Let C = True
Add C to S
Solution found succesfully
Solution: S = {A-T, B-T, C-T}
Compare DFS and Random Probing in terms of efficiency.
Random probing could be faster but with no guarantee, depending on the randomly selected probe. DFS guarantees an answer but could be slower.
Use this guide to review and test your understanding! 🚀