This lesson teaches how math helps us make smart choices, and how machines do the same thing

The Rainy Day Dilemma

You wake up, look outside, and see gray clouds. You ask yourself, “Should I bring an umbrella?”

You start thinking:

  • If it’s raining, bring an umbrella.
  • If it’s sunny, wear sunglasses.
  • If it’s cloudy but not raining, maybe bring a jacket.

That little decision tree you just made is based on logic — clear, rule-based thinking.
Computers use the same kind of logic when deciding what to do next.


What Is Logic?

Logic is the math of reasoning. It’s about using clear rules — “if this, then that” — to reach conclusions.

You probably use logic every day without realizing it:

  • If I study, then I’ll do better on the test.
  • If I forget my lunch, then I’ll be hungry.
  • If it’s Saturday, then there’s no school.

In math, these can be written as statements that are either true or false. Computers love that kind of clarity.

IF P, THEN Q (an implication, written PQP \rightarrow Q)

RulePQ
If I study, then I’ll do better on the testI studyI’ll do better on the test
If I forget my lunch, then I’ll be hungryI forget my lunchI’ll be hungry
If it’s Saturday, then there’s no schoolIt’s Saturdaythere’s no school

Say we want to confirm if a rule is true, then we want to back it up with data. We would take sample data from a class to prove that the rule is correct.

Rule 1

To test this rule, we can survey a class of students and tollies each possible outcome.

P (study)Q (do better)Count
True ✅True ✅40
True ✅False ❌10

If I study then I do better (on the test)

P (study)Q (do better)P → Q (rule)
True ✅True ✅True ✅
True ✅False ❌False ❌

Based on the sample data, if all students study, then 80% (=40/50 * 100%) of the time, a student would get a better grade on the test.


Try It Yourself — The Decision Game

Make your own mini decision system.
Write down three yes/no questions that lead to a result.

Example:

  1. Is it raining?
  2. Do you have an umbrella?
  3. If yes, bring it. If no, wear a raincoat.

You’ve just made a flowchart — a picture of logic in action.

You can make a fun version too:
“If it’s after dinner and there’s ice cream in the freezer, then get a spoon!”

Ice Cream Rule 1) 🍽️ Dinner is done ❌ NO 2) 🍨 Ice cream exists ❌ NO Result Not yet — check both.
The rule is: IF (🍽️ after dinner) AND (🍨 ice cream exists), THEN get a spoon 🥄.

Truth Tables

In logic, every statement can be true or false.
When you combine them, you can use and, or, and not to build more complex ideas.

For example:

  • A and B means both must be true.
  • A or B means at least one is true.
  • Not A flips it — true becomes false, and false becomes true.

These simple connectors let computers process millions of rules in seconds.

Truth Tables ✅ = true ❌ = false A B A AND B A OR B NOT A
AND is only ✅ when both are ✅. OR is ✅ if at least one is ✅. NOT flips ✅ ↔ ❌.

Thinking Like a Data Scientist

Every time a computer makes a decision, it’s following a chain of logical rules.

A self-driving car might think:

  • If the light is red and there’s a car in front, then stop.
  • If the light is green and the road is clear, then go.

A spam filter might think:

  • If the email has the word “prize” and unknown links, then mark as spam.
  • If it’s from a known contact, then allow.

Each choice is built from simple yes/no checks — just faster and on a bigger scale.


How This Connects to Machine Learning

Machine learning models often use logical patterns when making predictions.
One classic example is the decision tree — a structure that asks a series of yes/no questions to reach a conclusion.

For instance:

  • Is the animal furry?
  • Does it bark?
  • Then it’s probably a dog.

The computer doesn’t think like a human, but it mimics decision-making using clear logical steps.

Decision Tree (Yes/No Questions) Yes No Yes No Yes No Is the animal furry? ❌ No Does it bark? ❌ No Does it have fins? ❌ No 🐶 Dog 🐱 Cat 🐟 Fish 🦎 Other Prediction: —
A decision tree is a chain of yes/no questions. Your answers choose a path to a final label (a “prediction”).

Takeaway Message

Logic helps us turn choices into rules.
By breaking problems into small, clear steps, both people and machines can make decisions that make sense — every time.

Optional Extensions

  • Try drawing a decision tree for something you know well, like choosing what to wear, what snack to eat, or which game to play.Then, think about how a computer might make the same decision with yes/no rules.
  • Older students can explore online visual tools for building simple “if-then” programs or logic puzzles — they’re great practice for real-world coding and AI thinking.

By jess