Propositional Logic Cheat Sheet

Complete Reference Guide for Knowledge-Based Agents

Back to Lecture Overview

Overview & Motivation

Key Idea: Logic provides a formal language for representing knowledge and drawing inferences in a truth-preserving way.
Advantages of Logic:
  • Compact representation of knowledge
  • Truth-preserving inference rules
  • Formal reasoning without enumeration
  • High expressiveness
Three Components of Logic:
  1. Syntax: Valid formulas
  2. Semantics: Meaning (models)
  3. Inference Rules: Derivation rules

1. Syntax

Definition: Syntax defines the set of valid formulas (grammatical expressions).
Building Blocks:
Propositional Symbols (Atoms):
A, B, C, Rain, Wet, Traffic

Atomic formulas representing basic propositions

Logical Connectives:
¬, ∧, ∨, →, ↔

Operators for combining formulas

Recursive Formula Construction:
Connective Symbol Formula Name
NOT ¬ ¬f Negation
AND f ∧ g Conjunction
OR f ∨ g Disjunction
IMPLIES f → g Implication
IFF f ↔ g Biconditional
Examples:
  • Valid: A, ¬A, A ∧ B, (A ∨ B) → C
  • Invalid: A ¬B, A + B, → A

2. Semantics

Definition: Semantics specifies the meaning of formulas through worlds and models.
World (Possible World):
Definition: A world represents a possible configuration or state of affairs in reality.
Key Concept: A world is a complete description of how things could be. Each world represents a hypothetical scenario where certain propositions are true and others are false.
Example: Different possible worlds:
  • World 1: It's raining, the ground is wet, it's Monday
  • World 2: It's not raining, the ground is wet (sprinklers), it's Monday
  • World 3: It's not raining, the ground is dry, it's Tuesday
Model:
Definition - Model:

A model w in propositional logic is an assignment of truth values to propositional symbols.

Important Note: In logic, the word "model" has a special meaning, quite distinct from how we use it in machine learning (quite an unfortunate collision). A model (in the logical sense) represents a possible state of affairs in the world.
w = {A: 0/1, B: 0/1, C: 0/1, ...}

Model: A mathematical representation of a world - an assignment of truth values (0 or 1) to propositional symbols.

Relationship: Each model w corresponds to exactly one possible world, and vice versa.

Example: All Possible Models

Given: 3 propositional symbols: A, B, C

Number of possible models: 2³ = 8

All 8 possible models w:
1. {A:0, B:0, C:0}
2. {A:0, B:0, C:1}
3. {A:0, B:1, C:0}
4. {A:0, B:1, C:1}
 
5. {A:1, B:0, C:0}
6. {A:1, B:0, C:1}
7. {A:1, B:1, C:0}
8. {A:1, B:1, C:1}

General Rule: With n propositional symbols, there are 2ⁿ possible models.

World ↔ Model: We use "world" when thinking about reality and "model" when doing formal logic. They refer to the same thing!
Interpretation Function I(f, w):
Returns true (1) if model w satisfies formula f, false (0) otherwise.
Truth Table for Connectives:
f g ¬f f ∧ g f ∨ g f → g f ↔ g
0 0 1 0 0 1 1
0 1 1 0 1 1 0
1 0 0 0 1 0 0
1 1 0 1 1 1 1
Models of a Formula M(f):
M(f) = {w | I(f, w) = 1}

Definition: The set of all models (worlds) that satisfy formula f.

Intuition: M(f) picks out all the possible worlds where formula f is true.

Example: f = Rain ∨ Wet
M(f) includes all worlds/models where Rain=1 or Wet=1 or both.

These are worlds like:

  • World where it's raining and wet
  • World where it's not raining but wet (sprinklers)
  • World where it's raining but somehow not wet (unusual!)

Key Insight: A formula compactly represents a set of possible worlds!

3. Knowledge Base (KB)

Definition: KB is a set of formulas representing their conjunction (all must be true).
M(KB) = ⋂f∈KB M(f)

Intuition: KB specifies constraints on the world.

M(KB) is the set of all possible worlds satisfying those constraints.

Key Insight: Adding formulas to KB shrinks the set of possible worlds (adds more constraints on reality).
Example:
  • KB = {Rain, Rain → Wet}
  • M(KB) = all worlds where both Rain and Wet are true
  • Interpretation: KB rules out worlds where it's not raining, or where it's raining but not wet
  • Possible worlds consistent with KB: Only worlds where it's raining AND the ground is wet
Narrowing Down Worlds:
  • Start: All 2ⁿ possible worlds
  • Add formula: Eliminate worlds that don't satisfy it
  • More knowledge → Fewer possible worlds
  • Goal: Narrow down to the actual world!

4. Relationships: Entailment, Contradiction, Contingency

Entailment
KB ⊨ f

Definition: M(f) ⊇ M(KB)

f adds no information (already known)

Example:
Rain ∧ Snow ⊨ Snow
Contradiction
KB ⊨ ¬f

Definition: M(KB) ∩ M(f) = ∅

f contradicts KB

Example:
Rain ∧ Snow
contradicts ¬Snow
Contingency
Neither

Definition: ∅ ⊊ M(KB) ∩ M(f) ⊊ M(KB)

f adds non-trivial information

Example:
Rain and Snow
Important Relationship: KB contradicts f ⟺ KB entails ¬f

5. Knowledge Base Operations

Tell[f] → KB

Purpose: Add new information

Responses:
  • KB ⊨ f: Already knew that
  • KB ⊨ ¬f: Don't believe that
  • Contingent: Learned something new (update KB)
Ask[f] → KB

Purpose: Query for information

Responses:
  • KB ⊨ f: Yes
  • KB ⊨ ¬f: No
  • Contingent: I don't know

6. Satisfiability & Model Checking

Satisfiability: KB is satisfiable if M(KB) ≠ ∅
Reduce Ask[f] to Satisfiability:
Check Entailment (KB ⊨ f):
Is KB ∪ {¬f} unsatisfiable?
Check Contradiction (KB ⊨ ¬f):
Is KB ∪ {f} unsatisfiable?
Complexity: SAT is NP-complete!
Model Checking as CSP:
Propositional Logic CSP
Propositional symbol Variable
Formula Constraint
Model Assignment
Algorithms:
  • DPLL: Backtracking search + pruning
  • WalkSat: Randomized local search

7. Inference Rules

Inference Rule: Syntactic pattern for deriving new formulas
Premises
───────────
Conclusion
Key Idea: Inference rules operate directly on syntax, not semantics!
Classic Inference Rules:
Modus Ponens:
p, p → q
─────────
q

"If p implies q and p is true, then q is true"

Modus Tollens:
p → q, ¬q
─────────
¬p

"If p implies q and q is false, then p is false"

Forward Inference Algorithm:
  1. Repeat until no changes to KB:
  2. Choose formulas f₁, ..., fₖ ∈ KB
  3. If matching rule exists: f₁,...,fₖ / g
  4. Add g to KB
Derivation (KB ⊢ f): f is eventually added to KB by applying inference rules

8. Soundness & Completeness

"The truth, the whole truth, and nothing but the truth"
Soundness

"Nothing but the truth"

{f : KB ⊢ f} ⊆ {f : KB ⊨ f}

Meaning: Everything derived is true. If we can derive f using inference rules, then f must be entailed.

Completeness

"The whole truth"

{f : KB ⊢ f} ⊇ {f : KB ⊨ f}

Meaning: All truths can be derived. If f is entailed, we can derive it using inference rules.

Visual Analogy:

Glass = Set of true formulas {f : KB ⊨ f}

Water = Set of derived formulas {f : KB ⊢ f}

  • Sound: Water never overflows the glass
  • Complete: Water fills the glass to the brim
Checking Soundness Example:
Is Rain, Rain → Wet / Wet sound?

Check: M(Rain) ∩ M(Rain → Wet) ⊆ M(Wet)

Result: ✅ Yes, this is sound!

9. Quick Reference Table

Notation Meaning Description
World Possible World A complete possible configuration of reality
w Model Mathematical representation of a world; assignment of truth values to propositional symbols
I(f, w) Interpretation Returns 1 if world w satisfies formula f, 0 otherwise
M(f) Models of f Set of all possible worlds (models) that satisfy f
M(KB) Models of KB Set of all possible worlds consistent with the knowledge base
KB ⊨ f Entailment f is true in all possible worlds where KB is true
KB ⊢ f Derivation f can be derived from KB using inference rules
SAT(KB) Satisfiability KB has at least one satisfying world (model)

10. Key Formulas & Relationships

Remember: M(f) represents the set of all possible worlds where formula f is true. All formulas below are about sets of worlds!
Model Operations (Operations on Sets of Worlds):
M(KB) = ⋂f∈KB M(f)

The worlds satisfying KB are exactly those worlds that satisfy all formulas in KB

M(f ∧ g) = M(f) ∩ M(g)

Worlds where both f and g are true

M(f ∨ g) = M(f) ∪ M(g)

Worlds where at least one of f or g is true

M(¬f) = All worlds \ M(f)

Worlds where f is false

Relationship Tests:
KB ⊨ f ⟺ M(f) ⊇ M(KB)
KB contradicts f ⟺ M(KB) ∩ M(f) = ∅
KB contradicts f ⟺ KB ⊨ ¬f
Satisfiability Tests:
KB ⊨ f ⟺ KB ∪ {¬f} is unsatisfiable
SAT(KB) ⟺ M(KB) ≠ ∅

Summary

Three Views of Logic:
  1. Syntax: Manipulation of symbols according to rules
  2. Semantics: Truth in possible worlds (models)
  3. Inference: Deriving new knowledge from existing knowledge
Model Checking:
  • Uses semantics
  • Enumerate and test models
  • Guaranteed correct
  • Can be slow (NP-complete)
Inference Rules:
  • Uses syntax
  • Apply rules to formulas
  • Can be efficient
  • Need soundness & completeness
Try Interactive Demos Next: CNF & Clause Form