GATE Data Science & AIGATE DA
Module 9 · Artificial intelligence

AI: search, logic and reasoning under uncertainty

The AI section is small and very predictable: 6 to 10 marks a year from three ideas. Search asks which node is expanded next and whether a heuristic is admissible; logic asks whether a sentence is a tautology or says what an English sentence says; Bayesian networks ask for a probability or a conditional independence. This module teaches each idea on small examples from the Data Premier League and then works through every DA AI question asked so far.

You need: graphs, BFS and DFS from Python & DSA, sets and logic from the maths refreshers, and conditional probability and Bayes’ theorem from probability.

The route

    A lot of AI comes down to one question: given where you are and where you want to be, which sequence of moves gets you there? This part teaches you to see a problem as a map of situations, explores that map blindly (breadth-first, depth-first, uniform-cost), then with a sense of direction (greedy and A*), and finally against an opponent who wants you to lose (minimax and alpha–beta pruning). Search has appeared in every GATE DA paper so far, often with a figure to trace by hand.

    You need: what a graph is, and queues and stacks, from Python & DSA. Nothing else; every AI term is defined here.

    Uninformed search: finding a route with no sense of direction

    Uninformed (or “blind”) search explores a map of possible situations in a fixed order, using only the map itself and never a guess about how close the goal is.

    GATE DA asks which algorithm is uninformed (2026 Q13), and every A* or game-tree question builds on the same ideas: frontier, expansion, path cost. The properties table in this chapter (complete? optimal? how much memory?) is a favourite source of one-mark questions.

    It’s like looking for your friend’s seat in a stadium without a ticket number: you can sweep row by row, or run down one aisle to the end before trying the next, but you have no clue which direction is warmer.

    Where it shows up in GATE DA

    Recognising uninformed algorithms, their properties, and tracing BFS or DFS orders; also the foundation for every A* question.

    2026 Q13 · which is not uninformed?2025 Q44 · A* order (next chapter)Sample Q27 · A* graph search (next chapter)
    Heat: every year as part of search, 1–2 marks

    The problem: the team bus

    The Bengaluru Backprops have an away match against the Kalinga Kernels in Bhubaneswar. Their team bus has a route planner: a program that looks at the road map and decides which roads to drive. That route planner is our first agent.

    An agent is anything that observes its situation and chooses actions. A chess program, a delivery robot and the bus’s route planner are all agents. The agents in this chapter plan the whole sequence of actions in their head first, then carry it out.

    A search problem has five parts. Each is shown with the bus example.

    • States: every situation the world can be in, described just well enough to plan. Bus: which city it is in (8 cities, so 8 states).
    • Initial state: where you start. Bengaluru.
    • Actions: what you can do in a state. In Hyderabad: drive to Bengaluru, Vijayawada, Nagpur or Raipur.
    • Goal test: a check that says whether a state is a goal. “Is the bus in Bhubaneswar?”
    • Path cost: a number for each sequence of actions, the sum of the step costs. Total hours on the road.

    The state space is the graph whose nodes are states and whose edges are actions, labelled with their step costs. A solution is a path from the initial state to a goal state; an optimal solution is one with the smallest path cost.

    So “searching a state space” is a precise phrase: walk around this graph, starting at the initial state, until you find a path to a goal. For the bus the state space is just the road map. For other problems it is far larger and never drawn in full: in a puzzle, each arrangement of the pieces is one state.

    Frontier and expansion: the one idea behind every algorithm

    Every search algorithm in this part keeps two collections:

    • the frontier: states you have discovered (you know a path to them) but have not yet explored from;
    • the explored set (or closed set): states you have already explored from.

    To expand a state means to take it out of the frontier, check whether it is a goal, and if not, put its neighbours (its children, or successors) into the frontier. Start with only the initial state in the frontier and repeat until you expand a goal or the frontier is empty.

    That loop never changes. The only difference between BFS, DFS, uniform-cost search and A* is which state comes out of the frontier next.

    1. frontier ← {initial state}; explored ← empty.
    2. Repeat: if the frontier is empty, report failure. Remove one state $n$ from the frontier (the choice rule defines the algorithm).
    3. If $n$ passes the goal test, return the path to $n$.
    4. Add $n$ to explored. For each child of $n$ that is in neither the frontier nor explored, add it to the frontier and remember $n$ as its parent.

    Without the explored set this is called tree search: it may revisit states and can loop forever on a map with cycles.

    AlgorithmFrontier is a…Next state to expand
    Breadth-first search (BFS)queue (first in, first out)the one discovered earliest: shallowest first
    Depth-first search (DFS)stack (last in, first out)the one discovered most recently: deepest first
    Uniform-cost search (UCS)priority queue keyed by $g(n)$the one with the cheapest path cost so far

    Here $g(n)$ is the cost of the best path found so far from the start to $n$. Uniform-cost search is Dijkstra’s shortest-path algorithm, stopped as soon as the goal is expanded.

    A convention matters in hand traces: we test for the goal when a state is expanded (taken out of the frontier), not when it is first discovered. For uniform-cost search this is essential: a cheaper route to the goal may still be waiting in the frontier. Ties are broken alphabetically unless a question says otherwise.

    Try it

    The bus starts in Bengaluru (BLR) and must reach Bhubaneswar (BBI); numbers on roads are hours. Pick an algorithm and press Step: the readout shows what comes out of the frontier and what is waiting. Compare the three routes. BFS finds the route with the fewest roads (3 roads, 29 h), DFS charges down one branch (30 h), and only uniform-cost search finds the cheapest route, 23 h through Chennai.

    Trace uniform-cost search on the DPL map from Bengaluru (BLR) to Bhubaneswar (BBI). Roads (two-way, hours): BLR–HYD 9, BLR–MAA 5, MAA–VGA 7, HYD–VGA 4, HYD–NAG 8, HYD–RPR 12, NAG–RPR 5, RPR–BBI 8, VGA–VTZ 5, VTZ–BBI 6. In what order are the cities expanded, and what route is returned?

    1. Expand BLR ($g = 0$). Frontier: MAA 5, HYD 9.

      The frontier is a priority queue on $g$, the hours driven so far.

    2. Expand MAA (5). Add VGA with $g = 5 + 7 = 12$. Frontier: HYD 9, VGA 12.

      Chennai is cheaper to reach than Hyderabad, so it goes first even though it was added at the same time.

    3. Expand HYD (9). Via HYD, VGA would cost 13, worse than 12, so VGA keeps 12. Add NAG 17 and RPR 21.

      When a state already in the frontier is reached again, keep the cheaper of the two paths.

    4. Expand VGA (12): add VTZ 17. Expand NAG (17, tied with VTZ, NAG first alphabetically): RPR via NAG would cost 22, no change.

      Ties are broken alphabetically.

    5. Expand VTZ (17): add BBI with $g = 23$. Then expand RPR (21): BBI via RPR would cost 29, no change.

      BBI is now in the frontier, but we do not stop: RPR at 21 is cheaper and might have led to a cheaper route to BBI.

    6. Expand BBI (23): the goal test passes. Order: BLR, MAA, HYD, VGA, NAG, VTZ, RPR, BBI. Route BLR–MAA–VGA–VTZ–BBI, 23 hours.

      Uniform-cost search expands states in order of increasing $g$, so the first time it expands the goal, no cheaper route exists.

    Depth-limited search and iterative deepening

    DFS uses very little memory: it only holds the current path and the unexplored siblings along it. But on a huge or infinite state space it can dive forever down one branch. Two fixes:

    • Depth-limited search (DLS): DFS that treats every state at depth $\ell$ (the depth limit) as if it had no children. It cannot go forever, but if the shallowest goal is deeper than $\ell$ it fails.
    • Iterative deepening DFS (IDDFS): run DLS with $\ell = 0, 1, 2, \ldots$ until a goal is found. It finds the shallowest goal like BFS but needs only DFS’s memory.

    Doesn’t IDDFS waste time redoing the top of the tree? Very little: almost all the nodes of a tree are in its bottom level, which IDDFS generates only once.

    Try it

    Each dot is a node of a search tree; the number in it is how many times iterative deepening generates it (the root is not counted in the totals). Raise the branching factor $b$ and watch the extra work over BFS shrink: with $b = 10$ and $d = 5$ it is about 11%, while the memory drops from 100,000 nodes to about 50.

    Notation: $b$ = branching factor (maximum number of children of a state), $d$ = depth of the shallowest goal, $m$ = maximum depth of the state space, $C^*$ = cost of an optimal solution, $\epsilon$ = smallest step cost (positive), $\ell$ = depth limit. Complete means it always finds a solution when one exists; optimal means the solution it finds is a cheapest one.

    Complete?Optimal?TimeMemory
    BFSyes (finite $b$)only if all step costs are equal$O(b^d)$$O(b^d)$
    Uniform-costyes (step costs $\ge \epsilon \gt 0$)yes$O(b^{1+\lfloor C^*/\epsilon\rfloor})$same as time
    DFSno (yes as graph search on a finite space)no$O(b^m)$$O(bm)$
    Depth-limitedno (fails if $\ell \lt d$)no$O(b^\ell)$$O(b\ell)$
    Iterative deepeningyes (finite $b$)only if all step costs are equal$O(b^d)$$O(bd)$

    An algorithm is uninformed if it never uses an estimate of the distance to the goal: BFS, DFS, uniform-cost, depth-limited, iterative deepening, bidirectional. It is informed if it uses a heuristic $h(n)$: greedy best-first, A*, IDA*. Uniform-cost search uses costs, but costs already paid, so it is still uninformed.

    Every state in a search tree has exactly 3 children, and the only goal is the last state generated at depth 3. Not counting the root, how many states does BFS generate before it finds the goal?

    BFS generates every state at depths 1, 2 and 3: $b + b^2 + b^3$.

    $3 + 9 + 27 = 39$. This is the $O(b^d)$ in the table: the last level dominates.

    A search algorithm stores its frontier in a stack and always expands the most recently added state. Which algorithm is it?

    1. Breadth-first search
    2. Depth-first search
    3. Uniform-cost search
    4. A* search

    Last in, first out means the newest, deepest state goes next.

    (B). BFS uses a queue (first in, first out); uniform-cost and A* use priority queues keyed by $g$ and $g + h$.

    Iterative deepening runs on a tree where every state has 2 children and the only goal is the last state at depth 3. Not counting the root, how many states are generated in total over all iterations ($\ell = 0, 1, 2, 3$)?

    A state at depth $k$ is generated once in each iteration with $\ell \ge k$, so $d - k + 1$ times.

    Depth 1: 2 states × 3 iterations = 6. Depth 2: 4 × 2 = 8. Depth 3: 8 × 1 = 8. Total $6 + 8 + 8 = 22$, against 14 for BFS.

    GATE DA 2026 · Q13 · MCQ · 1 mark

    Which of the following algorithms is NOT an example of uninformed search?

    1. Breadth First Search
    2. Depth First Search
    3. A* Search
    4. Depth-limited Search

    Which one uses an estimate $h(n)$ of the remaining cost?

    A* orders its frontier by $g(n) + h(n)$, where $h$ is a heuristic estimate of the cost still to go, so it is informed. The other three use only the structure of the graph. Answer (C). Official key: C.

    Two-way roads, each taking 1 hour: S–A, S–B, A–C, C–D, D–G, B–G. Start S, goal G. Both searches are graph searches, test for the goal on expansion and consider neighbours in alphabetical order (DFS pushes them in reverse alphabetical order, so the alphabetically first is popped first). Which statement is correct?

    1. Both expand 5 states; BFS returns S–B–G and DFS returns S–A–C–D–G.
    2. Both return S–B–G, because it is the shortest route.
    3. BFS expands only S, A, B and then G; DFS returns S–A–C–D–G.
    4. DFS returns S–B–G and expands 3 states.

    Write the queue (for BFS) and the stack (for DFS) after each expansion. For BFS, notice that C joins the queue before G does.

    BFS. Queue [S]. Expand S → [A, B]. Expand A → add C: [B, C]. Expand B → add G: [C, G]. Expand C → add D: [G, D]. Expand G: goal. Expanded S, A, B, C, G (5 states); route S–B–G.

    DFS. Stack top first: [S]. Expand S → [A, B]. Expand A → [C, B]. Expand C → [D, B]. Expand D → [G, B]. Expand G: goal. Expanded S, A, C, D, G (5 states); route S–A–C–D–G, twice as long.

    Answer (A). (C) is what BFS does if it tests for the goal when a state is generated: it stops while expanding B. That variant is legitimate too, which is why exam questions state the convention. (B) and (D) assume DFS finds short routes; it does not.

    Two-way roads with costs: S–A 1, S–B 5, S–D 4, A–B 2, A–C 6, B–C 2, B–G 9, C–G 3, D–G 6. Start S, goal G; goal test on expansion; ties alphabetical. Find (i) the cost of the route uniform-cost search returns, (ii) how many states it expands (count S and G), and (iii) the cost of the route BFS returns.

    For uniform-cost search, keep updating a state’s $g$ when a cheaper path to it appears. B starts at 5 but drops when A is expanded.

    Uniform-cost. Expand S (0): A 1, B 5, D 4. Expand A (1): B improves to 3, C 7. Expand B (3): C improves to 5, G 12. Expand D (4): G improves to 10. Expand C (5): G improves to 8. Expand G (8). Expanded S, A, B, D, C, G: 6 states; route S–A–B–C–G costing 8.

    BFS. Expand S: queue [A, B, D]. Expand A: add C. Expand B: add G (its parent is B). Expand D, then C, then G. Route S–B–G costing $5 + 9 =$ 14. BFS minimises the number of roads, not the hours.

    Tempting wrong answers: stopping uniform-cost search when G is first generated gives 12; counting only the states on the final route gives 5.

    Which statements are true? ($b$ finite, all step costs positive.)

    1. Iterative deepening is complete and needs only $O(bd)$ memory.
    2. DFS as a graph search on a finite state space always finds a solution if one exists.
    3. BFS always returns an optimal solution when all step costs are positive.
    4. Depth-limited search with limit $\ell \ge d$ always returns a shallowest solution.

    For (C), think of the bus map. For (D), DLS is still depth-first inside its limit.

    (A) True: it finds the shallowest goal and only stores one path plus siblings.

    (B) True: the explored set stops it revisiting states, and there are finitely many, so it eventually tries them all.

    (C) False: BFS minimises the number of steps. On the bus map it returns a 29-hour route although a 23-hour route exists. It is optimal only when every step costs the same.

    (D) False: inside the limit it still dives depth-first, so it can return a goal at depth $\ell$ before trying a shallower one in a later branch. Answer A; B.

    • Write the frontier out after every expansion; most marks are lost by skipping one line.
    • State the convention you use: goal test on expansion, ties alphabetical, graph or tree search.
    • Ask “which state comes out next?”: that single rule identifies the algorithm.
    • Calling BFS optimal without the “equal step costs” condition.
    • Stopping uniform-cost search as soon as the goal enters the frontier.
    • Calling uniform-cost search informed because it uses costs. Costs already paid are not a heuristic.
    1. A search problem is states, an initial state, actions, a goal test and path costs; the state space is the graph they form.
    2. Every algorithm repeats one loop: take a state from the frontier, test it, add its children. BFS uses a queue, DFS a stack, uniform-cost a priority queue on g(n).
    3. BFS and iterative deepening find the shallowest goal; only uniform-cost finds the cheapest when costs differ. IDDFS gets BFS’s answer with DFS’s O(bd) memory.

    The team bus wants the route with the fewest roads, whatever the hours. Which strategy explores every city one road away before any city two roads away?

    Breadth-first search
    It expands states in order of depth, so the first time it reaches the goal, it has used the fewest roads.
    Depth-first search
    That follows one road as far as it goes before backing up. Which strategy finishes a whole level first?
    Uniform-cost search
    That orders by hours, not by number of roads. Here every road should count the same.
    Depth-limited search with limit 1
    With limit 1 it never looks two roads away at all.

    Uniform-cost search keeps its frontier as

    a stack
    A stack gives the newest state first. Uniform-cost search wants the cheapest.
    a first-in-first-out queue
    That is BFS. Think about what “uniform cost” orders by.
    a priority queue ordered by the path cost g(n)
    It always expands the cheapest-so-far state, like Dijkstra’s algorithm.
    a priority queue ordered by g(n) + h(n)
    That is A*, which needs a heuristic.

    Why is iterative deepening preferred to BFS for very large trees with unit step costs?

    It expands fewer nodes than BFS
    It expands slightly more, because it repeats the upper levels.
    It finds cheaper solutions than BFS
    With unit costs both find the shallowest, cheapest goal.
    It works without a goal test
    Every search needs a goal test.
    It finds the same shallowest goal using O(bd) memory instead of O(b^d)
    Memory, not time, is what runs out first in BFS.

    Informed search: heuristics, greedy best-first and A*

    Informed search uses a heuristic, a cheap estimate of the cost still to go, to expand the most promising states first; A* combines it with the cost already paid and still guarantees the cheapest route.

    A* is the most examined search topic in GATE DA: tracing its expansion order (2025 Q44, sample Q27) and knowing which heuristics are admissible (2024 Q23, sample Q46). Expect at least one question, often two marks.

    It’s like driving with a sign that says “Bhubaneswar 600 km” at each junction: you still count the kilometres you have driven, but the signs stop you wandering south.

    Where it shows up in GATE DA

    Trace A* on a figure, find the largest admissible value of h, or decide which combination of heuristics stays admissible.

    2025 Q44 · A* expansion order2024 Q23 · combining admissible heuristicsSample Q27 · goal reached, largest admissible hSample Q46 · relaxed obstacles
    Heat: every year, 1–2 marks

    Uniform-cost search found the bus’s best route, but it expanded every city cheaper than 23 hours, including Nagpur and Raipur, which are in the wrong direction for a good route. It had no idea where Bhubaneswar was.

    Suppose the planner also knows, for each city, a rough estimate of the hours still needed, say from the straight-line distance. Bengaluru is about 15 hours away, Visakhapatnam about 5. That estimate is a heuristic.

    A heuristic function $h(n)$ estimates the cost of the cheapest path from state $n$ to a goal. It must be cheap to compute and $h(\text{goal}) = 0$. Write $h^*(n)$ for the true cheapest cost from $n$ to a goal. Example: on the bus map $h(\text{VTZ}) = 5$ while $h^*(\text{VTZ}) = 6$.

    Both use the generic graph search with a priority queue; only the priority differs.

    Greedy best-first search: expand the state with the smallest $h(n)$. It heads straight for whatever looks closest.

    A* search: expand the state with the smallest $$f(n) = g(n) + h(n),$$ where $g(n)$ is the cost already paid to reach $n$. So $f(n)$ estimates the cost of the cheapest complete route through $n$. With $h = 0$ everywhere, A* is uniform-cost search.

    $h$ is admissible if it never overestimates: $h(n) \le h^*(n)$ for every state $n$. Straight-line distance is admissible for road travel: no road is shorter than the straight line.

    $h$ is consistent (or monotone) if for every edge $n \to n'$ with cost $c(n, n')$: $$h(n) \le c(n, n') + h(n').$$ This is a triangle inequality: your estimate cannot drop by more than the step you just paid for. Every consistent heuristic (with $h(\text{goal}) = 0$) is admissible; the converse is false.

    A* tree search returns an optimal solution if $h$ is admissible. A* graph search (with an explored set, never reopening closed states) returns an optimal solution if $h$ is consistent. With a consistent $h$, the $f$-values of expanded states never decrease.

    Why admissibility is enough for tree search, in two lines. Let $C^*$ be the optimal cost. Some state $n$ on the optimal route is always waiting in the frontier with $f(n) = g(n) + h(n) \le g(n) + h^*(n) = C^*$. A worse goal $G_2$ has $f(G_2) = g(G_2) \gt C^*$, so $n$ always comes out first, and A* cannot return $G_2$ before finishing the optimal route.

    For graph search, admissibility is not enough: A* may close a state via an expensive path and then never reopen it. The Try it below shows exactly this.

    Try it

    Run A* with the default heuristic: it expands only 6 cities (uniform-cost search needed 8) and finds the 23-hour route. Then run Greedy: it trusts $h$ alone and returns the 29-hour route through Raipur. Finally, drag h(Chennai) to 18. That is still admissible (the true cost from Chennai is 18) but no longer consistent, and A* graph search now returns 24 hours: it closes Vijayawada via Hyderabad before it explores Chennai.

    Careful: In that last run, Vijayawada is expanded with $g = 13$ (via Hyderabad). Chennai, with $f = 5 + 18 = 23$, comes out later and offers Vijayawada at $g = 12$, but Vijayawada is already closed. The heuristic jumped from 18 at Chennai to 9 at Vijayawada across a 7-hour road ($18 \gt 7 + 9$): that is the inconsistency.
    GATE DA 2025 · Q44 · MCQ · 2 marks

    The state graph shows the action cost along the edges and the heuristic function h associated with each state.

    Suppose $A^*$ algorithm is applied on this state graph using priority queue to store the frontier. In what sequence are the nodes expanded?

    1. S,A,E,C,B,D,G
    2. S,E,A,C,B,D,G
    3. S,A,E,B,C,D,G
    4. S,A,B,E,C,D,G
    1. Expand S. Children: A with $g = 4$, $f = 4 + 2 = 6$; E with $g = 1$, $f = 1 + 6 = 7$.

      A* orders by $f = g + h$, not by $g$ (which would pick E) or $h$ alone.

    2. Expand A ($f = 6$). Add B: $g = 6$, $f = 6 + 2 = 8$. Frontier: E 7, B 8.

      This rules out (B) and (D): after S comes A, and after A comes E (7 is less than 8).

    3. Expand E ($f = 7$). Add C: $g = 1 + 2 = 3$, $f = 3 + 6 = 9$. Frontier: B 8, C 9.

      C is reached cheaply through E, but its large heuristic value pushes $f$ to 9.

    4. Expand B ($f = 8$). Via B, C would have $g = 8$, worse than 3, so nothing changes. Expand C ($f = 9$). Add D: $g = 6$, $f = 8$.

      This settles it: B (8) before C (9). Option (A) puts C before B.

    5. Expand D ($f = 8$). Add G: $g = 9$, $f = 9$. Expand G: goal. Sequence S, A, E, B, C, D, G, answer (C), route S–E–C–D–G of cost 9.

      D’s $f$ (8) is lower than C’s (9) although D comes later: $h(\text{C}) = 6 \gt c(\text{C}, \text{D}) + h(\text{D}) = 5$, so this $h$ is not consistent. It is still admissible, and the answer is optimal here. Official key: C.

    If $h_1$ and $h_2$ are admissible, then $\max(h_1, h_2)$, $\min(h_1, h_2)$, any weighted average $\lambda h_1 + (1 - \lambda)h_2$ and $|h_1 - h_2|$ are all admissible: each is at most $\max(h_1, h_2) \le h^*$. The sum $h_1 + h_2$ and the product $h_1 h_2$ can overestimate. Of two admissible heuristics, the larger one (it dominates) is better: A* expands no more states with it.

    A standard way to build admissible heuristics: solve a relaxed problem, one with fewer restrictions. Its optimal cost can only be lower than the real one.

    On the DPL map (BLR–MAA 5, BLR–HYD 9; $h(\text{MAA}) = 13$, $h(\text{HYD}) = 11$), A* expands Bengaluru first. What are the $f$-values of Chennai and Hyderabad in the frontier after that?

    $f = g + h$, with $g$ the hours from Bengaluru.

    $f(\text{MAA}) = 5 + 13 = 18$ and $f(\text{HYD}) = 9 + 11 = 20$. So A* expands Chennai next, while greedy best-first (which compares only 13 and 11) would choose Hyderabad.

    GATE DA 2024 · Q23 · MCQ · 1 mark

    Let $h_1$ and $h_2$ be two admissible heuristics used in $A^*$ search. Which ONE of the following expressions is always an admissible heuristic?

    1. $h_1 + h_2$
    2. $h_1 \times h_2$
    3. $h_1/h_2,\ (h_2 \neq 0)$
    4. $|h_1 - h_2|$

    Heuristics are non-negative. Compare each option with $\max(h_1, h_2)$.

    Since $h_1, h_2 \ge 0$, $|h_1 - h_2| \le \max(h_1, h_2) \le h^*$, so (D) never overestimates.

    The others can: if $h_1 = h_2 = h^* = 3$, then $h_1 + h_2 = 6$ and $h_1 h_2 = 9$; if $h_1 = 4$, $h_2 = 0.5$ and $h^* = 4$, then $h_1/h_2 = 8$. Answer (D). Official key: D.

    GATE DA 2024 sample paper · Q27 · MCQ · 2 marks

    Consider the search space depicted in the figure below.

    S is the initial state. G1 and G2 are two states that satisfy the goal test. The cost of traversing from one state to another is depicted by the numerical value close to the edge connecting the two states. The estimated cost to the goal is reported inside the states. Use alphabetical order of nodes to break ties. Which goal state is reached if you perform A* (graph) search? What is the largest value that the heuristic function can take for node A while still being admissible?

    1. G1 and 16
    2. G1 and 15
    3. G2 and 16
    4. G2 and 15

    Run A* and keep the frontier with $f$-values; several states tie at the end, so the alphabetical rule matters. For the second part, A’s only exit is to B: what is the cheapest cost from B to a goal?

    A* (graph search). Expand S (8): A $f = 3 + 10 = 13$, B $8 + 4 = 12$, F $6 + 5 = 11$. Expand F (11): D $10 + 3 = 13$, H $10 + 6 = 16$. Expand B (12): G1 $18 + 0 = 18$ (D via B costs 12, worse). Expand A (13, ties with D, A first): B via A costs 8, no better. Expand D (13): C $16 + 2 = 18$, E $13 + 4 = 17$. Expand H (16): G2 $18$. Expand E (17): G2 via E also 18, F via E costs 15, worse. Now C, G1 and G2 all have $f = 18$; alphabetically C, then G1. Expand C: G1 via C costs 20, no better. Expand G1: goal, cost 18 (route S–B–G1).

    Largest admissible $h(\text{A})$. From A the only edge is A→B (5). From B the cheapest route to a goal is B→G1 (10); B→D→E→G2 costs 12. So $h^*(\text{A}) = 5 + 10 = 15$, and admissibility allows $h(\text{A}) \le 15$. Answer (B). (Sample paper, no official key; this is our answer.)

    GATE DA 2024 sample paper · Q46 · MSQ · 2 marks

    Consider the grid world shown in the figure below.

    An agent is planning to move from the starting location $(x_s, y_s)$ to the final location $(x_f, y_f)$. The obstacles along the path are triangular in form. Consider the following heuristic functions to conduct A* search.

    − $h_c$ assumes the obstacles are the smallest circles circumscribing the triangles.
    − $h_r$ assumes the obstacles are smallest rectangles circumscribing the triangles.
    − $h_c'$ assumes the obstacles are largest circles inscribed in the triangles.
    − $h_r'$ assumes the obstacles are largest rectangles inscribed the triangles.

    Which of the following statement(s) is(are) true?

    1. $h_c$ is an admissible heuristic
    2. $h_r$ is an admissible heuristic
    3. $h_c'$ is an admissible heuristic
    4. $h_r'$ is an admissible heuristic

    Each heuristic is the shortest path length in an imagined world. Is that world easier (fewer blocked points) or harder than the real one?

    A shape inscribed in a triangle lies inside it, so with inscribed obstacles less of the grid is blocked. Every path that avoids the real triangles also avoids the smaller shapes, so the shortest path in the imagined world is never longer than the real one: $h_c'$ and $h_r'$ never overestimate. They are relaxed problems, hence admissible.

    A circumscribed shape contains the triangle, so more is blocked and the imagined shortest path can be longer than the real one; $h_c$ and $h_r$ can overestimate. Answer C; D. (Sample paper, no official key; this is our answer.)

    One-way roads: S→A cost 2, A→G cost 4, S→B cost 3, B→G cost 4. Heuristic: $h(\text{S}) = 5$, $h(\text{A}) = 4$, $h(\text{B}) = 1$, $h(\text{G}) = 0$. Which statements are true?

    1. $h$ is admissible.
    2. $h$ is consistent.
    3. A* graph search returns a route of cost 6.
    4. Greedy best-first search returns a route of cost 7.

    First compute $h^*$ for every state. For consistency, test $h(n) \le c(n, n') + h(n')$ on all four edges.

    $h^*(\text{A}) = 4$, $h^*(\text{B}) = 4$, $h^*(\text{S}) = \min(2 + 4, 3 + 4) = 6$. Every $h \le h^*$: (A) true.

    Edge S→B: $h(\text{S}) = 5 \gt 3 + h(\text{B}) = 4$. (B) false.

    A*: expand S; A $f = 2 + 4 = 6$, B $f = 3 + 1 = 4$. Expand B: G $g = 7$, $f = 7$. Expand A (6): G improves to $g = 6$. Expand G: cost 6. (C) true: the inconsistency did no harm here, because no closed state needed reopening.

    Greedy: S, then B ($h = 1$ beats 4), then G: route S–B–G of cost 7. (D) true. Answer A; C; D. If you ticked (B), you probably checked only edges into the goal.

    One-way roads: S→A 3, S→B 6, A→B 2, A→G 7, B→G 3. Known values: $h(\text{S}) = 6$, $h(\text{B}) = 2$, $h(\text{G}) = 0$. Find (i) the largest integer value of $h(\text{A})$ that keeps $h$ admissible, and (ii) the largest that keeps $h$ consistent.

    Admissible: compare with $h^*(\text{A})$. Consistent: every edge out of A gives an upper bound on $h(\text{A})$, and the edge into A gives a lower bound.

    (i) $h^*(\text{A}) = \min(7, 2 + 3) = 5$. The other states are fine ($h(\text{B}) = 2 \le 3$, $h(\text{S}) = 6 \le 8$), so the largest admissible value is 5.

    (ii) Edges out of A: $h(\text{A}) \le 2 + h(\text{B}) = 4$ and $h(\text{A}) \le 7 + 0 = 7$. Edge into A: $h(\text{S}) = 6 \le 3 + h(\text{A})$ needs $h(\text{A}) \ge 3$. The other edges hold. So $3 \le h(\text{A}) \le 4$: the largest consistent value is 4.

    The gap between 5 and 4 is the point: consistency is a stronger demand. Answering 7 uses only the direct edge A→G and forgets the cheaper route through B.

    One-way roads: S→A 2, S→B 1, A→G 2, B→G 5. Heuristic: $h(\text{S}) = 0$, $h(\text{A}) = 5$, $h(\text{B}) = 1$, $h(\text{G}) = 0$. A* (goal test on expansion) returns a route of cost

    1. 4, because A* is always optimal when $h(\text{G}) = 0$
    2. 6, because $h(\text{A})$ overestimates the true cost from A
    3. 6, because A* stops as soon as the goal is generated
    4. 7

    Compute $f$ for A and B after expanding S, then follow the smaller one.

    Expand S: A $f = 2 + 5 = 7$, B $f = 1 + 1 = 2$. Expand B: G $g = 6$, $f = 6$. Now G (6) beats A (7), so A* expands G and returns cost 6, although S–A–G costs 4.

    The reason is $h(\text{A}) = 5 \gt h^*(\text{A}) = 2$: the heuristic is not admissible, so it hid the good route. Answer (B). (C) gives the right number for the wrong reason: the goal test here is on expansion. (A) is false: $h(\text{G}) = 0$ is required but not sufficient. (D) adds the heuristic into the route cost.

    • Write each frontier entry as “state: g + h = f”; it makes ties and updates visible.
    • To test admissibility, compute $h^*$ for every state by working backwards from the goal.
    • To test consistency, check $h(n) \le c(n, n') + h(n')$ on every edge, in the edge’s direction.
    • Ordering A* by $g$ or by $h$ alone (those are uniform-cost and greedy).
    • Believing an admissible heuristic guarantees optimal A* graph search; that needs consistency.
    • Adding two admissible heuristics and expecting the sum to stay admissible.
    1. A* expands the state with the smallest f(n) = g(n) + h(n); greedy best-first uses h(n) alone and is not optimal.
    2. Admissible: h(n) ≤ h*(n). Consistent: h(n) ≤ c(n, n′) + h(n′) on every edge. Consistent implies admissible.
    3. Admissible is enough for optimal A* tree search; graph search needs consistency. max, min and |h₁ − h₂| of admissible heuristics stay admissible; the sum does not.

    If the heuristic is $h(n) = 0$ for every state, A* behaves exactly like

    greedy best-first search
    Greedy would see every state as equally close. What is left of f = g + h?
    depth-first search
    The frontier is still a priority queue, not a stack.
    uniform-cost search
    With h = 0, f(n) = g(n): the cheapest-so-far state goes first.
    breadth-first search
    Only if every step costs the same.

    Which statement is always true?

    Every admissible heuristic is consistent
    Find one in this chapter: the 2025 Q44 heuristic is admissible but not consistent.
    Every consistent heuristic with h(goal) = 0 is admissible
    Chain the inequality along the optimal route from n to the goal: h(n) ≤ h*(n).
    A heuristic that overestimates speeds up A* without changing its answer
    It can change the answer: practice h3 returns 6 instead of 4.
    Greedy best-first search is optimal when h is admissible
    On the bus map, greedy returns 29 hours with an admissible h.

    $h_1$ and $h_2$ are admissible and $h_2(n) \ge h_1(n)$ for every $n$. Which should A* use?

    $h_2$: it dominates $h_1$, so A* expands no more states
    A larger admissible estimate is closer to the truth and prunes more.
    $h_1$: smaller estimates are safer
    Both are already safe (admissible). Which one is more informative?
    $h_1 + h_2$, to combine both
    The sum can overestimate.
    It makes no difference
    Both give the optimal answer, but not with the same amount of work.

    Adversarial search: minimax and alpha–beta pruning

    Adversarial search plans moves when an opponent moves too: minimax assumes the opponent always picks the reply that is worst for you, and alpha–beta pruning gets the same answer while skipping branches that cannot matter.

    A game-tree question has appeared in every GATE DA paper: the meaning of α and β (2024 Q25), the value at the root (2026 Q30), and which branches are pruned (2025 Q43, sample Q31).

    It’s like planning a chess move by asking “what’s their best reply?” for each option, and abandoning an option the moment you find one reply that makes it worse than something you already have.

    Where it shows up in GATE DA

    Compute a minimax value, say which subtrees alpha–beta prunes, or find the range of a leaf for which pruning happens.

    2024 Q25 · what α and β mean2025 Q43 · ranges for pruning2026 Q30 · best strategy at the rootSample Q31 · which subtrees are pruned
    Heat: every year, 1–2 marks

    The problem: two captains

    Before the final, the Kalinga Kernels’ captain picks one of three batting plans. The Hyderabad Hyperplanes’ captain sees the plan and picks one of three bowling plans in reply. A model predicts the Kernels’ winning margin (in runs) for each of the nine combinations. The Kernels want the margin high; the Hyperplanes want it low.

    A route planner chooses every step itself. Here half the choices belong to someone working against you. That changes the question from “which path is best?” to "which move is best, assuming the reply is as bad for me as possible?"

    A two-player, turn-taking, zero-sum game (one player’s gain is the other’s loss) with perfect information is drawn as a game tree:

    • The root is the current position; levels alternate between the player MAX (wants a high score) and the opponent MIN (wants it low). One level of moves is a ply.
    • Leaves (terminal states) carry a utility: the final score from MAX’s point of view. Kernels’ winning margin: MAX = Kernels, MIN = Hyperplanes.

    The minimax value of a node is: its utility, if it is a leaf; the largest value among its children, if MAX moves there; the smallest, if MIN moves there. Compute it bottom-up (by a depth-first walk). At the root, MAX plays the move leading to the child with the largest value.

    Minimax visits every node: time $O(b^m)$ for branching factor $b$ and depth $m$, memory $O(bm)$.

    Alpha–beta pruning: skip what cannot matter

    In the “DPL match” tree of the Try it below, the Kernels’ first plan B leads to margins 3, 12, 8; the Hyperplanes would choose 3, so plan B is worth 3. Now the Kernels look at plan C. The first reply gives margin 2. Stop right there: whatever the other two replies give, the Hyperplanes can hold plan C to at most 2, and the Kernels already have 3. The remaining leaves under C can be skipped without being looked at.

    Alpha–beta pruning formalises this with two numbers carried down the tree.

    At any point of the depth-first walk:

    • $\alpha$ = the highest value MAX is already guaranteed at some choice point on the path from the root (MAX’s best option so far). It starts at $-\infty$ and only rises at MAX nodes.
    • $\beta$ = the lowest value MIN is already guaranteed on the path (MIN’s best option so far). It starts at $+\infty$ and only falls at MIN nodes.

    Values between $\alpha$ and $\beta$ are the only ones that can still change the decision. As soon as $\alpha \ge \beta$ at a node, its remaining children are pruned: one of the players above will never let play reach this node.

    Walk the tree left to right, depth first, passing $(\alpha, \beta)$ down.
    At a MAX node: after each child returns value $v$, set $\alpha \leftarrow \max(\alpha, v)$. If $\alpha \ge \beta$, prune its remaining children.
    At a MIN node: after each child returns value $v$, set $\beta \leftarrow \min(\beta, v)$. If $\alpha \ge \beta$, prune its remaining children.
    A node passes its value up to its parent; the parent’s $\alpha$ and $\beta$ were never changed by the child.

    Try it

    Press Step to walk the tree; the current node is outlined and its α and β are shown above it. In “DPL match”, two leaves are pruned. Switch to “Best order”: the best moves come first and four of nine leaves are skipped. “Worst order” prunes nothing. Then press “Shuffle leaves” a few times and compare with “Plain minimax”: the root value never changes, only the number of leaves looked at.

    (1) Alpha–beta returns exactly the minimax value at the root; only the values of pruned subtrees are left unknown. (2) How much it prunes depends on the order children are examined. With perfect ordering it looks at about $O(b^{m/2})$ leaves instead of $O(b^m)$, so it can search twice as deep in the same time; with random ordering about $O(b^{3m/4})$; with the worst ordering it prunes nothing.

    GATE DA 2024 sample paper · Q31 · MCQ · 2 marks

    Consider the game tree shown below.

    The value below each node is the output of the utility function. The subtrees rooted at which of these nodes will be pruned because of alpha-beta pruning?

    1. m and j
    2. r and j
    3. h and p
    4. no nodes are pruned
    1. Subtree b (MIN), with $\alpha = -\infty$, $\beta = +\infty$. Its child e (MAX) sees k = 3 and l = 0, so e = 3. Back at b: $\beta = 3$. Then f = 2, so b = min(3, 2) = 2.

      Nothing can be pruned yet: no bound is finite until a first value comes back to a choice point.

    2. Back at a (MAX): $\alpha = 2$. MAX is now guaranteed at least 2.

      $\alpha$ is the best value MAX has found so far along the path.

    3. Subtree c (MIN), $(\alpha, \beta) = (2, +\infty)$. g = 6, so $\beta = 6$. Go into h (MAX) with $(2, 6)$, then into m (MIN) with $(2, 6)$. q = 1: m’s $\beta$ becomes 1, and now $\alpha = 2 \ge \beta = 1$. Prune r.

      m will be worth at most 1, but MAX at the root already has 2, so play never reaches m on purpose; r’s value does not matter.

    4. m returns 1, so h’s $\alpha = \max(2, 1) = 2$. Then n = 6: h = 6, and $\alpha = 6 \ge \beta = 6$, but h has no children left. h returns 6; c = min(6, 6) = 6. At a: $\alpha = 6$.

      h itself is not pruned: both its children were needed to know its value.

    5. Subtree d (MIN), $(6, +\infty)$. i = 1: $\beta = 1 \le \alpha = 6$. Prune j (and with it o and p). Root value 6, MAX plays to c. Answer (B) r and j.

      d is worth at most 1 to MAX, who already has 6. (Sample paper, no official key; this is our answer.) Load “Sample Q31” in the Try it to watch every step.

    To find when a leaf is pruned, write the condition $\alpha \ge \beta$ at the node just before that leaf, with $\alpha$ and $\beta$ as expressions in the unknown. A MIN node’s remaining children are pruned once its running minimum is $\le \alpha$; a MAX node’s once its running maximum is $\ge \beta$. Ties prune ($\ge$, not $\gt$).

    The Kernels (MAX) choose plan 1, 2 or 3; then the Hyperplanes (MIN) choose a reply and the game ends. Margins for plan 1: 4, 7, 9; plan 2: 2, 8, 6; plan 3: 5, 5, 10. What is the minimax value of the root?

    Each MIN node takes the smallest of its three leaves; the root takes the largest of those.

    MIN values: plan 1 → 4, plan 2 → 2, plan 3 → 5. MAX takes the largest: 5, by playing plan 3. Plan 2 has the largest leaf (8), but the Hyperplanes would never allow it.

    GATE DA 2024 · Q25 · MCQ · 1 mark

    Consider the following statement:

    In adversarial search, $\alpha$–$\beta$ pruning can be applied to game trees of any depth where $\alpha$ is the (m) value choice we have formed so far at any choice point along the path for the MAX player and $\beta$ is the (n) value choice we have formed so far at any choice point along the path for the MIN player.

    Which ONE of the following choices of (m) and (n) makes the above statement valid?

    1. (m) = highest, (n) = highest
    2. (m) = lowest, (n) = highest
    3. (m) = highest, (n) = lowest
    4. (m) = lowest, (n) = lowest

    What does each player want: high values or low values?

    MAX’s best choice so far is the highest value it can guarantee; MIN’s best is the lowest. So (m) = highest and (n) = lowest. Answer (C). Official key: C.

    GATE DA 2026 · Q30 · NAT · 1 mark

    Consider the game tree for a two-player turn-taking minimax game as shown in the figure. The value of a terminal node represents the utility of the game state if the game ends there. The numbers written next to the edges denote the strategies.

    There are two players MAX and MIN. At any particular state of the game, MAX prefers to move to a state of maximum value. On the other hand, MIN prefers to move to a state of minimum value.

    Suppose MAX starts the game at the root and has three strategies: 1, 2 and 3. Next, MIN plays and also has three strategies: 1, 2 and 3. The game ends there. Both players always take optimal strategies throughout the game.

    At the root, the best strategy for MAX is ___________ . (Answer in integer)

    Find what MIN would do after each of MAX’s strategies. The answer is a strategy number, not a value.

    MIN values: strategy 1 → min(8, 6, −1) = −1; strategy 2 → min(1, 5, 7) = 1; strategy 3 → min(−4, −3, −12) = −12. MAX picks the largest, 1, which is strategy 2. Official key: 2.

    Strategy 1 holds the largest leaf (8) but MIN would answer with −1. Note the question asks for the strategy (2), not the root value (1).

    GATE DA 2025 · Q43 · MCQ · 2 marks

    Consider game trees Tree-1 and Tree-2 as shown. The first level is a MAX agent and the second level is a MIN agent. The value in the square node is the output of the utility function.

    For what ranges of $x$ and $y$, the right child of node $B$ and the right child of node $E$ will be pruned by alpha-beta pruning algorithm?

    1. $x \in [1, \infty)$ and $y \in (-\infty, 2]$
    2. $x \in (-\infty, 2]$ and $y \in (-\infty, 5]$
    3. $x \in (-\infty, 2]$ and $y \in [2, \infty)$
    4. $x \in [1, \infty)$ and $y \in (-\infty, 5]$

    Find $\alpha$ at the root after its left child, then write "running minimum $\le \alpha$" at B and at E.

    Tree-1. A’s left child is 2, so $\alpha = 2$. At B (MIN), after the leaf $x$, $\beta = x$. The right child is pruned when $\alpha \ge \beta$: $x \le 2$, i.e. $x \in (-\infty, 2]$.

    Tree-2. D = min(5, y), so at C, $\alpha = \min(5, y)$. At E, after the leaf 2, $\beta = 2$. Pruned when $\min(5, y) \ge 2$, i.e. $y \ge 2$: $y \in [2, \infty)$.

    Answer (C). Official key: C. The trap in (A) and (D) is to compare $x$ with the pruned leaf’s value 1; pruning never depends on the leaf being pruned.

    A three-ply game tree: the root R is MAX with MIN children B and C. B has MAX children D (leaves 3, 5) and E (leaves 6, 9). C has MAX children F (leaves 1, 2) and G (leaves 0, −1). Alpha–beta runs left to right. How many of the 8 leaves are evaluated?

    Track $(\alpha, \beta)$ into every node. Once B has a value, R’s $\alpha$ is set; what does that mean for C after F returns?

    D = max(3, 5) = 5, so B’s $\beta = 5$. Enter E with $(-\infty, 5)$: leaf 6 makes E’s $\alpha = 6 \ge 5$, so 9 is pruned. B = min(5, 6) = 5; at R, $\alpha = 5$.

    Enter C with $(5, +\infty)$, then F with $(5, +\infty)$: leaves 1 and 2 give F = 2 (no pruning inside F, as $\alpha$ stays 5 and $\beta$ is infinite). Back at C, $\beta = 2 \le \alpha = 5$, so G is pruned (leaves 0 and −1).

    Evaluated: 3, 5, 6, 1, 2, so 5 leaves; root value 5. A common slip is to prune leaf 2 inside F: F is a MAX node, and its running maximum 1 is not $\ge \beta = +\infty$.

    A MAX root has two MIN children. The left one has leaves 5 and 8. The right one has leaves $x$, 4 and 7, in that order. Alpha–beta runs left to right. Which statement is correct?

    1. The leaf 7 is pruned for every value of $x$.
    2. The leaf 7 is pruned only when $x \le 5$.
    3. The leaf 4 is pruned for every value of $x$.
    4. When $x \gt 5$, nothing is pruned.

    The root’s $\alpha$ is 5 after its left child. Consider $x \le 5$ and $x \gt 5$ separately.

    Left child: min(5, 8) = 5, so $\alpha = 5$ at the root. At the right MIN node, after $x$, $\beta = x$.

    If $x \le 5$: $\alpha \ge \beta$ immediately, so 4 and 7 are both pruned. If $x \gt 5$: no pruning yet; the leaf 4 gives $\beta = 4 \le 5$, so 7 is pruned.

    Either way 7 is pruned: (A). (B) forgets that the second leaf can trigger pruning too; (C) fails for $x \gt 5$; (D) is wrong because 4 arrives before 7.

    Which statements about alpha–beta pruning are true?

    1. It always returns the same value at the root as minimax.
    2. With perfect move ordering it examines about $O(b^{m/2})$ leaves for branching factor $b$ and depth $m$.
    3. The number of nodes it prunes does not depend on the order in which children are examined.
    4. At a MIN node, the remaining children are pruned as soon as the node’s running minimum is less than or equal to $\alpha$.

    Use the Try it: compare “Best order” and “Worst order” on the same nine leaves.

    (A) True: it only skips subtrees that cannot affect the root’s decision. (B) True: perfect ordering halves the effective depth. (C) False: the same nine leaves are pruned 4 times with the best order and never with the worst. (D) True: that is the condition $\alpha \ge \beta$ with $\beta$ the running minimum. Answer A; B; D.

    • Write $(\alpha, \beta)$ next to each node as you enter it, and update it after every child.
    • Remember who updates what: MAX nodes raise $\alpha$, MIN nodes lower $\beta$.
    • When asked “which subtree is pruned”, name the child whose value was never needed, not its parent.
    • Pruning on the value of the leaf you are about to skip; you never look at it.
    • Using $\gt$ instead of $\ge$: ties prune.
    • Reporting the root’s value when the question asks for the move (strategy) that achieves it.
    1. Minimax: leaves give utilities, MAX nodes take the maximum of their children, MIN nodes the minimum; MAX plays the move to the best child.
    2. α is MAX’s best guaranteed value on the path (highest), β is MIN’s (lowest); prune the remaining children as soon as α ≥ β.
    3. Pruning never changes the root value; good move ordering cuts the work from O(b^m) to about O(b^(m/2)).

    MAX can choose move 1, after which MIN can reach outcomes 10 or −20, or move 2, after which MIN can reach 3 or 4. Assuming MIN plays well, MAX should choose

    move 1, because 10 is the best outcome in the tree
    MIN chooses after move 1. Which outcome would MIN pick there?
    move 2, worth 3
    Move 1 is worth min(10, −20) = −20, move 2 is worth min(3, 4) = 3.
    either: they average the same
    Minimax does not average; it assumes the worst reply.
    move 2, worth 4
    Right move, wrong value: MIN would answer with 3.

    Alpha–beta prunes the remaining children of a node when

    α ≤ β
    That holds almost all the time; pruning is the exception.
    a leaf value equals α
    Pruning compares α with β, not a leaf with α alone.
    α ≥ β
    Then one of the players above already has a better option, so this node will not be reached in optimal play.
    the node is a MAX node
    Both MAX and MIN nodes can prune.

    Compared with minimax, alpha–beta pruning

    can return a different move, but faster
    It returns exactly the minimax value.
    always halves the number of leaves examined
    The saving depends on move ordering, and can be zero.
    needs a heuristic like A*
    It uses only the utilities and the bounds α and β.
    gives the same root value, possibly examining far fewer leaves
    With perfect ordering about b^(m/2) instead of b^m.

    All roads take different times. Which uninformed search is guaranteed to find the fastest route?

    Breadth-first search
    It minimises the number of roads, not the time.
    Uniform-cost search
    It expands states in order of the time spent so far, so the first goal expanded is the cheapest.
    Iterative deepening
    Like BFS, it finds the shallowest goal.
    Depth-first search
    DFS is not optimal at all.

    A* expands the frontier state with the smallest

    h(n)
    That is greedy best-first search.
    g(n)
    That is uniform-cost search.
    g(n) + h(n)
    Cost paid so far plus the estimate of the cost to go.
    max(g(n), h(n))
    A* adds the two.

    A heuristic has h(A) = 6, h(B) = 2 and an edge A → B of cost 3. Which is true?

    h must be inadmissible
    Admissibility compares h with the true cost to the goal, which you do not know here.
    h is not consistent
    6 > 3 + 2 breaks h(A) ≤ c(A, B) + h(B).
    h is consistent on this edge
    Check 6 ≤ 3 + 2.
    A* will certainly return a non-optimal route
    An inconsistent but admissible h often still works; it is just no longer guaranteed in graph search.

    At a MIN node, α = 4 and the first child returns 3. What happens?

    Nothing; MIN nodes never prune
    They do, when their β falls to α or below.
    α becomes 3
    MIN nodes change β, not α.
    The node’s value is exactly 3
    It is at most 3; the exact value is never needed.
    β becomes 3 ≤ α, so the remaining children are pruned
    MAX above already has 4, and this node is worth at most 3.

    Minimax computes values with a depth-first walk. Its memory use for branching factor b and depth m is

    O(b^m)
    That is its time. Depth-first walks keep only the current path.
    O(bm)
    Like DFS: one path of length m plus the siblings along it.
    O(b^(m/2))
    That is alpha–beta’s best-case time.
    O(m)
    Close, but the siblings at each level are also stored when generated together.

    An AI agent that only stores facts can look things up; an agent that stores facts and rules can work out new facts nobody told it. Logic is the language that makes this safe: it says exactly when a conclusion is guaranteed by what the agent knows. This part covers propositional logic (true/false statements joined by “and”, “or”, “if … then”) and first-order logic (statements about every or some object). GATE DA has asked one or two logic questions every year, all short and all very learnable.

    You need: nothing from Part 1. Sets, complements and De Morgan’s laws from the maths refreshers help, because logic follows the same rules.

    Propositional logic: a knowledge base that can reason

    Propositional logic builds sentences from simple true-or-false statements with “not”, “and”, “or”, “if … then” and “if and only if”, and a truth table tells you when each sentence is true.

    Every GATE DA paper has had a question here: tautologies (2024 Q29), equivalent formulas (2025 Q15), entailment (2026 Q24) and turning English into a formula (2026 Q38). Each one is settled by a truth table of four or eight rows.

    It’s like a referee’s rulebook: once the rules and the facts of the match are written down, the decision follows mechanically, and anyone who applies the rules gets the same answer.

    Where it shows up in GATE DA

    Short questions (1–2 marks) every year, usually MSQ: which formulas are tautologies, which are equivalent, which English reading is right.

    2024 Q29 · which are tautologies?2025 Q15 · p → q ≡ ¬p ∨ q2026 Q24 · what entailment means2026 Q38 · English to a formula
    Heat: every year, 1–3 marks

    Why an agent needs logic

    The Hyderabad Hyperplanes have a match-day assistant, a small AI program. Its knowledge base (KB for short) is the list of sentences it holds to be true. Some are facts, some are rules:

    • Fact: it is raining.
    • Rule: if it rains, the match is shortened.
    • Rule: if the match is shortened, the Hyperplanes play their extra spinner.

    Nobody told the assistant “play the extra spinner”, yet it can work that out: rain, so shortened; shortened, so the extra spinner. That step from what it knows to something new is inference. Logic tells the agent which inferences are safe: a conclusion is safe when it has to be true whenever everything in the knowledge base is true. Search (Part 1) finds a path to a goal; logic lets an agent decide what is true about its world.

    Statements and connectives

    A proposition is a sentence that is either true (T) or false (F), such as “it is raining”. We name simple propositions with letters, $p$, $q$, $r$, and call them atoms. Larger sentences are built with five connectives:

    SymbolRead asTrue exactly whenDPL example
    $\lnot p$not $p$$p$ is falseit is not raining
    $p \land q$$p$ and $q$both are trueraining and shortened
    $p \lor q$$p$ or $q$at least one is true (both is fine)the Kernels or the Backprops qualify
    $p \Rightarrow q$if $p$ then $q$; $p$ implies $q$every case except $p$ true, $q$ falseif it rains, the match is shortened
    $p \Leftrightarrow q$$p$ if and only if $q$$p$ and $q$ have the same valueshortened exactly when it rains

    Papers also write $\to$ for $\Rightarrow$ and $\leftrightarrow$ for $\Leftrightarrow$; they mean the same. The symbol $\equiv$ is different: it means “logically equivalent” (defined below). When brackets are missing, $\lnot$ binds tightest, then $\land$, then $\lor$, then $\Rightarrow$, then $\Leftrightarrow$. So $\lnot p \lor q$ means $(\lnot p) \lor q$, and $C \land S \Leftrightarrow D$ means $(C \land S) \Leftrightarrow D$.

    A truth table lists every way of giving T or F to the atoms, one row each, and works out the sentence in each row. With $n$ atoms there are $2^n$ rows: 4 rows for $p, q$; 8 for $p, q, r$. A row is also called a model (or a possible world): one complete description of how things could be.

    The connective everyone trips on: "if $p$ then $q$"

    Treat $p \Rightarrow q$ as a promise. The league announces: “If it rains, the match will be shortened.” Four things can happen.

    Rain ($p$)Shortened ($q$)Was the promise kept?$p \Rightarrow q$
    TTYes: it rained and they shortened it.T
    TFNo: it rained and they played the full match. The only broken promise.F
    FTYes: the promise said nothing about dry days (maybe the floodlights failed).T
    FFYes: no rain, nothing promised, nothing broken.T

    The last two rows are the ones that feel odd. "If $p$ then $q$" only makes a claim about the situations where $p$ happens. When $p$ is false, the promise was never tested, and logic counts an untested promise as kept. We say $p \Rightarrow q$ is vacuously true when $p$ is false.

    Two consequences worth remembering. First, $p \Rightarrow q$ has exactly one false row ($p$ true, $q$ false), so it says the same as "not ($p$ and not $q$)", which is $\lnot p \lor q$. Second, $p \Rightarrow q$ does not say that $p$ causes $q$, or that $p$ happens at all; it only rules out "$p$ without $q$".

    Careful: $p \Rightarrow q$ is not the same as its converse $q \Rightarrow p$. “If it rains, the match is shortened” does not mean “if the match is shortened, it rained”. It is the same as its contrapositive $\lnot q \Rightarrow \lnot p$: “if the match was not shortened, it did not rain”.

    A sentence is a tautology (or valid) if it is true in every row of its truth table, e.g. $p \lor \lnot p$. It is a contradiction (or unsatisfiable) if it is false in every row, e.g. $p \land \lnot p$. It is satisfiable if it is true in at least one row.

    Two sentences $F$ and $G$ are logically equivalent, written $F \equiv G$, if they have the same value in every row. Equivalently, $F \Leftrightarrow G$ is a tautology.

    Each one can be checked with a four- or eight-row truth table.

    • Implication: $p \Rightarrow q \;\equiv\; \lnot p \lor q$.
    • Contrapositive: $p \Rightarrow q \;\equiv\; \lnot q \Rightarrow \lnot p$.
    • Negated implication: $\lnot(p \Rightarrow q) \;\equiv\; p \land \lnot q$.
    • Biconditional: $p \Leftrightarrow q \;\equiv\; (p \Rightarrow q) \land (q \Rightarrow p)$.
    • De Morgan: $\lnot(p \land q) \equiv \lnot p \lor \lnot q$ and $\lnot(p \lor q) \equiv \lnot p \land \lnot q$ (the same laws as for sets: complement of an intersection is the union of complements).
    • Distributive: $p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)$ and $p \land (q \lor r) \equiv (p \land q) \lor (p \land r)$.
    • Double negation: $\lnot\lnot p \equiv p$.

    Entailment: what the knowledge base guarantees

    Back to the assistant. Its knowledge base is the “and” of all its sentences. A sentence $\alpha$ (the Greek letter alpha, standing for any sentence) is entailed by the knowledge base, written $KB \models \alpha$, if $\alpha$ is true in every model in which $KB$ is true. In words: whenever everything the agent knows holds, $\alpha$ must hold too. The symbol $\models$ is read “entails”.

    The following say the same thing:

    1. $KB \models \alpha$: every row where $KB$ is true also makes $\alpha$ true.
    2. $KB \Rightarrow \alpha$ is a tautology.
    3. $KB \land \lnot\alpha$ is unsatisfiable (no row makes $KB$ true and $\alpha$ false).

    The third form is the one computers use: to prove $\alpha$, assume it is false and show that this clashes with the knowledge base.

    Two inference rules come up all the time. Modus ponens: from $p$ and $p \Rightarrow q$, conclude $q$ (that’s what the assistant did twice). Modus tollens: from $p \Rightarrow q$ and $\lnot q$, conclude $\lnot p$. A tempting but unsafe pattern is "from $q$ and $p \Rightarrow q$, conclude $p$" (affirming the consequent): the match may have been shortened for another reason.

    Try it

    Type a formula (or tap an example) and the table fills in every row, with grey helper columns for each piece. Start with p ⇒ q and find its single F row. Then try the 2024 Q29 examples: (A) has one bad row, (D) has none. Switch to Equivalent? to compare the contrapositive and the converse with $p \Rightarrow q$, and to Entails? to see that a knowledge base entails a sentence exactly when no row has F true and G false.

    To test whether $X \Rightarrow Y$ is a tautology, don’t write all the rows. An implication is false only when the left side is true and the right side is false, so try to build that row. If $X$ being true forces $Y$ to be true, there is no bad row and it is a tautology. If you find one, that row is your counterexample.

    GATE DA 2024 · Q29 · MSQ · 1 mark

    Let $x$ and $y$ be two propositions. Which of the following statements is a tautology /are tautologies?

    1. $(\lnot x \land y) \Rightarrow (y \Rightarrow x)$
    2. $(x \land \lnot y) \Rightarrow (\lnot x \Rightarrow y)$
    3. $(\lnot x \land y) \Rightarrow (\lnot x \Rightarrow y)$
    4. $(x \land \lnot y) \Rightarrow (y \Rightarrow x)$
    1. Each option is "left side $\Rightarrow$ right side", so look only at rows where the left side is true. In (A) and (C) the left side $\lnot x \land y$ is true in exactly one row: $x = F$, $y = T$. In (B) and (D) the left side $x \land \lnot y$ is true only when $x = T$, $y = F$.

      An “and” of two literals pins down a single row. Every other row makes the implication vacuously true.

    2. (A): with $x = F$, $y = T$, the right side $y \Rightarrow x$ is $T \Rightarrow F = F$. So (A) is false in that row: not a tautology.

      We found the bad row: left side true, right side false.

    3. (C): with $x = F$, $y = T$, the right side $\lnot x \Rightarrow y$ is $T \Rightarrow T = T$. No bad row, so (C) is a tautology.

      The only row that could break it doesn’t.

    4. (B) and (D): with $x = T$, $y = F$, the right sides are $\lnot x \Rightarrow y = F \Rightarrow F = T$ and $y \Rightarrow x = F \Rightarrow T = T$. Both are tautologies.

      In each, the right side is an implication whose “if” part is false, so it is vacuously true. Answer: (B), (C), (D). Official key: B; C; D.

    CNF and resolution: how a program proves things

    Truth tables double with every new atom (30 atoms means over a billion rows), so real reasoners use rules instead. The most common is resolution, and it works on sentences in a standard shape.

    A literal is an atom or its negation ($p$ or $\lnot p$). A clause is an “or” of literals, like $\lnot p \lor q \lor r$. A sentence is in conjunctive normal form (CNF) if it is an “and” of clauses, like $(\lnot p \lor q) \land (p \lor r)$.

    1. Replace $p \Leftrightarrow q$ by $(p \Rightarrow q) \land (q \Rightarrow p)$.
    2. Replace $p \Rightarrow q$ by $\lnot p \lor q$.
    3. Push every $\lnot$ inwards with De Morgan’s laws and $\lnot\lnot p \equiv p$, until $\lnot$ sits only on atoms.
    4. Distribute $\lor$ over $\land$: $p \lor (q \land r)$ becomes $(p \lor q) \land (p \lor r)$.

    Resolution rule: from two clauses that contain a complementary pair, such as $(a \lor b)$ and $(\lnot b \lor c)$, infer the clause with that pair removed: $(a \lor c)$. If $b$ is true, $c$ must hold; if $b$ is false, $a$ must hold; either way $a \lor c$.

    To show $KB \models \alpha$: put $KB \land \lnot\alpha$ in CNF, then keep resolving pairs of clauses. If you reach the empty clause (written $\square$, from resolving $b$ with $\lnot b$), $KB \land \lnot\alpha$ is unsatisfiable, so $KB \models \alpha$.

    The assistant’s reasoning as resolution: let $a$ = rain, $b$ = shortened, $c$ = extra spinner. The KB in CNF is $(\lnot a \lor b)$, $(\lnot b \lor c)$, $(a)$. To prove $c$, add $\lnot c$. Resolve $(\lnot b \lor c)$ with $(\lnot c)$: $(\lnot b)$. Resolve that with $(\lnot a \lor b)$: $(\lnot a)$. Resolve that with $(a)$: the empty clause. So $KB \models c$.

    The Kalinga Kernels’ coach says: “If we win the toss, we bowl first.” Which sentence says exactly that the coach’s rule was broken, that is, $\lnot(p \Rightarrow q)$ where $p$ = win the toss and $q$ = bowl first?

    1. $\lnot p \Rightarrow \lnot q$
    2. $p \land \lnot q$
    3. $\lnot p \land q$
    4. $\lnot p \lor \lnot q$

    An implication has only one false row. Which situation is it?

    $p \Rightarrow q \equiv \lnot p \lor q$, so by De Morgan $\lnot(p \Rightarrow q) \equiv p \land \lnot q$: they won the toss and did not bowl first. Answer (B).

    (A) is the “inverse”, a different rule. (C) describes losing the toss and bowling anyway, which keeps the rule. (D) is $\lnot(p \land q)$, De Morgan applied to the wrong formula.

    GATE DA 2025 · Q15 · MCQ · 1 mark

    Let $p$ and $q$ be any two propositions. Consider the following propositional statements.

    $S_1 : p \to q, \quad S_2 : \lnot p \land q, \quad S_3 : \lnot p \lor q, \quad S_4 : \lnot p \lor \lnot q,$

    where $\land$ denotes conjunction (AND operation), $\lor$ denotes disjunction (OR operation), and $\lnot$ denotes negation (NOT operation). Which one of the following options is correct? (Note: $\equiv$ denotes logical equivalence)

    1. $S_1 \equiv S_3$
    2. $S_2 \equiv S_3$
    3. $S_2 \equiv S_4$
    4. $S_1 \equiv S_4$

    When is $p \to q$ false? Write a sentence with “or” that is false in exactly the same row.

    $S_1$ is false only when $p = T$, $q = F$. $S_3 = \lnot p \lor q$ is false only when $\lnot p$ and $q$ are both false, which is the same row. So $S_1 \equiv S_3$: answer (A).

    (B) fails at $p = q = F$ ($S_2$ false, $S_3$ true). (C) fails at $p = q = F$ ($S_2$ false, $S_4$ true). (D) fails at $p = q = T$ ($S_1$ true, $S_4$ false). Official key: A.

    GATE DA 2026 · Q24 · MSQ · 1 mark

    Sentence $X$ is said to entail Sentence $Y$ if whenever $X$ is $TRUE$, $Y$ also must hold $TRUE$.

    Which of the following statements is/are correct if $X$ entails $Y$?

    1. $X \Rightarrow Y$
    2. $X \land \lnot Y$ is $FALSE$
    3. if $X$ then $Y$
    4. if $Y$ then $X$

    Use the theorem "three ways to test $KB \models \alpha$" with $X$ in place of $KB$. For (D), look for a small example such as $X = p \land q$, $Y = p$.

    If $X \models Y$, no row has $X$ true and $Y$ false. That is exactly "$X \Rightarrow Y$ is true in every row“ (A, and C says the same in words) and ”$X \land \lnot Y$ is false in every row" (B).

    (D) is the converse and need not hold: $X = p \land q$ entails $Y = p$, but $p$ does not entail $p \land q$ (take $p = T$, $q = F$). Answer (A), (B), (C). Official key: A; B; C.

    GATE DA 2026 · Q38 · MCQ · 2 marks

    Assume that a Creative ($C$) person will Succeed ($S$) if the person is also Disciplined ($D$), but will not succeed otherwise. Now, consider the following statements:

    (i) $\;C \land S \Leftrightarrow D$
    (ii) $\;C \Rightarrow (S \Leftrightarrow D)$
    (iii) $\;C \Leftrightarrow ((D \Rightarrow S) \lor \lnot S)$

    Which of the following options is correct?

    1. Both (i) and (ii) are TRUE
    2. Only (ii) is TRUE
    3. Both (ii) and (iii) are TRUE
    4. Only (iii) is TRUE

    The sentence only talks about creative people: “for a creative person, succeeding happens exactly when they are disciplined”. What should the formula say about someone who is not creative? For (iii), simplify $(D \Rightarrow S) \lor \lnot S$ first.

    “TRUE” here means “a correct representation of the assumption”. The assumption is: if $C$, then ($S$ exactly when $D$). That is (ii), $C \Rightarrow (S \Leftrightarrow D)$, which says nothing about people who are not creative.

    (i) reads $(C \land S) \Leftrightarrow D$. Take a disciplined person who is not creative: $C = F$, $D = T$. The assumption allows this, but (i) gives $F \Leftrightarrow T = F$. So (i) wrongly forces every disciplined person to be a creative success.

    (iii): $(D \Rightarrow S) \lor \lnot S = \lnot D \lor S \lor \lnot S$, which is always true because $S \lor \lnot S$ is. So (iii) collapses to $C \Leftrightarrow T$, which is just $C$: “everyone is creative”. Not the assumption.

    Only (ii) is right: answer (B). Official key: B.

    The Bengaluru Backprops’ selection assistant has four atoms: $p$ = “the pitch is dry”, $q$ = “a spinner is picked”, $r$ = “a part-time spinner bats at 6”, $s$ = “the captain bowls first over”. Its knowledge base is $$KB = (p \Rightarrow q) \land (q \Rightarrow r) \land (r \Rightarrow s).$$ In how many of the 16 rows of the truth table is $KB$ true?

    Each rule forbids “T followed by F” in the order $p, q, r, s$. Once one atom is T, what must every later atom be?

    $KB$ is true when none of the three implications has a bad row: never $p = T, q = F$; never $q = T, r = F$; never $r = T, s = F$. So once an atom in the list $p, q, r, s$ is T, every atom after it is T too.

    The rows allowed are F F F F, F F F T, F F T T, F T T T, T T T T: the first T can be at position 1, 2, 3, 4, or nowhere. That is 5 models.

    Tempting wrong answers: 8, from treating each rule as halving the rows (the rules overlap, so they don’t cut independently), and 1, from thinking the rules force everything to be T (they don’t: $p$ false leaves the chain free, vacuously).

    The Nagpur Neural Nets’ assistant knows: either the opener ($p$) or the captain ($q$) will bat at number 1; if the opener bats at 1, the score crosses 50 in the powerplay ($r$); if the captain bats at 1, the score also crosses 50 ($r$). So $KB = (p \lor q) \land (p \Rightarrow r) \land (q \Rightarrow r)$. Which sentences are entailed by $KB$? (Select all that apply.)

    1. $r$
    2. $p \land q$
    3. $\lnot r \Rightarrow \lnot p$
    4. $p \Rightarrow q$

    List the rows (of $p, q, r$) where $KB$ is true. Then check each option on those rows only.

    $p \lor q$ needs at least one of $p, q$ true; either one then forces $r = T$. The models of $KB$ are $(p, q, r) = (F, T, T), (T, F, T), (T, T, T)$.

    (A) $r$ is T in all three: entailed. This is “reasoning by cases”, which resolution performs: $(p \lor q)$ and $(\lnot p \lor r)$ give $(q \lor r)$; with $(\lnot q \lor r)$ that gives $r$.

    (C) $\lnot r \Rightarrow \lnot p$ is the contrapositive of $p \Rightarrow r$, which is in $KB$: entailed (and in every model $r = T$, so it is vacuously true there anyway).

    (B) fails in model $(F, T, T)$. (D) $p \Rightarrow q$ fails in model $(T, F, T)$. The tempting error is to think "both routes lead to $r$" means both happen; $KB$ only says at least one does. Answer (A), (C).

    Which of these is a CNF form of $\lnot\big(p \Rightarrow (q \land r)\big)$?

    1. $(\lnot p \lor q) \land (\lnot p \lor r)$
    2. $p \land \lnot q \land \lnot r$
    3. $p \land (\lnot q \lor \lnot r)$
    4. $\lnot p \lor (\lnot q \land \lnot r)$

    Use $\lnot(X \Rightarrow Y) \equiv X \land \lnot Y$, then De Morgan on $\lnot(q \land r)$.

    Step 1: $\lnot(p \Rightarrow (q \land r)) \equiv p \land \lnot(q \land r)$, because an implication is false exactly when its left side is true and its right side false.

    Step 2: De Morgan: $\lnot(q \land r) \equiv \lnot q \lor \lnot r$. So the sentence is $p \land (\lnot q \lor \lnot r)$: two clauses, already in CNF. Answer (C).

    (A) is the CNF of $p \Rightarrow (q \land r)$ itself: the negation was dropped. (B) applies De Morgan wrongly ($\lnot(q \land r)$ is not $\lnot q \land \lnot r$); it is false at $p = T, q = T, r = F$, where the original is true. (D) negates the implication by negating both sides, which is not a valid rule.

    • Read $p \Rightarrow q$ as a promise: false only when $p$ happens and $q$ doesn’t.
    • For "is $X \Rightarrow Y$ a tautology?", only examine rows where $X$ is true.
    • Check an equivalence by finding one row where the two sides differ; one row is enough to say “not equivalent”.
    • Prove entailment by showing $KB \land \lnot\alpha$ has no model.
    • Thinking $p \Rightarrow q$ is false when $p$ is false. It is (vacuously) true.
    • Swapping an implication for its converse $q \Rightarrow p$.
    • Applying De Morgan without flipping the connective: $\lnot(p \land q)$ is $\lnot p \lor \lnot q$, not $\lnot p \land \lnot q$.
    • Reading "$X$ entails $Y$“ as ”$Y$ entails $X$".
    1. A truth table has 2ⁿ rows; tautology = true in all, contradiction = true in none, satisfiable = true in some.
    2. p ⇒ q is false only when p is true and q false; so p ⇒ q ≡ ¬p ∨ q ≡ ¬q ⇒ ¬p, but not q ⇒ p.
    3. KB ⊨ α means α holds in every model of KB; equivalently KB ⇒ α is a tautology, or KB ∧ ¬α is unsatisfiable (what resolution proves).

    The league promised: “If it rains, the match will be shortened.” It did not rain, and the match was played in full. Did the league break its promise?

    Yes: the match was not shortened
    The promise was only about rainy days. Which situation would actually break it?
    It is neither kept nor broken, so the sentence has no truth value
    In logic every proposition is T or F. An untested promise has to be one of them.
    No: the promise was never tested, so it counts as kept
    Right. $p \Rightarrow q$ is false only when $p$ is true and $q$ false. With $p$ false it is vacuously true.
    Only if the match was shortened for some other reason
    Nothing was shortened here. Look at what the promise claims when it doesn’t rain.

    Which sentence is equivalent to $p \Rightarrow q$?

    $\lnot q \Rightarrow \lnot p$
    The contrapositive. Both are false only at $p = T$, $q = F$.
    $q \Rightarrow p$
    That’s the converse. Compare the rows $p = F$, $q = T$.
    $\lnot p \Rightarrow \lnot q$
    That’s the inverse, which is equivalent to the converse, not the original.
    $p \land q$
    $p \Rightarrow q$ is true when $p$ is false; $p \land q$ isn’t.

    $KB \models \alpha$ holds exactly when

    $KB \land \alpha$ is satisfiable
    That only says they can be true together once. Entailment needs every model of $KB$.
    $\alpha \Rightarrow KB$ is a tautology
    The arrow points the wrong way.
    $KB$ and $\alpha$ are equivalent
    Equivalence is entailment in both directions; one direction is enough here.
    $KB \land \lnot\alpha$ is unsatisfiable
    No row has $KB$ true and $\alpha$ false, which is the definition of entailment. Resolution proofs show exactly this.

    First-order logic: talking about every player at once

    First-order logic adds objects, properties of objects (predicates) and the words “for all” ($\forall$) and “there exists” ($\exists$), so one sentence can describe a whole squad.

    GATE DA asks you to pick the correct translation of an English sentence (2024 Q54, 2026 Q14) or to decide which quantified sentences are valid (2026 Q48). Two rules of thumb settle most of them.

    It’s like the difference between a team sheet that lists “Asha is fit, Bilal is fit, Chitra is fit, …” and a single line from the physio: “every batter is fit”.

    Where it shows up in GATE DA

    Translation from English, negating quantifiers, and spotting which sentences are valid. Mostly MSQ.

    2024 Q54 · “all balls are round except…”2026 Q14 · each king is a person2026 Q48 · ∀ ⇒ ∃ and friends
    Heat: 2 of 3 papers, 1–2 marks each

    Why propositions are not enough

    Suppose the Kalinga Kernels’ assistant has to know that every batter in a 25-player squad is fit. In propositional logic each fact needs its own atom: $\mathit{AshaFit}$, $\mathit{BilalFit}$, and so on, and the rule “batters must be fit” has to be written 25 times. Add a player and you add atoms and rules. Worse, the logic cannot see that $\mathit{AshaFit}$ and $\mathit{BilalFit}$ are about the same property.

    First-order logic (also called predicate logic) fixes this by talking about objects and their properties.

    The vocabulary
    domain
    the set of objects we talk about, e.g. the four players Asha, Bilal, Chitra, Dev. It is never empty.
    constant
    a name for one object: $\mathit{Asha}$.
    variable
    a placeholder for an object: $x$, $y$.
    predicate
    a property or relation that is T or F once you plug in objects: $\mathit{Fit}(x)$ “x is fit”, $\mathit{Admires}(x, y)$ “x admires y”.
    $\forall x$
    "for all $x$": the sentence after it holds for every object in the domain.
    $\exists x$
    "there exists $x$": it holds for at least one object (one or more).

    A world (also called an interpretation or model) fixes the domain and says, for each predicate, which objects it is true of. “Every batter is fit” is then written once: $$\forall x\,\big(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x)\big).$$ Over a finite domain, $\forall$ is a big “and” and $\exists$ is a big “or”: with the four players, $\forall x\, \mathit{Fit}(x)$ means $\mathit{Fit}(\mathit{Asha}) \land \mathit{Fit}(\mathit{Bilal}) \land \mathit{Fit}(\mathit{Chitra}) \land \mathit{Fit}(\mathit{Dev})$. That view explains almost every rule below.

    The two translation rules

    “All A are B” uses $\forall$ with $\Rightarrow$: $\forall x\,(A(x) \Rightarrow B(x))$. The implication restricts the claim to the A’s; anything that isn’t an A makes the implication vacuously true, so it is ignored, which is what we want. Writing $\forall x\,(A(x) \land B(x))$ instead says that everything in the domain is an A and a B: “every player is a fit batter”, a much stronger claim.

    “Some A is B” uses $\exists$ with $\land$: $\exists x\,(A(x) \land B(x))$, a single object that is both. Writing $\exists x\,(A(x) \Rightarrow B(x))$ instead is almost always true for a silly reason: any object that is not an A makes the implication true, so it is a witness.

    EnglishFirst-order logic
    Every batter is fit.$\forall x\,(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x))$
    Some batter is fit.$\exists x\,(\mathit{Batter}(x) \land \mathit{Fit}(x))$
    No batter is fit.$\forall x\,(\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$, or $\lnot\exists x\,(\mathit{Batter}(x) \land \mathit{Fit}(x))$
    Only fit players bat.$\forall x\,(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x))$ (“only” points the arrow at the word after it)
    Everyone admires somebody.$\forall x\,\exists y\; \mathit{Admires}(x, y)$
    Somebody is admired by everyone.$\exists y\,\forall x\; \mathit{Admires}(x, y)$

    $$\lnot\forall x\, P(x) \;\equiv\; \exists x\, \lnot P(x) \qquad\qquad \lnot\exists x\, P(x) \;\equiv\; \forall x\, \lnot P(x)$$ “Not everyone is fit” means “someone is unfit”; “nobody is fit” means “everyone is unfit”. This is De Morgan’s law for the big “and” and big “or”. Example: the negation of “every batter is fit” is $\exists x\,(\mathit{Batter}(x) \land \lnot\mathit{Fit}(x))$, “some batter is unfit”, using $\lnot(A \Rightarrow B) \equiv A \land \lnot B$ from Chapter 2.1.

    Order of quantifiers matters

    $\forall x\,\exists y\; \mathit{Admires}(x, y)$: everyone has a hero, but the heroes can differ. $\exists y\,\forall x\; \mathit{Admires}(x, y)$: there is one player whom everybody admires. The second is stronger. If one player is admired by all, then certainly everyone admires somebody, so $\exists y\,\forall x \Rightarrow \forall x\,\exists y$ is valid; the reverse is not.

    Valid sentences

    A first-order sentence is valid if it is true in every world (every non-empty domain and every way of filling in the predicates). It is the first-order version of a tautology. To show a sentence is not valid, build one small world where it is false (a counter-model); two objects are usually enough.

    • Valid: $\forall x\, P(x) \Rightarrow \exists x\, P(x)$ (the domain is never empty, so “all” includes at least one).
    • Not valid: $\exists x\, P(x) \Rightarrow \forall x\, P(x)$ (one fit player doesn’t make everyone fit).
    • Valid: $\forall x\,(P(x) \land Q(x)) \Leftrightarrow \forall x\, P(x) \land \forall x\, Q(x)$, and $\exists x\,(P(x) \lor Q(x)) \Leftrightarrow \exists x\, P(x) \lor \exists x\, Q(x)$.
    • Only one direction is valid: $\forall x\, P(x) \lor \forall x\, Q(x) \Rightarrow \forall x\,(P(x) \lor Q(x))$, and $\exists x\,(P(x) \land Q(x)) \Rightarrow \exists x\, P(x) \land \exists x\, Q(x)$.
    • Valid: $\exists y\,\forall x\, R(x, y) \Rightarrow \forall x\,\exists y\, R(x, y)$; the converse is not.
    Try it

    This is a world of four players. Tap any T/F to change who is a batter, who is fit and who admires whom; the eight sentences below re-evaluate, each with a witness or counterexample. Notice that the wrong translations (lines 2 and 4) disagree with the right ones. Choose No batters to see “every batter is fit” become vacuously true. Then make a column of all T and watch $\exists y\,\forall x$ switch on.

    GATE DA 2024 · Q54 · MSQ · 2 marks

    Let game(ball, rugby) be true if the ball is used in rugby and false otherwise.

    Let shape(ball, round) be true if the ball is round and false otherwise.

    Consider the following logical sentences:

    s1: ∀ball ¬ game(ball, rugby) ⟹ shape(ball, round)
    s2: ∀ball ¬ shape(ball, round) ⟹ game(ball, rugby)
    s3: ∀ball game(ball, rugby) ⟹ ¬ shape(ball, round)
    s4: ∀ball shape(ball, round) ⟹ ¬ game(ball, rugby)

    Which of the following choices is/are logical representations of the assertion, “All balls are round except balls used in rugby”?

    1. $s1 \land s3$
    2. $s1 \land s2$
    3. $s2 \land s3$
    4. $s3 \land s4$
    1. Write $G(b)$ for game(ball, rugby) and $R(b)$ for shape(ball, round). “All balls are round except balls used in rugby” makes two claims: a ball not used in rugby is round, $\forall b\,(\lnot G(b) \Rightarrow R(b))$, which is s1; and a rugby ball is not round, $\forall b\,(G(b) \Rightarrow \lnot R(b))$, which is s3.

      “Except” carves out the rugby balls and says they are the exception: not round. The intended reading, confirmed by the key, is “round exactly when not a rugby ball”.

    2. s2 is the contrapositive of s1: $\lnot R \Rightarrow G$ is the same as $\lnot G \Rightarrow R$. So s2 $\equiv$ s1. Likewise s4 ($R \Rightarrow \lnot G$) is the contrapositive of s3, so s4 $\equiv$ s3.

      Contrapositives are equivalent for each ball, so the $\forall$ versions are equivalent too.

    3. (A) $s1 \land s3$: both claims. Correct. (C) $s2 \land s3 \equiv s1 \land s3$: also correct.

      Replacing a sentence by an equivalent one doesn’t change the meaning.

    4. (B) $s1 \land s2 \equiv s1$: only the first claim; it allows a round rugby ball. (D) $s3 \land s4 \equiv s3$: only the second claim; it allows a non-round ball that isn’t used in rugby. Answer (A), (C).

      Each of (B), (D) says one thing twice. Official key: A; C.

    The Haryana Heuristics’ physio claims “every batter is fit”: $\forall x\,(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x))$. Which sentence says the physio is wrong?

    1. $\forall x\,(\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    2. $\exists x\,(\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    3. $\forall x\,(\lnot\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    4. $\exists x\,(\mathit{Batter}(x) \land \lnot\mathit{Fit}(x))$

    Move $\lnot$ past $\forall$ (it becomes $\exists$), then negate the implication.

    $\lnot\forall x\,(B(x) \Rightarrow F(x)) \equiv \exists x\,\lnot(B(x) \Rightarrow F(x)) \equiv \exists x\,(B(x) \land \lnot F(x))$: some batter is unfit. Answer (D).

    (A) says no batter is fit, far stronger than needed. (B) is true as soon as anyone is not a batter. (C) is a different rule altogether.

    The domain is three players and $P(x)$ means “x scored a fifty”. There are $2^3 = 8$ ways to decide which players scored a fifty. In how many of them is $\exists x\, P(x) \Rightarrow \forall x\, P(x)$ true?

    An implication is false only when the left side is true and the right side false. When does that happen here?

    It is false when someone scored a fifty but not everyone did: 1 or 2 of the 3 players, which is $3 + 3 = 6$ worlds. It is true in the other 2: nobody scored (left side false, vacuously true) or everybody scored (right side true). Answer 2, which is why this sentence is not valid.

    GATE DA 2026 · Q14 · MCQ · 1 mark

    Which of the following statements is NOT true?

    (The names of the predicates are intuitive.)

    1. $\forall x\;\forall y\;\; \mathit{Classmate}(x, y) \Rightarrow \mathit{Classmate}(y, x)$
    2. $\forall x\;\mathit{Likes}(x, \mathit{Icecream}) \;\Rightarrow\; \lnot\exists x\;\lnot\mathit{Likes}(x, \mathit{Icecream})$
    3. “Each king is a person” is equivalent to $\forall x\;\mathit{IsKing}(x) \land \mathit{IsPerson}(x)$
    4. “All humans are mortal” is equivalent to $\forall x\;\mathit{IsHuman}(x) \Rightarrow \mathit{IsMortal}(x)$

    Which quantifier goes with $\Rightarrow$, and which with $\land$?

    (C) uses $\forall$ with $\land$, which says that everything in the domain is a king and a person. “Each king is a person” should be $\forall x\,(\mathit{IsKing}(x) \Rightarrow \mathit{IsPerson}(x))$. So (C) is the false statement: answer (C).

    (A) is true for the intended meaning: being classmates is symmetric. (B) is the quantifier-negation rule: “everyone likes ice cream” means “nobody doesn’t like ice cream”. (D) is the textbook translation of “all A are B”. Official key: C.

    GATE DA 2026 · Q48 · MSQ · 2 marks

    Let $P(x)$ be a predicate.

    Which of the following statements is/are NOT valid in first-order logic?

    1. $\forall x\, P(x) \Rightarrow \exists x\, P(x)$
    2. $\exists x\, P(x) \Rightarrow \forall x\, P(x)$
    3. $\exists x\, P(x) \Leftrightarrow \forall x\, P(x)$
    4. $\forall x\, P(x) \Rightarrow \exists x\, \lnot P(x)$

    For each one, try a two-object world where $P$ is true of one object and false of the other, and a one-object world where $P$ is true.

    Each side carries its own quantifier, so compare “all” with “some”.

    (A) is valid: domains are non-empty, so if every object has $P$, at least one does.

    (B) fails in the world {$a$, $b$} with $P(a)$ true and $P(b)$ false: “some” is true, “all” is false. (C) fails in the same world, since a biconditional with sides T and F is false. (D) fails in a world where $P$ is true of every object: the left side is true and there is no object without $P$.

    Not valid: (B), (C), (D). Official key: B; C; D.

    The Hyderabad Hyperplanes’ selectors announce: “Only fit players are selected.” A journalist wants to report that the announcement is false. Which sentence should the journalist’s claim be equivalent to? ($\mathit{Sel}(x)$: x is selected; $\mathit{Fit}(x)$: x is fit.)

    1. $\exists x\,(\mathit{Fit}(x) \land \lnot\mathit{Sel}(x))$
    2. $\forall x\,(\mathit{Sel}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    3. $\exists x\,(\mathit{Sel}(x) \land \lnot\mathit{Fit}(x))$
    4. $\forall x\,(\lnot\mathit{Fit}(x) \Rightarrow \mathit{Sel}(x))$

    First translate “only fit players are selected”: “only” points the arrow at the word after it. Then negate.

    Step 1: “Only fit players are selected” means anyone selected is fit: $\forall x\,(\mathit{Sel}(x) \Rightarrow \mathit{Fit}(x))$. (It does not say every fit player is selected.)

    Step 2: negate: $\exists x\,\lnot(\mathit{Sel}(x) \Rightarrow \mathit{Fit}(x)) \equiv \exists x\,(\mathit{Sel}(x) \land \lnot\mathit{Fit}(x))$: some selected player is unfit. Answer (C).

    (A) is the negation of the reversed reading “all fit players are selected”, the classic “only” trap. (B) says no selected player is fit, which is too strong. (D) says every unfit player is selected; it doesn’t follow from the announcement being false, and it can be true while the announcement also holds (when nobody is unfit).

    $P$ and $Q$ are predicates over any non-empty domain. Which of these are valid? (Select all that apply.)

    1. $\forall x\,(P(x) \land Q(x)) \Leftrightarrow \big(\forall x\, P(x) \land \forall x\, Q(x)\big)$
    2. $\big(\forall x\, P(x) \lor \forall x\, Q(x)\big) \Rightarrow \forall x\,(P(x) \lor Q(x))$
    3. $\forall x\,(P(x) \lor Q(x)) \Rightarrow \big(\forall x\, P(x) \lor \forall x\, Q(x)\big)$
    4. $\big(\exists x\, P(x) \land \exists x\, Q(x)\big) \Rightarrow \exists x\,(P(x) \land Q(x))$

    Think of DPL players: $P$ = “is a batter”, $Q$ = “is a bowler”, in a squad where every player is exactly one of the two.

    (A) Valid. “Everyone is P and Q” holds exactly when everyone is P and everyone is Q: $\forall$ is a big “and”, and “and”s can be regrouped freely.

    (B) Valid. If everyone is P, then everyone is P or Q; same if everyone is Q.

    (C) Not valid. Squad {$a$, $b$} with $a$ a batter only and $b$ a bowler only: everyone is a batter or a bowler, yet not everyone is a batter and not everyone is a bowler.

    (D) Not valid. Same squad: there is a batter and there is a bowler, but nobody is both.

    Answer (A), (B). The trap is to treat (B) and (C) as the same: $\forall$ splits over $\land$ in both directions, but over $\lor$ in only one.

    The domain has two players, Asha and Bilal. A relation $\mathit{Admires}(x, y)$ is any choice of which of the 4 ordered pairs (including a player admiring themself) are true, so there are $2^4 = 16$ possible relations. For how many of them is $\forall x\,\exists y\; \mathit{Admires}(x, y)$ true but $\exists y\,\forall x\; \mathit{Admires}(x, y)$ false?

    Draw the relation as a 2 × 2 grid: row = admirer, column = admired. The first sentence says every row has a T; the second says some column is all T.

    $\forall x\,\exists y$: each row has at least one T. Each row has 3 non-empty choices out of 4, so $3 \times 3 = 9$ relations.

    $\exists y\,\forall x$: some column is all T. Column 1 all T: $2^2 = 4$ relations; column 2 all T: 4; both: 1. So $4 + 4 - 1 = 7$ relations.

    Every relation with a full column has a T in every row, so all 7 are among the 9. The count we want is $9 - 7 =$ 2: the “diagonal” (each admires only themself) and the “swap” (each admires only the other). In both, everyone has a hero but no single player is everyone’s hero.

    A tempting wrong answer is 9, from $16 - 7$: that counts every relation where the second sentence is false, forgetting that the first must also be true.

    • Pair $\forall$ with $\Rightarrow$ and $\exists$ with $\land$.
    • Negate by flipping each quantifier and pushing $\lnot$ inside: $\lnot\forall x \to \exists x\,\lnot$.
    • Disprove validity with a two-object counter-model.
    • Read “only A are B” as $\forall x\,(B(x) \Rightarrow A(x))$.
    • Writing $\forall x\,(A(x) \land B(x))$ for “all A are B”.
    • Writing $\exists x\,(A(x) \Rightarrow B(x))$ for “some A is B”.
    • Swapping the order of $\forall$ and $\exists$ as if it didn’t matter.
    • Forgetting that “all balls are round except rugby balls” also says the rugby balls are not round.
    1. Predicates describe objects; ∀ is a big “and” over the domain, ∃ a big “or”.
    2. “All A are B” = ∀x (A(x) ⇒ B(x)); “some A is B” = ∃x (A(x) ∧ B(x)); ¬∀x P ≡ ∃x ¬P and ¬∃x P ≡ ∀x ¬P.
    3. Valid = true in every world; ∀x P ⇒ ∃x P and ∃y∀x R ⇒ ∀x∃y R are valid, their converses are not.

    Which sentence says “every batter is fit”?

    $\forall x\,(\mathit{Batter}(x) \land \mathit{Fit}(x))$
    This says everyone in the squad is a batter. What should happen to non-batters?
    $\forall x\,(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x))$
    The implication restricts the claim to batters; non-batters make it vacuously true.
    $\exists x\,(\mathit{Batter}(x) \land \mathit{Fit}(x))$
    That is “some batter is fit”, a much weaker claim.
    $\forall x\,(\mathit{Fit}(x) \Rightarrow \mathit{Batter}(x))$
    The arrow is reversed: this says every fit player bats.

    $\lnot\forall x\, \mathit{Fit}(x)$ is equivalent to

    $\forall x\, \lnot\mathit{Fit}(x)$
    That says nobody is fit. “Not everyone” is weaker than “no one”.
    $\lnot\exists x\, \mathit{Fit}(x)$
    This also says nobody is fit.
    $\exists x\, \lnot\mathit{Fit}(x)$
    “Not everyone is fit” means “someone is unfit”: flip the quantifier and push the $\lnot$ in.
    $\exists x\, \mathit{Fit}(x)$
    The negation has disappeared. Where should it go?

    Which implication is valid for every relation $R$ on every non-empty domain?

    $\forall x\,\exists y\, R(x, y) \Rightarrow \exists y\,\forall x\, R(x, y)$
    Everyone having a hero doesn’t mean they share one. Try two players who each admire only themselves.
    $\exists x\, R(x, x) \Rightarrow \forall x\, R(x, x)$
    “Some” to “all” fails as soon as one object lacks the property.
    $\forall x\,\exists y\, R(x, y) \Rightarrow \forall x\, R(x, x)$
    Admiring someone doesn’t mean admiring yourself.
    $\exists y\,\forall x\, R(x, y) \Rightarrow \forall x\,\exists y\, R(x, y)$
    If one $y$ works for every $x$, then every $x$ has some $y$: use that same one.

    Which of these is a tautology?

    $p \Rightarrow (p \land q)$
    Try $p = T$, $q = F$.
    $p \Rightarrow (q \Rightarrow p)$
    A bad row needs $p = T$ and $q \Rightarrow p$ false, but $q \Rightarrow p$ is true whenever $p$ is true.
    $(p \Rightarrow q) \Rightarrow p$
    Try $p = F$: the left side is true and the right side false.
    $p \lor q$
    It is false when both are false.

    From $p \Rightarrow q$ and $q$, an agent concludes $p$. This inference is

    valid: it is modus ponens
    Modus ponens goes from $p$ and $p \Rightarrow q$ to $q$. Check the direction.
    valid: it is modus tollens
    Modus tollens starts from $\lnot q$.
    not valid: $p = F$, $q = T$ makes both premises true and the conclusion false
    This is affirming the consequent: the match can be shortened without rain.
    valid only when $p$ and $q$ are equivalent
    An inference rule must work in every row, and the row $p = F$, $q = T$ breaks it.

    How many of the 8 rows over $p, q, r$ make $p \lor q$ true?

    3
    That is the count over $p, q$ alone. Each of those rows appears twice, once with $r = T$ and once with $r = F$.
    4
    Count the rows where $p$ and $q$ are both false: those are the only failures.
    6
    $p \lor q$ fails only when $p = q = F$, which is 2 of the 8 rows ($r$ free).
    7
    With three atoms, “both false” leaves $r$ free, so it rules out two rows.

    “Some bowler is injured” is

    $\exists x\,(\mathit{Bowler}(x) \land \mathit{Injured}(x))$
    One object that is both: $\exists$ pairs with $\land$.
    $\exists x\,(\mathit{Bowler}(x) \Rightarrow \mathit{Injured}(x))$
    Any non-bowler would make this true. Which connective goes with $\exists$?
    $\forall x\,(\mathit{Bowler}(x) \Rightarrow \mathit{Injured}(x))$
    That says every bowler is injured.
    $\exists x\, \mathit{Bowler}(x) \land \exists x\, \mathit{Injured}(x)$
    The bowler and the injured player could be different people.

    The negation of $\forall x\,(\mathit{Batter}(x) \Rightarrow \mathit{Fit}(x))$ is

    $\forall x\,(\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    The quantifier must flip too.
    $\exists x\,(\lnot\mathit{Batter}(x) \Rightarrow \lnot\mathit{Fit}(x))$
    Negating an implication doesn’t negate both sides. When is an implication false?
    $\exists x\,(\mathit{Batter}(x) \land \lnot\mathit{Fit}(x))$
    Flip $\forall$ to $\exists$, then $\lnot(A \Rightarrow B) \equiv A \land \lnot B$.
    $\lnot\exists x\,\mathit{Batter}(x)$
    That says there are no batters, which would make the original vacuously true.

    Real decisions run on facts you are not sure of. A Bayesian network writes down which uncertain facts directly influence which, using one small table per fact, and that is enough to answer any probability question about all of them together. This part builds networks from scratch, reads conditional independence straight off the drawing, and then computes answers exactly (enumeration, variable elimination) and approximately (sampling). GATE DA has asked about Bayesian networks in every paper so far.

    You need: conditional probability, the multiplication rule and independence (Probability 2.1), Bayes’ theorem (Probability 2.2), and directed graphs from Python & DSA.

    Bayesian networks: who influences whom

    A Bayesian network is a drawing of arrows between uncertain facts, plus one small table per fact, that together pin down the probability of every combination of those facts.

    GATE DA asks it two ways: compute one probability from the tables (2024 Q64, 2 marks) or decide which independence statement the drawing allows (2024 Q24). Both take a minute once you know the two rules in this chapter.

    It’s like a family tree for causes: to know about a child, you mostly need to know about the parents, not every ancestor.

    Where it shows up in GATE DA

    One or two questions a year: a joint probability from CPTs, an independence statement, or an inference algorithm.

    2024 Q24 · which independence is false2024 Q64 · joint probability from CPTs2025 Q26 · exact vs approximate inferenceSample Q32 · likelihood weighting
    Heat: every year, 1–3 marks

    Recall three facts from Probability 2.1. The conditional probability $P(A\mid B)$ is the chance of $A$ once you know $B$ happened. The multiplication rule says $P(A, B) = P(B)\,P(A\mid B)$, where the comma means “and”. And $A$, $B$ are independent when $P(A\mid B) = P(A)$: learning $B$ changes nothing.

    A random variable here is simply an uncertain yes/no fact, such as “it rained overnight”. We write $R$ for the fact and $R = \text{yes}$ or $R = \text{no}$ for its two values.

    Match day in the DPL

    The Kalinga Kernels’ analyst tracks five yes/no facts before every home match: $R$ it rained overnight, $S$ the visitors picked their leg-spinner, $L$ the first innings ended with a low score, $D$ the start was delayed, $F$ fans left early. They want answers such as “the score was low; how likely is it that it had rained?”

    The problem: a full table is too big

    The most complete description of five yes/no facts is a joint distribution table: one row for every combination of values, with its probability. Five facts give $2^5 = 32$ rows. The rows must add up to 1, so 31 of them are free numbers you would have to estimate from data.

    That grows fast. With 20 facts the table has $2^{20} - 1$, over a million, free numbers. Nobody can estimate those, store them comfortably or add them up for every question.

    The way out is to notice that most facts are directly influenced by only one or two others. Rain affects the delay and the pitch; the delay does not care whether the spinner was picked. If you write down only those direct influences, a few numbers per fact are enough.

    FactParentsStored probabilities of “yes”Numbers
    $R$ rain overnightnone$P(R) = 0.2$1
    $S$ spinner pickednone$P(S) = 0.6$1
    $L$ low score$R, S$$P(L\mid R, S) = 0.9$, $P(L\mid R, \lnot S) = 0.7$, $P(L\mid \lnot R, S) = 0.4$, $P(L\mid \lnot R, \lnot S) = 0.1$4
    $D$ delayed start$R$$P(D\mid R) = 0.7$, $P(D\mid \lnot R) = 0.1$2
    $F$ fans leave early$L$$P(F\mid L) = 0.6$, $P(F\mid \lnot L) = 0.2$2
    Total (the full joint table needs 31)10

    Notation: $R$ alone is short for $R = \text{yes}$ and $\lnot R$ ("not $R$") for $R = \text{no}$. Each “no” probability is one minus the “yes” one, so it is not stored: $P(\lnot D\mid R) = 1 - 0.7 = 0.3$.

    A Bayesian network has two parts.

    • A directed acyclic graph (DAG): one node per random variable, arrows between them, and no way to follow arrows round in a loop. If there is an arrow $X \to Y$, then $X$ is a parent of $Y$ and $Y$ a child of $X$. Following arrows forward from $X$ reaches its descendants.
    • For every node $X$, a conditional probability table (CPT) giving $P(X\mid \text{parents of } X)$, one row for each combination of the parents’ values. A node with no parents just stores $P(X)$.

    Each row is a probability distribution, so it adds up to 1. For a yes/no node with $k$ yes/no parents that means $2^k$ rows and one free number per row.

    A Bayesian network over $X_1, \ldots, X_n$ defines the joint distribution $$P(x_1, x_2, \ldots, x_n) = \prod_{i=1}^{n} P\big(x_i \mid \text{parents}(X_i)\big).$$ In words: the probability of a full assignment is the product of one CPT entry per node, each read in the row that matches that node’s parents.

    Why the product is the whole joint

    List the variables so that every parent comes before its children (here $R, S, L, D, F$). Using the multiplication rule over and over, any joint can be written exactly as $$P(r, s, l, d, f) = P(r)\,P(s\mid r)\,P(l\mid r, s)\,P(d\mid r, s, l)\,P(f\mid r, s, l, d).$$ That step is always true; it is the chain rule of probability. The network then adds one promise: given its parents, each variable ignores every earlier variable. So $P(s\mid r) = P(s)$, $P(d\mid r, s, l) = P(d\mid r)$ and $P(f\mid r, s, l, d) = P(f\mid l)$, and the chain rule collapses to the product of CPT entries.

    For example, the chance of the day “rain, no spinner, low score, delay, fans stay” is $$P(R, \lnot S, L, D, \lnot F) = 0.2 \times 0.4 \times 0.7 \times 0.7 \times 0.4 = 0.01568.$$ Read each factor in the row matching the parents: $P(L\mid R, \lnot S) = 0.7$ and $P(\lnot F\mid L) = 1 - 0.6 = 0.4$.

    For yes/no variables, a node with $k$ parents needs $2^k$ numbers. Add over the nodes and compare with $2^n - 1$ for the full joint. If a variable takes $m$ values, each CPT row needs $m - 1$ numbers and the number of rows is the product of the parents’ value counts.

    Conditional independence: what the arrows leave out

    Two facts can be related at first but unrelated once you know a third. If you know it rained, learning that the start was delayed tells you nothing new about whether the score will be low: all the link between them ran through the rain.

    $X$ is conditionally independent of $Y$ given $Z$, written $X \perp Y \mid Z$, when $$P(X\mid Y, Z) = P(X\mid Z)$$ for all values. Once $Z$ is known, $Y$ adds nothing about $X$. Equivalently $P(X, Y\mid Z) = P(X\mid Z)\,P(Y\mid Z)$.

    Every question about independence in a network comes down to three ways a middle node $B$ can sit between $A$ and $C$.

    ShapeDPL example$B$ unknown$B$ observed
    Chain $A \to B \to C$rain → low score → fans leaveopen: $A$ and $C$ dependentblocked: $A \perp C \mid B$
    Fork $A \leftarrow B \to C$delay ← rain → low scoreopen: dependent (common cause)blocked: $A \perp C \mid B$
    Collider $A \to B \leftarrow C$rain → low score ← spinnerblocked: $A \perp C$open: dependent given $B$

    The chain and the fork behave alike: information flows through the middle until you observe it. The collider is the surprise. Rain and the spinner are chosen independently, so with nothing observed they are independent. But tell the analyst the score was low, and they become linked: if the spinner played, that already explains the low score, so rain becomes less likely. This is called explaining away. With the match-day tables:

    $$P(R\mid L) \approx 0.423, \qquad P(R\mid L, S) = 0.36, \qquad P(R\mid L, \lnot S) \approx 0.636.$$

    Before anything is observed, $P(R) = 0.2$. Learning $L$ raises it; learning $S$ as well pulls it back down. Rain and spinner are dependent once the score is known.

    Fix a set $Z$ of observed variables. A path between $X$ and $Y$ (following edges in either direction) is blocked if some node $B$ on it is

    • the middle of a chain or fork with $B$ in $Z$, or
    • a collider ($\to B \leftarrow$) with neither $B$ nor any descendant of $B$ in $Z$.

    If every path between $X$ and $Y$ is blocked, they are d-separated by $Z$, and then $X \perp Y \mid Z$ holds for every choice of CPTs.

    A useful special case, the local Markov property: each node is conditionally independent of its non-descendants given its parents.

    Careful: observing a descendant of a collider also opens it. In the match-day network, learning $F$ (fans left early) is evidence about $L$, so it too links $R$ and $S$.
    Try it

    Pick a shape and watch the two probabilities in the readout: if they differ, learning $A$ changes your belief in $C$. Start with the chain and the fork: observe the middle node and the two numbers become equal. Then pick the collider: the numbers are equal until you observe the middle node, and then they split. The numbers come from the full five-node network, computed exactly.

    GATE DA 2024 · Q24 · MCQ · 1 mark

    Consider five random variables $U, V, W, X$, and $Y$ whose joint distribution satisfies: $$P(U, V, W, X, Y) = P(U)P(V)P(W\mid U, V)P(X\mid W)P(Y\mid W)$$ Which ONE of the following statements is FALSE?

    1. $Y$ is conditionally independent of $V$ given $W$
    2. $X$ is conditionally independent of $U$ given $W$
    3. $U$ and $V$ are conditionally independent given $W$
    4. $Y$ and $X$ are conditionally independent given $W$
    1. Draw the network from the factorisation: each factor $P(\text{node}\mid\text{parents})$ gives arrows from the parents. So $U \to W \leftarrow V$, $W \to X$ and $W \to Y$.

      $P(U)$ and $P(V)$ have no condition, so $U$ and $V$ are roots. $P(W\mid U, V)$ means two arrows into $W$.

    2. (A) path $V \to W \to Y$ is a chain with $W$ observed: blocked, so true. (B) $U \to W \to X$, same reason: true. (D) $X \leftarrow W \to Y$ is a fork with $W$ observed: blocked, so true.

      Each of these pairs has only one path, through $W$, and $W$ is the middle of a chain or fork.

    3. (C) $U \to W \leftarrow V$ is a collider, and it is observed. Observing a collider opens the path, so $U$ and $V$ are dependent given $W$. (C) is the false statement. Official key: C.

      This is explaining away. $U$ and $V$ are independent on their own (the factorisation has $P(U)P(V)$), but not once their common effect is known.

    A network has six yes/no variables. $A$ and $B$ have no parents; $C$ has parents $A, B$; $D$ has parent $C$; $E$ has parents $C, D$; $F$ has parent $E$. How many independent numbers do its CPTs need, and how many does the full joint table need?

    A yes/no node with $k$ yes/no parents needs $2^k$ numbers. The full joint over $n$ yes/no variables needs $2^n - 1$.

    Network: $1 + 1 + 4 + 2 + 4 + 2 = 14$. Full joint: $2^6 - 1 = 63$.

    Using the match-day network, find $P(\lnot R, S, L, \lnot D, F)$: no rain, spinner picked, low score, no delay, fans leave early. (Round off to four decimal places.)

    One factor per node, each read in the row that matches its parents: $P(\lnot R)$, $P(S)$, $P(L\mid\lnot R, S)$, $P(\lnot D\mid\lnot R)$, $P(F\mid L)$.

    $0.8 \times 0.6 \times 0.4 \times 0.9 \times 0.6 = 0.10368 \approx$ 0.1037.

    $P(\lnot R) = 1 - 0.2$ and $P(\lnot D\mid \lnot R) = 1 - 0.1$: the “no” entries are one minus the stored “yes” entries.

    In the match-day network ($R \to D$, $R \to L$, $S \to L$, $L \to F$), which statements hold for every choice of CPTs? (Select all that apply.)

    1. $S \perp D$
    2. $S \perp D \mid L$
    3. $D \perp L \mid R$
    4. $R \perp F \mid L$

    The only path from $S$ to $D$ is $S \to L \leftarrow R \to D$. Is $L$ a collider on it? What happens when it is observed?

    (A) True: on $S \to L \leftarrow R \to D$ the node $L$ is a collider, unobserved and with no observed descendant, so the path is blocked.

    (B) False: observing the collider $L$ opens it, and $R$ (a fork, unobserved) lets the dependence through. With the match-day numbers, $P(S\mid L) \approx 0.773$ but $P(S\mid L, D) \approx 0.691$.

    (C) True: $D \leftarrow R \to L$ is a fork with $R$ observed. (D) True: $R \to L \to F$ is a chain with $L$ observed; the other route from $R$ to $F$ would have to pass through $L$ as well.

    GATE DA 2024 · Q64 · NAT · 2 marks

    Given the following Bayesian Network consisting of four Bernoulli random variables and the associated conditional probability tables:

    $P(\cdot)$
    $U = 0$0.5
    $U = 1$0.5
    $P(V = 0\mid\cdot)$$P(V = 1\mid\cdot)$
    $U = 0$0.50.5
    $U = 1$0.50.5
    $P(W = 0\mid\cdot)$$P(W = 1\mid\cdot)$
    $U = 0$10
    $U = 1$01
    $P(Z = 0\mid\cdot)$$P(Z = 1\mid\cdot)$
    $V = 0$$W = 0$0.50.5
    $V = 0$$W = 1$10
    $V = 1$$W = 0$10
    $V = 1$$W = 1$0.50.5

    The value of $P(U = 1, V = 1, W = 1, Z = 1) =$ ______ (rounded off to three decimal places).

    (Figure and tables redrawn from the paper.)

    Factorise: $P(U)\,P(V\mid U)\,P(W\mid U)\,P(Z\mid V, W)$. Read each factor in the row matching the parents’ values.

    $P(U{=}1) = 0.5$, $P(V{=}1\mid U{=}1) = 0.5$, $P(W{=}1\mid U{=}1) = 1$, $P(Z{=}1\mid V{=}1, W{=}1) = 0.5$.

    Product: $0.5 \times 0.5 \times 1 \times 0.5 = $ 0.125. Official key: 0.125.

    A common slip is to read $P(Z{=}1\mid V{=}0, W{=}1) = 0$ from the wrong row, which gives 0.

    A DPL scouting network has four variables. Weather $W$ takes 3 values (sunny, cloudy, rainy) and has no parents. Pitch $P$ takes 3 values (flat, slow, green) with parent $W$. Toss $T$ is yes/no with no parents. Result $Y$ takes 3 values (win, loss, no result) with parents $P$ and $T$. How many independent numbers do the CPTs need, and how many does the full joint table need?

    A variable with $m$ values needs $m - 1$ free numbers per CPT row. The number of rows is the number of combinations of the parents’ values.

    $W$: one row, $3 - 1 = 2$. $P$: 3 rows (one per weather) × 2 = 6. $T$: 1. $Y$: $3 \times 2 = 6$ rows × 2 = 12. Total $2 + 6 + 1 + 12 = $ 21.

    Full joint: $3 \times 3 \times 2 \times 3 = 54$ combinations, minus 1 because they add to 1: 53.

    The tempting 32 counts every CPT entry, including the ones fixed by “each row adds to 1”; 54 forgets that same constraint for the full table.

    A network has edges $A \to C$, $B \to C$, $C \to D$ and $B \to E$.

    Which statements are guaranteed by the graph? (Select all that apply.)

    1. $A \perp B$
    2. $A \perp B \mid D$
    3. $A \perp E \mid B$
    4. $A \perp E \mid C$

    Every path between these pairs passes through $C$, which is a collider ($A \to C \leftarrow B$). Ask in each case: is $C$ or its descendant $D$ observed? Is the fork at $B$ observed?

    The only path from $A$ to $B$ is $A \to C \leftarrow B$; from $A$ to $E$ it is $A \to C \leftarrow B \to E$.

    (A) True: the collider $C$ is unobserved and so is its descendant $D$, so the path is blocked.

    (B) False: $D$ is a descendant of the collider $C$; observing it opens the collider.

    (C) True: twice blocked, by the unobserved collider $C$ and by the observed fork at $B$.

    (D) False: observing $C$ opens the collider, and the fork at $B$ is unobserved, so the whole path is open.

    Correct: A, C. The usual mistake is to treat observing $D$ as harmless because $D$ is not on the path; descendants of a collider count.

    In the match-day network, the analyst hears only that the first innings ended with a low score. How likely is it that the spinner was picked? Then they also learn it rained overnight. What is the new probability? (Round off to three decimal places.)

    $D$ and $F$ add up to 1 out of every sum, so only $R$, $S$ and $L$ matter. Use $P(r)\,P(s)\,P(L\mid r, s)$ for the four combinations of $r, s$.

    Products $P(r)P(s)P(L\mid r, s)$: $(R, S)$: $0.2 \times 0.6 \times 0.9 = 0.108$; $(R, \lnot S)$: $0.2 \times 0.4 \times 0.7 = 0.056$; $(\lnot R, S)$: $0.8 \times 0.6 \times 0.4 = 0.192$; $(\lnot R, \lnot S)$: $0.8 \times 0.4 \times 0.1 = 0.032$. They add to $P(L) = 0.388$.

    $P(S\mid L) = \dfrac{0.108 + 0.192}{0.388} = \dfrac{0.300}{0.388} \approx$ 0.773.

    Adding rain keeps only the first two products: $P(S\mid L, R) = \dfrac{0.108}{0.108 + 0.056} = \dfrac{0.108}{0.164} \approx$ 0.659.

    Rain explains part of the low score, so the spinner becomes less likely: explaining away. Answering 0.6 both times (the prior) treats $S$ and $R$ as independent even after the collider $L$ is observed.

    • Draw the graph first, straight from the factorisation if that is what you are given.
    • For a joint probability, take exactly one CPT entry per node, in the row matching its parents.
    • For an independence question, list every path and check each middle node: chain, fork or collider; observed or not.
    • Thinking observation always blocks. At a collider it does the opposite.
    • Forgetting that an observed descendant of a collider also opens it.
    • Counting both “yes” and “no” entries of a row as free numbers; each row adds to 1.
    1. A Bayesian network is a DAG plus one CPT per node, and P(x₁, …, xₙ) = Π P(xᵢ | parents(Xᵢ)).
    2. It needs about n·2ᵏ numbers (k = most parents) instead of 2ⁿ − 1 for the full joint.
    3. Chains and forks block when the middle is observed; colliders block until the middle or a descendant is observed (explaining away).

    Rain and the visitors’ spinner each make a low score more likely, and they happen independently. You learn the score was low and the spinner played. Compared with knowing only that the score was low, rain is now

    more likely
    Ask whether the spinner already accounts for the low score.
    exactly as likely as before
    They were independent before the score was known. Once the shared effect is observed, that changes.
    less likely
    The spinner already explains the low score, so rain is needed less: explaining away. With the DPL tables it drops from about 0.42 to 0.36.
    certain not to have happened
    A low score is still possible with both causes; the probability drops but stays positive.

    In a chain $A \to B \to C$, observing $B$

    makes $A$ and $C$ conditionally independent
    All the influence from $A$ to $C$ runs through $B$; once $B$ is known, $A$ adds nothing.
    makes $A$ and $C$ dependent when they were independent
    That is the collider pattern, not the chain.
    has no effect on the link between $A$ and $C$
    The only path between them runs through $B$.
    makes $A$ certain
    Observing $B$ updates $A$ but does not fix it.

    A yes/no node has three yes/no parents. How many numbers does its CPT need?

    3
    One row per combination of parent values, not one per parent.
    4
    Count the combinations of three yes/no parents.
    16
    Each row adds to 1, so only one number per row is free.
    8
    $2^3 = 8$ rows, one free number each.

    Inference: asking the network questions

    Inference means computing a probability such as $P(\text{rain}\mid\text{low score})$ from a network: exactly, by adding up the right products, or approximately, by simulating many match days.

    GATE DA 2025 Q26 asked which algorithms are exact and which approximate; the 2024 sample paper (Q32) asked for likelihood-weighting weights and the estimate they give.

    It’s like estimating how often it rains on match days with a delay: you can work it out from the tables, or you can look back over a thousand simulated seasons and count.

    Where it shows up in GATE DA

    Name the algorithm type (exact or approximate), or run one small step of likelihood weighting or enumeration by hand.

    2025 Q26 · exact vs approximate inferenceSample Q32 · likelihood weighting2024 Q64 · joint from CPTs
    Heat: most years, 1–2 marks

    An inference question has three kinds of variable. The query is what you want to know ($R$). The evidence is what you have observed ($L = \text{yes}$). Everything else is hidden ($S$, $D$, $F$): not asked about, not observed.

    Recall from Bayes’ theorem (Probability 2.2) that a conditional probability is a ratio: $P(R\mid L) = P(R, L)/P(L)$. In practice you compute $P(R, L)$ and $P(\lnot R, L)$, then divide each by their sum. This last step is called normalising, and it is often written with a constant $\alpha$: $P(R\mid L) = \alpha\,P(R, L)$.

    Exact inference by enumeration

    To find $P(Q\mid e)$:

    1. For each value $q$ of the query, add the joint probability $\prod_i P(x_i\mid\text{parents})$ over every combination of the hidden variables, with the evidence held at its observed values. This gives $P(q, e)$.
    2. Normalise: divide each $P(q, e)$ by their total, which is $P(e)$.

    It is exact, but with $n$ yes/no variables it can touch up to $2^n$ rows.

    In the match-day network, the score was low. What is the probability that it rained overnight, $P(R\mid L)$?

    1. Query $R$, evidence $L$, hidden $S, D, F$. Write $$P(R, L) = \sum_{s}\sum_{d}\sum_{f} P(R)\,P(s)\,P(L\mid R, s)\,P(d\mid R)\,P(f\mid L).$$

      Every full assignment is a product of one CPT entry per node; the hidden variables are summed out.

    2. The sums over $d$ and $f$ are each 1: $\sum_d P(d\mid R) = 0.7 + 0.3 = 1$ and $\sum_f P(f\mid L) = 0.6 + 0.4 = 1$. So $P(R, L) = P(R)\sum_s P(s)P(L\mid R, s)$.

      A hidden variable with no observed descendant, here $D$ and $F$, adds up to 1 and drops out. Spotting this saves most of the work.

    3. $P(R, L) = 0.2\,(0.6 \times 0.9 + 0.4 \times 0.7) = 0.2 \times 0.82 = 0.164$.
      $P(\lnot R, L) = 0.8\,(0.6 \times 0.4 + 0.4 \times 0.1) = 0.8 \times 0.28 = 0.224$.

      Same sum with $R$ set to no: the rows $P(L\mid\lnot R, s)$ of the CPT.

    4. Normalise: $P(R\mid L) = \dfrac{0.164}{0.164 + 0.224} = \dfrac{0.164}{0.388} \approx$ 0.423.

      The denominator 0.388 is $P(L)$. A low score more than doubles the chance of overnight rain, from 0.2.

    Variable elimination: enumeration without repeated work

    Enumeration recomputes the same pieces over and over. Variable elimination pushes each sum as far right as it can go, computes it once, and stores the result as a small table (a factor) for later use.

    Example: $P(F)$, the chance that fans leave early. Sum out the variables one at a time: $D$ drops out (it sums to 1), then $R$ and $S$ are summed into a factor over $L$: $$P(L) = \sum_{r, s} P(r)\,P(s)\,P(L\mid r, s) = 0.108 + 0.056 + 0.192 + 0.032 = 0.388.$$ Finally $L$ is summed out: $$P(F) = P(F\mid L)P(L) + P(F\mid\lnot L)P(\lnot L) = 0.6 \times 0.388 + 0.2 \times 0.612 = 0.3552.$$ Enumeration would have added 16 products of five factors each; elimination did four small products and one two-term sum.

    Start with one factor per CPT, with evidence values plugged in. For each hidden variable in some order: multiply together the factors that mention it, sum it out, and put the new factor back. Multiply what is left and normalise.

    The answer is exact, the same as enumeration, whatever the order. The order only changes how much work is done. It is used to compute conditional probabilities $P(Q\mid e)$ and marginals such as $P(F)$.

    Try it

    Tap a node to observe it (tap again for “no”, a third time to clear). The ringed node is the query. Start with evidence $L$ and query $R$: you should see 0.4227, the worked example. Now also observe $S$ and watch rain drop (explaining away). Then edit a table: drag $P(L\mid R, S)$ and see the answer move. The readout shows how many of the 32 joint rows enumeration had to add.

    Approximate inference: simulate and count

    Exact inference can still blow up on large, densely connected networks (in general it is NP-hard). The alternative is to sample: generate many random full assignments that follow the network’s probabilities, and estimate the answer as a fraction. More samples give a better estimate, but never a guaranteed exact one. That is what “approximate” means here.

    • Prior (direct) sampling. Visit the nodes parents-first. For each, toss a biased coin using its CPT row for the parent values already drawn. One pass gives one simulated match day. Example: draw $R$ with $P(R) = 0.2$; if $R$ came out yes, draw $D$ with $P(D\mid R) = 0.7$; and so on.
    • Rejection sampling. Draw prior samples and throw away every one that disagrees with the evidence. Estimate $P(Q\mid e)$ as the fraction of the kept samples with $Q$ = yes. The expected fraction kept is $P(e)$, so rare evidence wastes almost every sample.
    • Likelihood weighting. Never throw away. Fix each evidence variable at its observed value instead of drawing it, draw the others as in prior sampling, and give the sample a weight: the product of $P(e_i\mid\text{parents})$ over the evidence variables. Estimate $P(Q\mid e)$ as (total weight of samples with $Q$ = yes) ÷ (total weight).
    • Gibbs sampling (a Markov chain Monte Carlo method). Start from any full assignment that agrees with the evidence. Repeatedly pick a non-evidence variable and redraw it from its distribution given all the others, which only needs its Markov blanket: its parents, its children and its children’s other parents. Estimate by the fraction of steps with $Q$ = yes.
    MethodExact or approximateUses evidence by
    Enumerationexactfixing it in the sums
    Variable eliminationexactfixing it in the factors
    Rejection samplingapproximatediscarding samples that disagree
    Likelihood weightingapproximatefixing it and weighting each sample
    Gibbs samplingapproximateholding it fixed while the rest wander
    Try it

    Choose a question and a method, then press +100 a few times. The blue line is the running estimate; the dashed line is the exact answer from enumeration. Notice how the estimate wobbles early and settles as samples pile up. Then choose $P(L\mid R{=}\text{yes}, D{=}\text{no})$ with rejection sampling: that evidence has probability 0.06, so about 94 of every 100 samples are thrown away. Switch to likelihood weighting and see every sample count.

    GATE DA 2024 sample paper · Q32 · MCQ · 2 marks

    Consider the Bayes Net containing four Boolean random variables $(A, B, C, D)$, with the following convention: $A = True \Rightarrow A = a$, and $A = False \Rightarrow A = \lnot a$ and similarly for the other variables. The conditional probability tables for the nodes in the network are also indicated in the figure. The following samples were generated through likelihood weighting:

    $A$$P(A)$
    $a$1/5
    $\lnot a$4/5
    $A$$B$$P(B\mid A)$
    $a$$b$1/5
    $\lnot a$$b$1/2
    $a$$\lnot b$4/5
    $\lnot a$$\lnot b$1/2
    $B$$C$$P(C\mid B)$
    $b$$c$1/4
    $\lnot b$$c$3/4
    $b$$\lnot c$2/5
    $\lnot b$$\lnot c$3/5
    $B$$D$$P(D\mid B)$
    $b$$d$1/2
    $\lnot b$$d$4/5
    $b$$\lnot d$1/2
    $\lnot b$$\lnot d$1/5

    $s_1: (\lnot a, \lnot b, \lnot c, \lnot d)$; $s_2: (\lnot a, b, \lnot c, \lnot d)$; $s_3: (\lnot a, \lnot b, \lnot c, d)$; $s_4: (\lnot a, b, \lnot c, d)$

    Estimate the likelihood weight of each sample and thereby estimate $P(b\mid\lnot a, \lnot c)$

    1. $s_1: 0.48, s_2: 0.32, s_3: 0.48, s_4: 0.32, P(b\mid\lnot a, \lnot c) = 0.4$
    2. $s_1: 0.48, s_2: 0.32, s_3: 0.48, s_4: 0.32, P(b\mid\lnot a, \lnot c) = 0.64$
    3. $s_1: 0.32, s_2: 0.48, s_3: 0.48, s_4: 0.32, P(b\mid\lnot a, \lnot c) = 0.64$
    4. $s_1: 0.48, s_2: 0.32, s_3: 0.32, s_4: 0.32, P(b\mid\lnot a, \lnot c) = 0.4$

    (Figure and tables redrawn from the paper.)

    1. The evidence is $\lnot a$ and $\lnot c$ (both fixed in every sample). So each weight is $$w = P(\lnot a)\times P(\lnot c\mid B\text{'s sampled value}).$$

      Likelihood weighting multiplies in the probability of each evidence value given its parents. $A$ has no parents; $C$’s parent is $B$. $B$ and $D$ were sampled, so they contribute no factor.

    2. Samples with $\lnot b$ ($s_1$, $s_3$): $w = \tfrac45 \times \tfrac35 = 0.48$. Samples with $b$ ($s_2$, $s_4$): $w = \tfrac45 \times \tfrac25 = 0.32$.

      Read $P(\lnot c\mid\lnot b) = 3/5$ and $P(\lnot c\mid b) = 2/5$ from the $\lnot c$ rows of the third table. The value of $D$ does not matter.

    3. Estimate: $P(b\mid\lnot a, \lnot c) \approx \dfrac{w_2 + w_4}{w_1 + w_2 + w_3 + w_4} = \dfrac{0.64}{1.6} = $ 0.4. Answer (A). (Sample paper, no official key; this is our answer.)

      (B) reports 0.64, the weight of the $b$ samples without dividing by the total. (C) swaps the weights of $s_1$ and $s_2$; (D) gives $s_3$ the wrong weight although it has $\lnot b$ like $s_1$.

    4. Check by exact inference: $P(b\mid\lnot a, \lnot c) = \dfrac{\tfrac12 \times \tfrac25}{\tfrac12 \times \tfrac25 + \tfrac12 \times \tfrac35} = \dfrac{0.2}{0.5} = 0.4$. The four samples happen to match it exactly.

      One flaw in the printed table: its $P(C\mid B)$ rows do not add to 1 ($\tfrac14 + \tfrac25 \ne 1$ for $b$). Only the $\lnot c$ rows are needed, so the answer is unaffected.

    The analyst draws 1000 prior samples from the match-day network to estimate $P(R\mid L)$ by rejection sampling. 388 of the samples have $L$ = yes, and 160 of those also have $R$ = yes. How many samples are rejected, and what is the estimate? (Round off to three decimal places.)

    Rejection keeps only samples that agree with the evidence; the estimate is a fraction of the kept ones.

    Rejected: $1000 - 388 = 612$. Estimate: $160/388 \approx$ 0.412, close to the exact 0.423. Dividing by 1000 instead (0.16) estimates $P(R, L)$, not $P(R\mid L)$.

    Likelihood weighting in the match-day network with evidence $L$ = yes and $D$ = yes produces four samples whose $(R, S)$ values are $s_1 = (\text{yes}, \text{yes})$, $s_2 = (\text{no}, \text{yes})$, $s_3 = (\text{yes}, \text{no})$, $s_4 = (\text{no}, \text{no})$. ($F$ was sampled too.) Find the weight of $s_1$ and the estimate of $P(R\mid L, D)$. (Round off to two decimal places.)

    Weight = $P(L\mid R, S)\times P(D\mid R)$, using each sample’s own $R$ and $S$. $F$ is not evidence, so it adds no factor.

    Weights: $s_1$: $0.9 \times 0.7 = 0.63$; $s_2$: $0.4 \times 0.1 = 0.04$; $s_3$: $0.7 \times 0.7 = 0.49$; $s_4$: $0.1 \times 0.1 = 0.01$.

    Estimate: $\dfrac{0.63 + 0.49}{0.63 + 0.04 + 0.49 + 0.01} = \dfrac{1.12}{1.17} \approx$ 0.96.

    The exact answer is $41/49 \approx 0.84$. Four hand-picked samples, one of each kind, do not follow the network’s frequencies (rain is drawn only 20% of the time), so the estimate is off; with many samples it converges.

    Use variable elimination in the match-day network to find $P(L)$ and then $P(F)$. (Round off to four decimal places.)

    $D$ sums to 1 and drops out. Sum $R$ and $S$ out of $P(r)P(s)P(L\mid r, s)$, then use $P(F) = P(F\mid L)P(L) + P(F\mid\lnot L)P(\lnot L)$.

    $P(L) = 0.2 \times 0.6 \times 0.9 + 0.2 \times 0.4 \times 0.7 + 0.8 \times 0.6 \times 0.4 + 0.8 \times 0.4 \times 0.1 = 0.108 + 0.056 + 0.192 + 0.032 = 0.388$.

    $P(F) = 0.6 \times 0.388 + 0.2 \times 0.612 = 0.2328 + 0.1224 = 0.3552$.

    GATE DA 2025 · Q26 · MSQ · 1 mark

    Which of the following statements is/are correct in a Bayesian network?

    1. Variable elimination is an approximate inference algorithm
    2. Gibbs sampling is an exact inference algorithm
    3. Variable elimination is used to determine conditional probabilities
    4. Rejection sampling is an approximate inference algorithm

    Sort the methods: which ones add up products of CPT entries, and which ones count random samples?

    (A) False: variable elimination is exact; it is enumeration with the repeated work removed.

    (B) False: Gibbs sampling is a Markov chain Monte Carlo method; its estimate only approaches the answer as the number of steps grows.

    (C) True: it computes $P(Q, e)$ for each value of the query and normalises to get $P(Q\mid e)$.

    (D) True: it estimates from the fraction of kept samples.

    Correct: C, D. Official key: C; D.

    In the match-day network, a fan reports that people left early ($F$ = yes), and nothing else is known. What is the probability that it rained overnight? (Round off to three decimal places.)

    $F$ depends on $R$ only through $L$. First find $P(L\mid R)$ and $P(L\mid\lnot R)$ by summing out $S$, then $P(F\mid R)$ and $P(F\mid\lnot R)$ by summing out $L$, then apply Bayes.

    $P(L\mid R) = 0.6 \times 0.9 + 0.4 \times 0.7 = 0.82$; $P(L\mid\lnot R) = 0.6 \times 0.4 + 0.4 \times 0.1 = 0.28$.

    $P(F\mid R) = 0.82 \times 0.6 + 0.18 \times 0.2 = 0.528$; $P(F\mid\lnot R) = 0.28 \times 0.6 + 0.72 \times 0.2 = 0.312$.

    $P(R\mid F) = \dfrac{0.2 \times 0.528}{0.2 \times 0.528 + 0.8 \times 0.312} = \dfrac{0.1056}{0.3552} \approx$ 0.297.

    Tempting wrong answers: 0.2 (ignoring the evidence) and 0.423 (treating $F$ as if it were $L$; fans also leave early on 20% of normal-score days, which weakens the evidence). Note the denominator is $P(F) = 0.3552$, as in the variable-elimination practice problem.

    Which statements about inference in a Bayesian network are correct? (Select all that apply.)

    1. In rejection sampling with evidence $e$, the expected fraction of samples kept is $P(e)$.
    2. In likelihood weighting no sample is discarded, and a sample’s weight is the product of $P(e_i\mid\text{parents}(E_i))$ over the evidence variables $E_i$.
    3. In Gibbs sampling, a variable is redrawn from its distribution given its parents only.
    4. The probability computed by variable elimination depends on the order in which variables are eliminated.

    For (C), think about what a child’s observed value tells you about its parent. For (D), separate “how much work” from “what answer”.

    (A) True: each prior sample agrees with the evidence with probability $P(e)$.

    (B) True: that is the definition, and it is why likelihood weighting wastes nothing.

    (C) False: Gibbs conditions on the whole Markov blanket (parents, children and the children’s other parents). Using parents only would ignore observed children, the very evidence that should move the estimate.

    (D) False: every order gives the same exact answer; only the size of the intermediate factors, and so the running time, changes.

    Correct: A, B.

    Gibbs sampling runs on the match-day network with evidence $L$ = yes and $D$ = no. The current state is $R$ = yes, $S$ = yes, $F$ = yes. The sampler now redraws $R$. With what probability is $R$ set to yes? (Round off to three decimal places.)

    Redraw $R$ from $P(R\mid\text{everything else})$. Keep only the factors that mention $R$: $P(R)$, $P(L\mid R, S)$ and $P(\lnot D\mid R)$. $F$ is outside $R$’s Markov blanket.

    For $R$ = yes: $P(R)\,P(L\mid R, S)\,P(\lnot D\mid R) = 0.2 \times 0.9 \times 0.3 = 0.054$.

    For $R$ = no: $0.8 \times P(L\mid\lnot R, S) \times P(\lnot D\mid\lnot R) = 0.8 \times 0.4 \times 0.9 = 0.288$.

    Normalise: $\dfrac{0.054}{0.054 + 0.288} = \dfrac{0.054}{0.342} = \dfrac{3}{19} \approx$ 0.158.

    Leaving out $D$ gives $\frac{0.18}{0.18 + 0.32} = 0.36$, which is $P(R\mid L, S)$; answering 0.2 uses the prior alone. The current value of $R$ plays no part: Gibbs redraws it from scratch.

    • Name the query, the evidence and the hidden variables before computing.
    • Drop hidden variables that have no observed descendant: they sum to 1.
    • In likelihood weighting, multiply in a factor for every evidence variable, including root nodes such as $A$ in sample Q32.
    • Forgetting to normalise: $P(R, L)$ is not $P(R\mid L)$.
    • Calling variable elimination approximate, or Gibbs sampling exact.
    • In likelihood weighting, adding factors for sampled (non-evidence) variables.
    1. Enumeration: P(Q | e) = α Σ over hidden variables of Π P(xᵢ | parents); exact but exponential.
    2. Variable elimination is exact too; it sums variables out one at a time and reuses the results (factors).
    3. Sampling is approximate: rejection discards, likelihood weighting weights by P(evidence | parents), Gibbs redraws from the Markov blanket.

    The evidence “it rained, and the start was not delayed” has probability 0.06. Out of 10,000 prior samples, about how many survive rejection sampling?

    9,400
    That is the number thrown away.
    600
    Each sample agrees with the evidence with probability 0.06, so about $0.06 \times 10{,}000 = 600$ are kept.
    10,000
    Only samples that match the evidence are kept.
    60
    Recompute $0.06 \times 10{,}000$.

    Which of these inference methods is exact?

    Likelihood weighting
    It estimates from weighted random samples.
    Gibbs sampling
    It is a Markov chain Monte Carlo method; its estimate only approaches the answer.
    Variable elimination
    It adds up the same products as enumeration, just more cleverly.
    Rejection sampling
    It counts random samples that match the evidence.

    In likelihood weighting with evidence $D$ = yes in the match-day network, a sample draws $R$ = yes. Its weight is

    0.2
    $R$ was sampled, so $P(R)$ is not part of the weight.
    0.14
    That multiplies in $P(R)$, which belongs to a sampled variable.
    0.3
    The evidence is $D$ = yes, not $D$ = no.
    0.7
    The only evidence variable is $D$, so the weight is $P(D\mid R) = 0.7$.

    In the network $A \to B \leftarrow C$ with nothing observed, which pair is independent?

    $A$ and $C$
    The only path between them meets head-to-head at the unobserved collider $B$, so it is blocked.
    $A$ and $B$
    $B$ depends directly on $A$.
    $B$ and $C$
    $B$ depends directly on $C$.
    No pair
    Look at the collider: what happens there when nothing is observed?

    Ten yes/no variables, each with at most two parents. At most how many numbers do the CPTs need?

    20
    A node with two parents has four rows, not two.
    1023
    That is the full joint table, $2^{10} - 1$.
    40
    At most $2^2 = 4$ per node, times 10 nodes.
    100
    Count rows per node: $2^k$ for $k$ parents.

    $P(R\mid L) \approx 0.42$ but $P(R\mid L, S) = 0.36$, where rain $R$ and spinner $S$ are independent causes of a low score $L$. This drop is called

    the base-rate effect
    That is about ignoring a prior. Here a second cause is involved.
    explaining away
    One cause being confirmed makes the other less needed to explain the effect.
    the local Markov property
    That says a node is independent of its non-descendants given its parents.
    normalisation
    Normalising is dividing by the total; this question is about how the evidence interacts.

    Rejection sampling estimates $P(R\mid L)$ poorly when

    $L$ is very likely
    Then most samples are kept, which is the good case.
    the network has few nodes
    Size is not the issue for rejection sampling.
    $R$ has no parents
    Roots are easy to sample.
    $L$ is very unlikely
    Almost every sample is thrown away, so the estimate rests on very few kept samples.

    To compute $P(R\mid L)$ in the match-day network, which hidden variables can be dropped before summing?

    Only $S$
    $S$ is a parent of the evidence $L$; it must stay in the sum.
    $D$ and $F$
    Neither has an observed descendant, so each sums to 1.
    $S$, $D$ and $F$
    $S$ matters: it changes $P(L\mid R, S)$.
    None
    Some hidden variables sum to 1 and drop out.
    Every module complete

    Every question, answered right.

    You worked through every quiz and every practice problem in GATE Data Science & AI. That took real effort, and the understanding is yours to keep. Add your name to make a certificate.