Fundamentals of Artificial Intelligence Master Reference & Formula Handbook
Consolidated mathematical formulas, search complexity matrices, game tree pruning protocols, probabilistic inference, and Python foundations for 21CSC569J.
02. Informed Heuristic Search (A* & AO*)
A* Evaluation Function & Admissibility
$$f(n) = g(n) + h(n)$$Admissibility: $0 \le h(n) \le h^*(n)$ (Never overestimates true minimal cost). Guarantees optimal path.
Consistency (Monotonicity): $h(n) \le c(n, a, n') + h(n') \implies f(n) \le f(n')$. Guarantees $f(n)$ is non-decreasing along paths.
8-Puzzle Manhattan Distance Heuristic
$$h(n) = \sum_{i=1}^8 \left( |x_i - x_i^{\text{goal}}| + |y_i - y_i^{\text{goal}}| \right)$$Benchmark: May 2025 Initial State has $h(S_0) = 5$, $g(S_0) = 0 \implies f(n) = 5$ constant at all 5 optimal moves.
AO* And-Or Branch Cost Propagation
$$\text{OR Branch: } \operatorname{Cost}(n) = \min_i [c(n, n_i) + h(n_i)], \qquad \text{AND Branch: } \operatorname{Cost}(n) = \sum_j [c(n, n_j) + h(n_j)]$$03. Adversarial Search & Constraint Satisfaction
Minimax & Alpha-Beta Pruning Invariant
$$\alpha \ge \beta \implies \text{PRUNE remaining sibling branches!}$$$\alpha = \max(\alpha, v)$ updated at MAX nodes ($\alpha = -\infty$). $\beta = \min(\beta, v)$ updated at MIN nodes ($\beta = +\infty$).
SEND + MORE = MONEY Cryptarithmetic Solution
$$\begin{matrix} & 9 & 5 & 6 & 7 \\ + & 1 & 0 & 8 & 5 \\ \hline 1 & 0 & 6 & 5 & 2 \end{matrix}$$ $$M = 1, \ O = 0, \ S = 9, \ E = 5, \ N = 6, \ R = 8, \ D = 7, \ Y = 2$$ $$\mathbf{N + E + E + D = 6 + 5 + 5 + 7 = 23}$$04. Uninformed Search Traversal & Complexities
| Search Algorithm | Data Structure | Complete? | Optimal? | Time | Space |
|---|---|---|---|---|---|
| Breadth-First (BFS) | FIFO Queue | Yes | Yes (unit cost) | $O(b^d)$ | $O(b^d)$ (Exponential) |
| Depth-First (DFS) | LIFO Stack | No (infinite trees) | No | $O(b^m)$ | $O(bm)$ (Linear) |
| Depth-Limited (DLS) | LIFO Stack (Limit $L$) | Yes (if $d \le L$) | No | $O(b^L)$ | $O(bL)$ (Linear) |
| Iterative Deepening (IDS) | LIFO Stack (Repeated) | Yes | Yes (unit cost) | $O(b^d)$ | $O(bd)$ (Optimal + Linear) |
Hill Climbing 3 Hazards
1. Local Maxima: Peak lower than global optimum $\to$ Remedy: Random Restart.
2. Plateau / Shoulder: Flat zero gradient $\to$ Remedy: Limited sideways moves.
3. Ridge: Steep sides, gentle spine $\to$ Remedy: Simulated Annealing ($P = e^{\Delta E / T}$).
05. Knowledge Representation & Bayesian Networks
The Alarm Bayesian Network Solution
$$P(A \mid J, M, \neg E, \neg B) = \frac{P(A \mid \neg B, \neg E)P(J \mid A)P(M \mid A)}{\sum_{a} P(a \mid \neg B, \neg E)P(J \mid a)P(M \mid a)}$$ $$= \frac{0.001 \times 0.90 \times 0.70}{(0.001 \times 0.90 \times 0.70) + (0.999 \times 0.05 \times 0.01)} = \frac{0.000630}{0.0011295} = \frac{140}{251} \approx \mathbf{55.78\%}$$Minsky's Frames & Chaining
Frames Structure: Slots (attributes), Facets (defaults/ranges), and Procedural Demons (`if-needed`, `if-added`, `if-removed`).
Forward Chaining: Data-driven ($\text{IF} \to \text{THEN}$) starting from facts (CLIPS, Rete).
Backward Chaining: Goal-driven ($\text{THEN} \to \text{IF}$) starting from hypothesis (Prolog, MYCIN).
06. Python Core, Pandas & Visualization
Mutability & Memory Proof
Strings are Immutable: Modification raises `TypeError`. Creating/concatenating alters `id(obj)`.
Lists are Mutable: In-place `append()` retains identical `id(obj)`.
Essential Pandas Commands
• Missing Data: `df.isnull().sum()`, `df.fillna(df['col'].mean(), inplace=True)`, `df.dropna(subset=['col'])`
• GroupBy: `df.groupby('Store')['Sales'].agg(['sum', 'mean'])`
• Filtering: `df[(df['Category'] == 'Electronics') & (df['Total_Sales'] > 10000)]`
07. Master Algorithm Matrix
| Algorithm | Class | Heuristic Used | Time | Space | Key Invariant |
|---|---|---|---|---|---|
| A* Search | Informed Graph | Admissible $h(n) \le h^*(n)$ | $O(b^d)$ | $O(b^d)$ | $f(n) = g(n) + h(n)$ |
| AO* Search | AND-OR Hypergraph | Underestimate $h(n)$ | $O(b^d)$ | $O(bd)$ | AND takes sum; OR takes min |
| Minimax | Adversarial Game | Static Evaluation | $O(b^m)$ | $O(bm)$ | Alternating MAX/MIN plies |
| Alpha-Beta | Adversarial Game | Static Evaluation | $O(b^{m/2})$ optimal | $O(bm)$ | Cutoff when $\alpha \ge \beta$ |
| Bayesian Net | Probabilistic Graphical | CPTs | $O(n \cdot 2^k)$ | $O(n \cdot 2^k)$ | $\prod P(X_i \mid \text{Parents}(X_i))$ |