Daylila
How AI actually works

Lesson 1 of 13

Rules versus examples

Explain why AI learns from examples instead of following written rules.

01 · Learn · the idea

Try to write down the exact rule for what makes a photo a photo of a cat. Not a vague description — a real rule, precise enough that a machine following it to the letter would never miss and never be wrong. Pointed ears? Foxes have those. Whiskers? So do seals. Fur, four legs, a tail, two eyes — you’ve just described a thousand animals. You know a cat the instant you see one. But you cannot write down the rule you’re using. That gap — between what you can do and what you can state — is the whole reason modern AI exists.

The old way: tell the computer the rules

For most of computing history, a program was a list of exact instructions a person wrote by hand. Do this, then this; if this is true, do that. It is a rulebook, followed to the letter.

This works beautifully when you can actually write the rules down. Payroll is arithmetic with clear steps. The legal moves of chess fit on a page. A tax form is a long “if this, then that.” For any task you can fully spell out, hand-written rules are perfect — precise, fast, and they never get tired.

The wall: some things you can do but can’t spell out

Then you hit tasks that refuse to be written down. Recognise a friend’s face across a noisy room. Tell a real email from junk. Understand what a sentence means. You perform these effortlessly, all day. But if you sit down to write the exact rules, you can’t — because there aren’t any tidy ones. Every rule you invent has a hole. Every hole needs another rule. The rulebook grows forever and still misses the next odd case.

This is the wall the old way could never climb. Not because the tasks are complicated in the way a tax form is complicated, but because the knowledge lives in your reflexes, not in words. You have the skill without having the rule.

The flip: show examples instead of writing rules

Here is the move that changed everything. If you can’t write the rule, don’t. Instead, gather thousands of examples where the answer is already known — this photo is a cat, that one isn’t — and hand them to the machine. Let it hunt through them and find the pattern on its own. It builds its own rough rule out of the examples, a rule nobody wrote and nobody could fully explain.

That is what “machine learning” means, under the fancy name. Not a computer told what to do. A computer shown what right looks like, many times, and left to work out the how. The examples are the teacher. The pattern it extracts is the lesson.

A worked example: catching spam

Picture a junk-mail filter, built two ways.

The rulebook way. You write a rule: block any message containing “free money”. It works for a day. Then the junk mail arrives spelling it “fr33 m0ney”, and your rule sees nothing wrong. So you add a rule for that. The next batch says “f-r-e-e m-o-n-e-y”. You add another rule. Meanwhile your rule for “free” has blocked a real email from a shop offering a free trial you actually wanted. You are losing, one patch at a time, forever.

The examples way. You gather ten thousand real messages, each already marked junk or not-junk, and let the machine study them. It doesn’t learn the word “free”. It learns the shape of junk — odd spellings, a breathless tone, a pushy link, a stranger asking for money — from how those things cluster in the marked pile. Now a message it has never seen, spelling it “fr33 m0ney”, still smells like junk, because it matches the shape. And the shop’s honest “free trial” doesn’t, because in ten thousand examples that shape sat in the not-junk pile. Nobody wrote a rule for “fr33”. The machine drew the line itself.

The examples way isn’t magic and it isn’t perfect — it can be fooled, and we’ll see exactly how later in the course. But it bends where the rulebook snaps. A hand-written rule matches only what it literally says. A pattern learned from examples stretches to cover cases it never met, because it captured the gist instead of the letter.

Why this is the whole game

Every headline you read about AI — a system that spots a tumour in a scan, finishes your sentence, drives a car, paints a picture — sits on top of this one idea. None of them were programmed with rules for the task. All of them were shown mountains of examples and left to find the pattern. The differences between them are differences of scale and plumbing, which the rest of this course unpacks. The core is what you just met.

It’s worth sitting with how strange this is. We built machines that are good at exactly the thing we can’t explain, by giving up on explaining it. The knowledge that runs the modern world’s AI isn’t written in anyone’s rulebook — it’s buried in the examples, dug out by a machine that cannot tell you what it found. That’s a real power and a real blind spot at the same time, and you are already living inside the results of it. The rest of this course is about seeing the machinery clearly enough to know which it is, and when.

02 · Try · the lab

03 · Check · quick quiz

1. Why is recognising a cat in a photo a bad fit for hand-written rules?

  • Computers are too slow to check every rule in time
  • You can do it instantly but can't state the exact rule you're using
  • There aren't enough cat photos to write rules from
  • Cats look too similar to each other to tell apart
Answer

You can do it instantly but can't state the exact rule you're using — The knowledge lives in your reflexes, not in words. Every rule you try (pointed ears, whiskers, fur) has a hole and matches other animals too. That's exactly the kind of task learning-from-examples was built for.

2. A spam filter trained on examples blocks 'fr33 m0ney' even though that exact spelling was never in its training set. How?

  • It memorised every spam message it might ever see
  • It secretly looks the message up in a database of known spam
  • It learned the shape of junk — odd spelling, urgency, a money ask — so a new message matching that shape still looks wrong
  • It blocks anything with numbers where letters should be
Answer

It learned the shape of junk — odd spelling, urgency, a money ask — so a new message matching that shape still looks wrong — It didn't learn the word 'free' or the string 'fr33'. It learned the pattern that junk tends to share, so a message it has never seen still matches the gist. A pattern stretches to new cases; a literal rule can't.

3. What is the core shift from traditional programming to machine learning?

  • You show the machine examples of the right answer instead of writing the rule yourself
  • The machine writes its own programming language
  • The computer becomes conscious enough to reason like a person
  • You use faster hardware so old rules run better
Answer

You show the machine examples of the right answer instead of writing the rule yourself — Traditional code is a rulebook a person writes. Machine learning flips it: you supply labelled examples of what right looks like, and the machine works out the pattern itself. It's shown what to do, not told how.