Foundation of AI › Unit 2

Unit 2 of Foundation of AI covers how AI systems are actually built, in seven hours and without any programming. It has five parts: the basic structure of an AI system, three simplified architectures (rule-based systems, machine learning and neural networks), knowledge representation using symbols and facts, search and problem solving such as solving a maze or finding the shortest route, and natural language understanding as used by Google Translate and chatbots.

This is the unit students find hardest, and the reason is usually the same. The three architectures are memorised as three names instead of three different answers to one question: where do the rules come from? Keep that question in mind and the unit becomes straightforward.

1. The basic structure of an AI system

Every AI system, from a spam filter to a self-driving car, has the same five-stage skeleton. Click any stage to see what it does.

Anatomy of an AI systemClick any stage for what happens there and what goes wrong there

→

→

→

→

Input: raw data arrivesThe system takes in raw data: text typed by a user, an image from a camera, a stream of transactions, a sensor reading. Failures here are the most common cause of bad AI in practice, because a system fed the wrong data cannot be rescued by a better model.
Pre-processing: cleaning and structuringRaw data is cleaned, missing values are handled, formats are standardised and the data is converted into numbers the model can work with. This step routinely takes most of the effort in a real project, though it appears in no textbook diagram.
Knowledge or model: where the intelligence sitsEither a knowledge base of facts and rules, in a rule-based system, or a trained model whose parameters encode what was learned from data. This is the part people mean when they say “the AI”.
Reasoning or inference: producing an answerThe engine applies the rules, or the model applies its learned parameters, to this particular input and produces a conclusion: a classification, a prediction, a route, a sentence.
Output and feedback: the answer, and learning from itThe result is given to the user or acted on, and the outcome is compared with what actually happened. That difference is fed back to improve the model. Remove this loop and the system stops being AI.

The feedback loop at the end is what makes this an AI system rather than a pipeline. Output is compared against what actually happened, the difference is fed back, and the model adjusts. Remove that loop and you have ordinary software that happens to use statistics.

2. AI architectures, simplified

The syllabus lists three: rule-based systems, machine learning and neural networks. They are best understood as three answers to one question.

Where do the rules come from? In a rule-based system, a human expert writes them. In machine learning, the system derives them from labelled examples. In a neural network, the rules are not written anywhere at all; they exist as millions of numerical weights that nobody can read directly. That progression, from written to learned to unreadable, is the whole of this section.

Pick a problem and see which architecture fits

Which architecture would you use?Choose a real problem and see which approach fits, and why the others do not

Pick a problem above.

Rule-based systems

A rule-based system stores knowledge as explicit if-then rules written by a human expert, and an inference engine applies them to the facts it is given. If income is below a threshold and credit history is clean, then approve. If the patient has fever and a rash, then consider these three conditions.

Its great advantage is transparency. You can always trace exactly why the system reached a conclusion, which matters enormously in banking, insurance and medicine. Its fatal weakness is brittleness. Every new situation needs a new rule written by hand, rules start to contradict one another as they multiply, and the system fails completely on anything its author did not foresee. That weakness is what ended the expert-systems boom of the 1980s and pushed the field towards learning from data.

Machine learning

Machine learning inverts the approach. Instead of writing the rules, you provide labelled examples and the algorithm finds the pattern that separates them. Give it fifty thousand transactions labelled fraudulent or genuine, and it works out for itself which combinations of amount, time, location and device indicate fraud, including combinations no analyst would have thought to check.

The three basic kinds are worth knowing by name:

  • Supervised learning. Learns from labelled examples. Used for prediction and classification, such as spam detection or loan default prediction.
  • Unsupervised learning. Finds structure in unlabelled data, such as grouping customers into segments nobody defined in advance.
  • Reinforcement learning. Learns by trial and reward, as when a system learns to play a game or to route deliveries efficiently.

Neural networks

A neural network is loosely inspired by the brain. Simple units called neurons are arranged in layers. Each connection carries a weight, each neuron adds up what reaches it, applies a threshold, and passes the result forward. Learning means adjusting the weights, over and over, until the output matches the right answer often enough.

A signal moving through a neural networkWatch the layers activate one after another

Input layer takes the raw values, such as the pixels of an image. Each hidden layer combines them into progressively more abstract features: edges, then shapes, then objects. The output layer produces the answer. Nothing in the middle is labelled by a human, which is why a neural network is powerful and why it is hard to explain.

Basis Rule-based system Machine learning Neural network
Source of rules Written by a human expert Learned from labelled data Stored as numerical weights
Data needed None, but an expert is needed Moderate to large Very large
Explainability Complete. Every decision is traceable. Partial. Feature importance can be inspected. Poor. Often called a black box.
Handles new situations Badly. Fails outside its rules. Reasonably, if similar to training data Well, given enough training data
Best for Stable, regulated, well-understood domains Prediction from structured records Images, speech, language
Example Loan eligibility screening, tax rules Fraud detection, churn prediction Face unlock, translation, chatbots

3. Knowledge representation

Before a machine can reason, the facts have to be written in a form it can work with. Knowledge representation is the study of how to do that.

Knowledge representation is the method of encoding facts, objects, relationships and rules about the world in a structured form that a machine can store and reason over.

The syllabus mentions symbols and facts. The four standard methods are:

Method How it works Example
Logical representation Facts and rules written in formal logic, with strict inference If Human(x) then Mortal(x). Human(Socrates). Therefore Mortal(Socrates).
Semantic network A graph of concepts joined by labelled relationships Sparrow → is-a → Bird → can → Fly
Frames A record of slots and values describing one object Car: wheels = 4, fuel = petrol, owner = Ramesh
Production rules If-then pairs, as used in expert systems If temperature above 38 then flag fever

Semantic networks are the ones examiners ask you to draw, so practise one. The classic exam example is a small network around a bird: Sparrow is-a Bird, Bird has Wings, Bird can Fly, Penguin is-a Bird, Penguin cannot Fly. That last node is the interesting one, because it is exactly where simple inheritance breaks and why knowledge representation is a research field rather than a filing exercise.

4. Search and problem solving

Many AI problems reduce to the same shape: you are in some state, you want to reach a goal state, and you must find a sequence of moves that gets you there. Solving a maze is this. Finding the shortest route across a city is this. Planning a delivery schedule is this.

State space search means representing the problem as a set of possible states connected by legal moves, then searching that space systematically for a path from the start state to the goal state.

Run the two basic strategies below on the same maze and watch the difference. This is the syllabus’s maze example, made watchable.

Maze search visualiser: BFS versus DFSGreen is the start, red is the goal, blue is explored, amber is the final path


Strategy: noneCells explored: 0Path length: 0

Watch what happens. Breadth-first search spreads outward evenly and always finds the shortest path, but explores a great many cells to do it. Depth-first search commits to one direction and follows it to the end, which can be much faster or much slower, and the path it finds is usually not the shortest. This trade-off between guarantee and cost is the heart of the topic.

Basis Breadth-first search (BFS) Depth-first search (DFS)
Order of exploration All neighbours at one distance before going deeper One branch as deep as possible, then backtracks
Shortest path Guaranteed, when all moves cost the same Not guaranteed
Memory High. Holds an entire frontier. Low. Holds one path.
Risk Runs out of memory on large spaces Can go down an endless branch and never return
Good for Shortest route, fewest moves Puzzles where any solution will do, and memory is tight

Real navigation systems use a smarter method called A-star, which is breadth-first search plus an estimate of how far the goal still is, so it explores in roughly the right direction instead of evenly in all directions. That is how Google Maps searches a road network of millions of junctions in a fraction of a second.

Two further tools on this site go deeper into this topic: the AI search algorithms visualiser for a fuller comparison of search strategies, and the Minimax and alpha-beta pruning visualiser for how a machine searches ahead in a game where an opponent is also choosing moves.

5. Natural language understanding

Natural language understanding, or NLU, is the part of AI concerned with getting from words to meaning. It is a subset of the wider field of natural language processing, which also covers generating language.

When you type “book me a cab to the airport at 6”, the system performs several steps in sequence: it splits the sentence into tokens, identifies the parts of speech, recognises named entities (the airport, the time), classifies your intent as booking a ride, extracts the slots the booking needs, and resolves ambiguity. That last step is where the difficulty lives. “Book” is a verb here and a noun elsewhere. Human readers resolve this without noticing; machines need context to do it.

Google Translate, and why it got suddenly better

Early machine translation worked phrase by phrase from bilingual dictionaries and rules, which is why it produced sentences that were technically correct and unmistakably wrong. Modern translation encodes the entire sentence into a numerical representation of its meaning, then generates the sentence afresh in the target language. This is why quality jumped so sharply, and why translation between Indian languages, which have far less training data than European ones, is still noticeably weaker.

Chatbots

A chatbot applies NLU to classify your message into an intent, extract the details it needs, and either answer from a knowledge base or generate a response. A rule-based chatbot matches keywords and fails on anything phrased unexpectedly. A modern language-model chatbot handles phrasing well but can state something false with complete confidence, which is the failure mode Unit 4 examines.

Model exam answers

Differentiate between a rule-based system and machine learning (5 marks)

A rule-based system stores knowledge as if-then rules written in advance by a human expert, and applies them through an inference engine. Machine learning derives its rules from labelled data instead of being given them. The differences are: source of knowledge, expert versus data; data requirement, none versus substantial; explainability, fully traceable versus partial; handling of new cases, fails outside its rules versus generalises to similar cases; and maintenance, every new case needs a new rule versus retraining on new data. A rule-based system suits stable regulated domains such as tax computation; machine learning suits prediction from large records, such as detecting fraudulent UPI transactions.

Explain state space search with an example (7 marks)

State space search represents a problem as a set of possible states connected by legal moves, and searches for a path from the initial state to a goal state. Its four components are the initial state, the set of possible actions, the transition model that says which action leads to which state, and the goal test.

Consider a maze. Every square is a state; the initial state is the entrance; legal actions are moving up, down, left or right into a square that is not a wall; the goal test is whether the current square is the exit. Breadth-first search examines all squares one step away, then all squares two steps away, and so on, and therefore always finds the shortest path, at the cost of holding a large frontier in memory. Depth-first search follows one corridor to its end before backtracking, using little memory but giving no guarantee of the shortest path. Practical navigation systems use A-star search, which adds an estimate of the remaining distance so that exploration is directed towards the goal.

Practice questions

Unit 2 MCQ practice10 questions with explanations

Frequently asked questions

What is the difference between AI, machine learning and neural networks?

AI is the broad goal of building systems that perform tasks requiring intelligence. Machine learning is one approach to reaching it, in which the system learns rules from data rather than being given them. A neural network is one technique within machine learning, using layers of simple units whose connection weights are adjusted during training. They are nested, not parallel.

Which is better, BFS or DFS?

Neither is better in general; they trade different things. BFS guarantees the shortest path when all moves cost the same, but holds a large frontier in memory. DFS uses very little memory and can reach a deep solution quickly, but gives no guarantee of the shortest path and can get stuck exploring a long fruitless branch. Choose BFS when the shortest path matters, DFS when memory is limited and any valid solution will do.

Why are neural networks called black boxes?

Because their knowledge is stored as millions of numerical weights rather than as readable rules. You can see the input and the output, and you can measure how accurate the system is, but you cannot point to the place inside it where a particular decision was made. This is why explainability is a live issue in banking, hiring and healthcare, and it is discussed again in Unit 4 under responsible AI.

What is the difference between NLP and NLU?

Natural language processing is the whole field of making machines work with human language, including generating it. Natural language understanding is the part concerned with extracting meaning from language: identifying intent, entities and relationships. NLU is a subset of NLP.

Written by Piyush Wairale, M.Tech, IIT Madras, founder of PiyushAI Edtech. Last reviewed 22 September 2026.