Last Minute Notes (LMNs) Artificial Intelligence (original) (raw)

Last Updated : 23 Jul, 2025

Artificial Intelligence (AI) refers to the simulation of human intelligence processes by machines, especially computer systems. AI encompasses tasks like learning, reasoning, problem-solving, perception, and language understanding. The ultimate goal of AI is to create systems that can perform tasks that would typically require human intelligence, such as recognizing speech, making decisions, and visual perception.

Search Algorithms in AI

Search problems in AI involve finding a path from an initial state to a goal state. It consists of defining the environment, the available actions, and the rules for transitioning between states.

**Uninformed search algorithms do not have any additional information about the goal beyond the problem's definition. They explore the search space without any heuristics.

**a) **Breadth-First Search (BFS)

BFS uses a queue (FIFO structure) to explore all nodes at the current depth level before moving on to nodes at the next level. It starts at the root node and explores its neighbors first, then their neighbors, and so on.

The algorithm ensures that the shallowest goal is found first, making it complete for finite search spaces.

**b) **Uniform Cost Search (UCS)

UCS uses a priority queue where nodes are prioritized by their path cost (g(n)). Unlike BFS, it expands the node with the least cumulative cost, ensuring that it always finds the optimal path.

**c) **Depth-First Search (DFS)

DFS uses a stack (LIFO structure) to explore as far down a branch as possible before backtracking. It is memory efficient but may fail to find a solution in infinite-depth spaces or loops.

**d) **Depth-Limited Search

Depth limited search is a variation of DFS, where a depth limit is imposed to prevent infinite recursion or exploring too deep. It stops searching when the depth limit is reached, even if the goal is not found.

**e) **Iterative Deepening Depth-First Search (IDDFS)

IDDFS combines the memory efficiency of DFS and the completeness of BFS. It performs a series of depth-limited searches, incrementally increasing the depth limit until the goal is found.

**f) **Bidirectional Search

Bidirectional search runs two simultaneous searches: one from the start state and the other from the goal state. The searches meet in the middle, significantly reducing the search space.

**Informed search algorithms use problem-specific knowledge (heuristics) to find the solution more efficiently by guiding the search process.

**Heuristic Function is used to guide the search algorithm by estimating the cost to reach the goal from a given state.

**a) **Greedy Best-First Search

Greedy best-first search prioritizes nodes based on heuristic functions h(n) that estimates the cost to reach the goal from a node. The algorithm does not guarantee an optimal solution, as it focuses solely on the heuristic.

**b) **A * Search Algorithm

A* search algorithm combines uninformed cost search and greedy best-first search by evaluating nodes using f(n) = g(n) + h(n), where g(n) is the cost to reach the node and h(n) is the heuristic estimate of the cost from the node to the goal. A* search guarantees optimality if the heuristic is admissible (never overestimates) and consistent.

**c) **Iterative Deepening A* Search (IDA*)

IDA* search combines A* and iterative deepening to overcome A*'s memory limitation. IDA* performs a series of depth-limited searches where the depth limit is based on the f(n) value instead of depth in the search tree.

In each iteration, nodes are explored only if their f(n) value is within the current threshold. The threshold is updated iteratively to the smallest f(n) value that exceeded the current threshold, ensuring an optimal solution.

**Adversarial search is used when multiple agents compete to maximize their payoff while minimizing the opponent’s payoff.

**a) **Minimax Algorithm

Minimax algorithm computes optimal decisions in two-player games, assuming both players play optimally. The algorithm recursively evaluates all possible moves to choose the best one for the current player.

**b) **Alpha-Beta Pruning

Alpha-beta pruning optimizes Minimax by pruning branches that do not influence the final decision. It uses two values, \alpha (best already explored option for the maximizer) and \beta (best for the minimizer), to prune irrelevant nodes.

Logic in Artificial Intelligence

**1. Propositional Logic

**Propositional Logic (Boolean Logic) deals with statements that are either true or false. The simplest form of logic used to represent facts about the world and manipulate those facts.

Common logical connectives are:

Truth table is used to determine the truth value of compound propositions. For example for P\rightarrow Q:

P Q P → Q
T T T
T F F
F T T
F F T

Propositional logic cannot handle environments of unlimited size effectively because it lacks the ability to express concepts related to time, space, and universal relationships between objects in a concise manner.

**2. Predicate Logic

**Predicate Logicrepresent and reason about statements involving objects, their properties and their relationship. The object represent entities in the domain of discourse (e.g., "John," "car," or "number").

It extends propositional logic by introducing:

**First-order logic is a specific type of predicate logic with additional restrictions:

  1. **Constants: Names for specific objects (e.g., John,2,a).
  2. **Variables: Generic placeholders for objects (e.g., x, y, z).
  3. **Predicates: Represent properties or relationships (e.g., Student(x), Taller(x,y)).
  4. **Functions: Represent mappings (e.g., Father(x)).
  5. **Quantifiers: Express properties of entire collection of objects. First-order logic contains two standard quantifiers:
    • **Universal Quantifier (∀): States that a proposition is true for all values of a variable. Example: \forall x \, Student(x) \to Studies(x): "All students study."
    • *Existential Quantifier (\exists)*: States that a property applies to at least one object in the domain.
      Example: \exists x \, Likes(x, IceCream): "Someone likes ice cream."
    • \forall and \exists are interrelated and often interchangeable via negation.
  6. **Logical Connectives:\land, \lor, \neg, \to, \leftrightarrow

**Inference in Predicate Logic

Reasoning Under Uncertainty

AI systems often work with uncertain information. This uncertainty arises due to:

To handle uncertainty, AI uses tools like probabilistic reasoning to make inferences about the most likely outcomes.

Conditional Independence Representation

Conditional independence representation deals with uncertainty and probabilistic models. It allows us to simplify complex probabilistic relationships by assuming that two events are independent given some third event.

Two variables X and Y are conditionally independent given Z if the probability of X given Z is unaffected by Y:

P(X | Y, Z) = P(X | Z)

In a Bayesian network, conditional independence is encoded by the network structure:

D-separation to determine conditional independence in a directed acyclic graph (DAG). For example, a set of nodes Z blocks a path between X and Y if:

Exact Inference Through Variable Elimination

Variable elimination is a method used in probabilistic graphical models for exact inference. It allows for the computation of marginal probabilities by systematically eliminating variables that are not of interest.

The variable elimination algorithm can be summarized in the following steps:

  1. **Initialization:
    • Identify all random variables involved in the model.
    • Define the sets of query variables Y, evidence variables E, and hidden variables Z.
  2. **Evidence Handling: Incorporate evidence into the computation using evidence potentials, which simplify the summation and conditioning processes.
  3. **Elimination Process: Iteratively eliminate each variable in Z by summing over its values. For each variable v being eliminated:
    • Identify all factors that include v.
    • Multiply these factors together.
    • Sum out v to create a new factor that does not include v.
  4. **Normalization: After all relevant variables have been eliminated, normalize the resulting factor to obtain a proper probability distribution.

Approximate Inference Through Sampling

Approximate inference is used to estimate probabilities or make decisions when exact inference is too computationally expensive. Sampling methods randomly sample from the probability distribution to estimate the result. This allows us to estimate complex probabilities quickly, even in large models.

**1. Direct sampling methods involve generating random samples from the probability distribution of a model and using these samples to approximate the desired probability.

For example: If you want to estimate **P(A), you would generate random samples from the model, count how many times **A is true, and divide by the total number of samples to get the approximate probability of **A.

**2. **Rejection Sampling is a technique used to sample from complex distributions by generating samples from a simpler, easier-to-sample distribution and rejecting those that do not meet certain criteria. The process of random sampling involves following steps

  1. **Sample Generation: Generate a point from a proposal distribution (a distribution from which sampling is straightforward).
  2. **Acceptance Criteria: Accept the sample if it meets the criteria based on the target probability distribution; otherwise, reject it and repeat the process.

**3. **Likelihood Weighting is an advance sampling technique used in Bayesian networks to handle observed evidence. The process involves following steps:

  1. **Sampling Order: Sample from the network's variables in a specific order, excluding the evidence variables (those with known values).
  2. **Weighting Samples: For each sample, assign a weight based on the likelihood of the evidence given that sample.
  3. **Weight Adjustment: Adjust the weight of each sample according to how well it matches the evidence, giving more importance to samples that align closely with the observed data.
  4. **Iteration: Repeat this process multiple times to create a collection of weighted samples.

This method allows for more efficient inference in Bayesian networks compared to basic rejection sampling.