Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Certified Tripo AI Expert ยท Lesson 3 of 8

Module Two

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
3
Module 2 ยท Certified Tripo AI Specialist โ€“ Logic & Rules

๐Ÿง  Module Two ยท How Computers Think โ€“ Logic and Rules

Certified Tripo AI Specialist ยท The Foundation of Intelligence

๐Ÿ“– Module Introduction

Hello again, young thinker! ๐Ÿ‘‹ In Module One, we learned what AI is and why it's important. Now we're going to look under the hood and see how computers think.

You might think computers are super smart and mysterious. But really, they are very simple. They just follow rules. If you give a computer the right rules, it can do amazing things.

Think about a traffic light. It follows a very simple rule: "If it's time to stop, turn red. If it's time to go, turn green." That's it! But when many simple rules work together, they create something powerful.

In this module, we will learn about logic โ€” the science of true and false. We'll learn how computers make decisions using rules. We'll also explore how AI uses logic to think. By the end, you'll understand the basic building blocks of all computer thinking!

๐Ÿ’ก Fun fact: The word "logic" comes from the Greek word "logos" which means "reason". Computers are masters of reason โ€” they just follow the rules!

๐ŸŽฏ Learning Objectives

By the end of this module, you will be able to:

  • โœ”๏ธ Understand what logic is and why it's important.
  • โœ”๏ธ Explain what true and false mean in computing.
  • โœ”๏ธ Use if-then rules to make decisions.
  • โœ”๏ธ Understand AND, OR, and NOT logic gates.
  • โœ”๏ธ Build simple decision trees using rules.
  • โœ”๏ธ Understand how AI uses rules to make decisions.
  • โœ”๏ธ Create your own rule-based system.

๐Ÿ“š Warm-up Story ยท The Royal Guard

Imagine you are a royal guard at a castle. Your job is to decide who can enter the castle. You have rules to follow:

  • If someone has a royal invitation, they can enter.
  • If someone is the queen, they can enter.
  • If someone is a knight, they can enter.
  • If someone is a thief, they cannot enter.

When someone comes to the gate, you check: do they have an invitation? Are they the queen? Are they a knight? Are they a thief? You use your rules to decide "yes" or "no".

Computers work exactly the same way. They have rules, and they check each rule to decide what to do. In this module, we'll learn how to write these rules so computers can make decisions just like the royal guard!

   +------------------+
   |  Who is at the   |
   |  gate?           |
   +--------+---------+
            |
            V
   +--------+---------+
   |  Check rules:    |
   |  - Invitation?   |
   |  - Queen?        |
   |  - Knight?       |
   |  - Thief?        |
   +--------+---------+
            |
            V
   +--------+---------+
   |  Decision:       |
   |  Enter or Stay?  |
   +------------------+
  

๐Ÿงฉ Main Lessons

Lesson 1 ยท What is Logic?

Definition: Logic is a way of thinking that uses rules to decide if something is true or false. It helps us reason and make decisions.

Why important: Computers use logic for everything. Without logic, a computer wouldn't know what to do.

Simple explanation: Logic is like a set of rules for thinking. It helps you decide: "Is this true? Is that true? What should I do next?"

Real-life example: When you play a game, you use logic: "If I move here, will I win?"

School example: In math, you use logic: "If 2 + 2 = 4, then 4 + 4 = 8."

Home example: "If the fridge is empty, we need to go shopping."

Nigerian example: "If the rain comes, I will take my umbrella."

Illustration:

   +------------------+      +------------------+      +------------------+
   |  Fact 1          |      |  Logic           |      |  Conclusion      |
   |  "It is raining" | ---> |  (rule: if rain, | ---> |  "Take umbrella" |
   +------------------+      |   take umbrella) |      +------------------+
                            +------------------+
  
๐Ÿ“Œ Mini summary: Logic is the science of reasoning. It uses rules to decide what is true and what to do.

Lesson 2 ยท True and False โ€“ The Two Answers

Definition: In computing, every question has only two possible answers: True (yes, correct) or False (no, incorrect).

Why important: Computers are simple machines. They can only handle two answers. Everything they do is based on true or false.

Simple explanation: It's like a light switch. It's either ON (true) or OFF (false). There's no in-between.

Real-life example: "Is it raining?" โ†’ True or False.

School example: "Is 5 greater than 3?" โ†’ True.

Home example: "Is the door locked?" โ†’ True or False.

Nigerian example: "Is Lagos in Nigeria?" โ†’ True.

Illustration:

   +------------------+
   |  Question: Is it |
   |  raining?        |
   +--------+---------+
            |
     +------+------+
     |             |
    YES          NO
  (True)       (False)
     |             |
     V             V
  Take umbrella  No umbrella
  
๐Ÿ“Œ Mini summary: Computers use only two answers: True and False. Everything is based on these two answers.

Lesson 3 ยท If-Then Rules โ€“ The Basic Decision

Definition: An if-then rule says: "IF something is true, THEN do something."

Why important: This is the most basic way computers make decisions. All decision-making in computers starts with if-then rules.

Simple explanation: It's like a promise: "If it rains, then I will take an umbrella."

Real-life example: If the traffic light is red, then stop. If it's green, then go.

School example: If you finish your homework, then you can play.

Home example: If the food is ready, then we eat.

Nigerian example: If the price of yam is cheap, then buy more.

Illustration:

   +------------------+
   |  IF condition    |
   |  (is it true?)   |
   +--------+---------+
            |
     +------+------+
     |             |
    True         False
     |             |
     V             V
  THEN do this   Do something
  (action)        else
  
๐Ÿ“Œ Mini summary: If-then rules are the building blocks of all computer decisions.

Lesson 4 ยท AND, OR, NOT โ€“ Combining Rules

Definition: AND, OR, and NOT are ways to combine true/false statements to make more complex rules.

Why important: Real decisions often need more than one condition. These tools let us build complex rules.

Simple explanation: AND = both must be true. OR = at least one must be true. NOT = the opposite.

Real-life example: "If it's raining AND I have an umbrella, I will go out." (Both must be true)

School example: "If you finish your homework AND clean your room, you can watch TV."

Home example: "If it's cold OR it's raining, stay inside." (Either one is enough)

Nigerian example: "If the market is open AND you have money, buy food."

Illustration:

   AND:   True AND True   = True
          True AND False  = False
          False AND True  = False
          False AND False = False

   OR:    True OR True    = True
          True OR False   = True
          False OR True   = True
          False OR False  = False

   NOT:   NOT True  = False
          NOT False = True
  
๐Ÿ“Œ Mini summary: AND, OR, and NOT let us combine conditions to make more powerful rules.

Lesson 5 ยท If-Then-Else โ€“ Two Paths

Definition: If-Then-Else means: "IF something is true, THEN do this. ELSE (otherwise) do something else."

Why important: This gives computers two choices, which is useful for most real-world decisions.

Simple explanation: It's like a fork in the road. One path if true, another path if false.

Real-life example: If you have money, buy food. Else, go home.

School example: If you pass the test, you go to the next grade. Else, you repeat.

Home example: If the laundry is clean, fold it. Else, wash it.

Nigerian example: If the bus comes, board it. Else, wait.

Illustration:

   +------------------+
   |  IF condition    |
   +--------+---------+
            |
     +------+------+
     |             |
    True         False
     |             |
     V             V
  Do this     Do that
  
๐Ÿ“Œ Mini summary: If-Then-Else lets computers choose between two paths.

Lesson 6 ยท Decision Trees โ€“ Many Choices

Definition: A decision tree is a series of if-then rules arranged like a tree. Each question leads to another question until a decision is reached.

Why important: This is how AI makes complex decisions. It's like a flowchart that asks questions until it reaches an answer.

Simple explanation: It's like a game of "20 Questions" โ€” you ask questions until you guess the answer.

Real-life example: A doctor's decision tree: "Is the patient coughing?" โ†’ "Is there a fever?" โ†’ Diagnosis.

School example: A decision tree for choosing a sport: "Do you like teams?" โ†’ Yes/No โ†’ recommendations.

Home example: "What to wear today?" โ†’ Is it cold? โ†’ Is it raining? โ†’ Outfit.

Nigerian example: A decision tree for choosing a market: "Do you want cheap goods?" โ†’ "Is it far?" โ†’ Market choice.

Illustration:

   +------------------+
   |  Is it raining?  |
   +--------+---------+
            |
     +------+------+
     |             |
    Yes           No
     |             |
     V             V
   Take         Is it hot?
   umbrella       /    \
                Yes    No
                 |      |
                 V      V
             Wear    Wear
             shorts  pants
  
๐Ÿ“Œ Mini summary: Decision trees are chains of if-then rules that lead to a final decision.

Lesson 7 ยท Rules vs Learning โ€“ Two Ways to Make AI

Definition: There are two ways to make AI: Rule-based (you write all the rules) and Learning-based (the computer learns the rules).

Why important: Understanding both helps you choose the right approach for each problem.

Simple explanation: Rule-based is like giving a friend a map. Learning-based is like letting them explore until they know the way.

Real-life example: A simple calculator uses rules. A self-driving car learns.

School example: A spelling checker uses rules. A handwriting recognizer learns.

Home example: A timer uses rules. A smart thermostat learns.

Nigerian example: A price calculator uses rules. A crop predictor learns from data.

Illustration:

   +------------------+      +------------------+
   |  Rule-based AI   |      |  Learning-based  |
   |  (you write      |      |  AI (computer    |
   |   the rules)     |      |   learns rules)  |
   +------------------+      +------------------+
   | - You know rules |      | - Computer finds |
   | - Easy to fix    |      |   rules by itself|
   | - Limited        |      | - Can improve    |
   +------------------+      +------------------+
  
๐Ÿ“Œ Mini summary: Rule-based AI uses rules you write. Learning-based AI discovers rules from data.

Lesson 8 ยท How to Build a Rule-Based System

Let's build a simple rule-based system step by step.

Example: A system that helps you decide what to eat.

   Rule 1: IF it's morning THEN eat breakfast
   Rule 2: IF it's afternoon THEN eat lunch
   Rule 3: IF it's evening THEN eat dinner
   Rule 4: IF you are hungry AND it's not time to eat THEN have a snack
  

We can write these rules in a simple way and let the computer follow them.

๐Ÿ“Œ Mini summary: Rule-based systems are built by writing clear if-then rules.

Lesson 9 ยท Building a Simple Decision Tree

Let's build a decision tree for choosing a game to play.

   Question 1: Do you want to play alone or with friends?
   - If alone: Play a video game.
   - If with friends:
        Question 2: Do you want to play inside or outside?
        - If inside: Play board games.
        - If outside: Play football.
  

This is how decision trees work โ€” each answer leads to another question until a final choice.

๐Ÿ“Œ Mini summary: Decision trees help choose by asking questions and following branches.

Lesson 10 ยท Logic in AI โ€“ Real-World Examples

AI uses logic everywhere. Here are some real-world examples:

  • Medical diagnosis: IF patient has symptoms A, B, C THEN diagnose disease X.
  • Credit approval: IF credit score > 700 AND income > 50,000 THEN approve loan.
  • Email filtering: IF email contains "free" AND "money" THEN mark as spam.
  • Traffic management: IF traffic is heavy AND time is peak hour THEN adjust lights.
๐Ÿ“Œ Mini summary: AI uses logic in medicine, banking, email filtering, traffic, and many other fields.

Lesson 11 ยท The Limits of Rule-Based Systems

Rule-based systems are great, but they have limits:

  • Too many rules: For complex problems, you might need millions of rules.
  • Can't handle new situations: If something new happens, you need to write a new rule.
  • Hard to maintain: When rules change, you need to update many things.

This is why many AI systems use learning instead of rules. But rules are still important, especially for simple, well-defined problems.

๐Ÿ“Œ Mini summary: Rule-based systems are simple and reliable, but they can become too complex for big problems.

Lesson 12 ยท Putting It All Together โ€“ A Complete Rule System

Let's build a complete rule system for a smart alarm clock.

   Rules:
   1. IF it's 6 AM AND it's Monday THEN play loud music.
   2. IF it's 6 AM AND it's Saturday THEN play soft music.
   3. IF it's 6 AM AND it's Sunday THEN don't play music.
   4. IF the weather is rainy AND it's 6 AM THEN play calm music.
   5. IF the weather is sunny AND it's 6 AM THEN play energetic music.
  

This alarm clock uses rules to decide what music to play. It's a real AI system!

๐Ÿ“Œ Mini summary: We combined many rules to build a smart system that can handle different situations.

๐Ÿ“– Key Vocabulary

  • Logic: The science of reasoning and rules.
  • True: Correct, yes.
  • False: Incorrect, no.
  • If-then rule: A rule that says: IF something is true, THEN do something.
  • AND: Both conditions must be true.
  • OR: At least one condition must be true.
  • NOT: The opposite.
  • Decision tree: A series of questions that lead to a decision.
  • Rule-based system: A system that uses rules to make decisions.

๐Ÿง  Important Concepts

  • Computers are simple: They only understand true and false.
  • Rules are power: With the right rules, computers can do amazing things.
  • AND/OR/NOT: These let us build complex rules.
  • Decision trees: A common way to organize rules.
  • Rules vs Learning: Both are important in AI.

๐Ÿ“˜ Step-by-Step Explanations

How to build a rule-based system:

  1. Identify the problem you want to solve.
  2. Think about all the possible situations.
  3. Write rules for each situation (IF condition THEN action).
  4. Organize the rules in a clear way.
  5. Test the rules with different inputs.
  6. Fix any problems you find.
  7. Add more rules as needed.

๐ŸŒ Real-life Examples

  • Traffic lights use rules to control traffic.
  • Thermostats use rules to control temperature.
  • Banking systems use rules to detect fraud.
  • Email filters use rules to sort messages.

๐Ÿ‡ณ๐Ÿ‡ฌ Nigerian Examples

  • Rule-based systems for predicting crop planting times.
  • Rules for determining market prices based on supply and demand.
  • Rules for traffic light timing in busy Lagos intersections.
  • Rules for health screening based on symptoms.

๐ŸŽˆ Fun Examples

  • Rules for choosing a video game: IF you like adventure AND you have time THEN play RPG.
  • Rules for what to wear: IF it's hot AND you're going outside THEN wear shorts.
  • Rules for what to eat: IF it's morning AND you're hungry THEN eat breakfast.

๐Ÿ  Everyday Examples

  • Rules for when to wake up: IF it's a weekday THEN wake at 6 AM.
  • Rules for what to watch: IF you're tired THEN watch something funny.
  • Rules for what to buy: IF it's on sale AND you need it THEN buy it.

๐Ÿง‘โ€๐Ÿซ Teacher Notes

Use lots of examples. Let students create their own rules for everyday situations. Use games and activities to teach logic. Show how simple rules combine to create complex behavior. Emphasize that logic is the foundation of all computing.

๐Ÿ‘ช Parent Tips

Practice logic at home. Play "20 Questions" to teach decision trees. Create simple rules for chores. Ask your child to explain the rules behind everyday devices. Celebrate when they create their own rule systems.

๐ŸŒŸ Interesting Facts

  • The ancient Greeks invented formal logic over 2,000 years ago.
  • Computers are based on logic gates invented by George Boole.
  • Your phone uses millions of logic gates to work.
  • AI systems can use millions of rules to make decisions.

๐Ÿค” Did You Know?

The first computers were mechanical and used physical switches (like traffic lights) to represent true and false. Today, your phone contains billions of tiny electronic switches!

๐Ÿงพ Remember This

  • Computers use true/false for everything.
  • If-then rules are the most basic way to make decisions.
  • AND, OR, NOT help combine rules.
  • Decision trees chain rules together.
  • Rule-based systems are simple and reliable.

โš ๏ธ Common Mistakes

  • Thinking computers are smarter than they are โ€” they just follow rules.
  • Writing rules that conflict with each other.
  • Forgetting to handle all possible cases.
  • Making rules too complex โ€” keep them simple.

โœ… Best Practices

  • Keep rules simple and clear.
  • Test rules with many examples.
  • Organize rules in a logical order.
  • Document your rules so others can understand them.
  • Add new rules gradually and test each one.

๐Ÿ“Š ASCII Illustrations

   Logic Flow:
   Input โ†’ Check Rules โ†’ Make Decision โ†’ Output

   Example:
   Is it raining? โ†’ Yes โ†’ Take umbrella.
   Is it raining? โ†’ No โ†’ No umbrella.
  
   Decision Tree:
        +------------------+
        |  Do you want     |
        |  something sweet?|
        +--------+---------+
                 |
          +------+------+
          |             |
         Yes           No
          |             |
          V             V
        +---+        +---+
        |   |        |   |
        V   V        V   V
     Cake  Candy   Fruits  Nuts
  

๐Ÿ“‹ Comparison Table

Logic TypeMeaningExample
ANDBoth must be trueraining AND windy
ORAt least one trueraining OR cold
NOTThe oppositeNOT raining

๐Ÿ“Œ End-of-Module Summary

You've completed Module Two! You now understand how computers think using logic and rules. You learned about true/false, if-then rules, AND/OR/NOT, and decision trees. You can now create simple rule-based systems. These are the building blocks of all AI. You're ready to learn how computers learn from examples in Module Three!

โ“ Frequently Asked Questions (10)

  1. What is logic? โ€” The science of reasoning with rules.
  2. What is true? โ€” Yes, correct.
  3. What is false? โ€” No, incorrect.
  4. What is an if-then rule? โ€” IF something is true, THEN do something.
  5. What is AND? โ€” Both conditions must be true.
  6. What is OR? โ€” At least one condition must be true.
  7. What is NOT? โ€” The opposite.
  8. What is a decision tree? โ€” A chain of questions to reach a decision.
  9. What is a rule-based system? โ€” A system that uses rules to decide.
  10. Why are rules important? โ€” They let computers make decisions.

๐Ÿ“ Review Questions (15)

  1. What is logic?
  2. What are the two answers a computer uses?
  3. What is an if-then rule?
  4. Give an example of an if-then rule at home.
  5. What does AND do?
  6. What does OR do?
  7. What does NOT do?
  8. What is a decision tree?
  9. Draw a simple decision tree.
  10. What is a rule-based system?
  11. Give an example of a rule-based system in real life.
  12. What is the difference between rule-based and learning-based AI?
  13. Why are rules important for computers?
  14. What happens if rules conflict?
  15. How can you make rules better?

โœ๏ธ Fill-in-the-Blank

  1. ______ is the science of reasoning.
  2. A computer only understands ______ and ______.
  3. An ______ rule says: IF something is true, THEN do something.
  4. ______ means both conditions must be true.
  5. A ______ tree is a chain of questions.

โœ… True or False

  1. Computers can only understand true and false. (True)
  2. AND means at least one condition is true. (False)
  3. OR means both conditions must be true. (False)
  4. NOT means the opposite. (True)
  5. Decision trees are used in AI. (True)

๐Ÿ”˜ Multiple Choice (15)

  1. What is logic? A) Science of reasoning B) Math C) Art D) Music โ†’ A
  2. What are the two answers in computing? A) True/False B) Yes/Maybe C) Right/Wrong D) On/Off โ†’ A
  3. What is an if-then rule? A) IF condition THEN action B) IF condition OR action C) IF condition AND action D) IF action THEN condition โ†’ A
  4. What does AND mean? A) Both true B) One true C) Opposite D) Neither โ†’ A
  5. What does OR mean? A) At least one true B) Both true C) Opposite D) Neither โ†’ A
  6. What does NOT mean? A) Opposite B) Same C) Both D) Neither โ†’ A
  7. What is a decision tree? A) Chain of questions B) A tree C) A rule D) A number โ†’ A
  8. What is a rule-based system? A) Uses rules to decide B) Learns from data C) Uses pictures D) Uses sound โ†’ A
  9. Which is an example of a rule? A) IF raining THEN take umbrella B) 2 + 2 = 4 C) Blue is a color D) Trees are tall โ†’ A
  10. Which combines conditions? A) AND B) True C) False D) Rule โ†’ A
  11. What does NOT True equal? A) False B) True C) Maybe D) Unknown โ†’ A
  12. What does AND True True equal? A) True B) False C) Maybe D) Unknown โ†’ A
  13. What does OR False False equal? A) False B) True C) Maybe D) Unknown โ†’ A
  14. Why are rules important? A) They help decide B) They are not important C) They slow things down D) They confuse computers โ†’ A
  15. What is the first step in building a rule system? A) Identify the problem B) Write rules C) Test rules D) Fix problems โ†’ A

๐Ÿ”— Matching

TermMatch
1. ANDA. The opposite
2. ORB. Both must be true
3. NOTC. At least one true

Answers: 1-B, 2-C, 3-A

๐Ÿ“ Short Answer

  1. Explain the difference between AND and OR.
  2. What is a decision tree and how does it work?
  3. Write a rule for deciding what to wear in the morning.

๐Ÿ“– Scenario-based Exercises

Scenario: You are building a system for a library. It needs to decide if someone can borrow a book. Write rules for this system.

Answer: 1) IF member has no overdue books THEN can borrow. 2) IF member has overdue books AND has paid fine THEN can borrow. 3) IF member has overdue books AND has not paid fine THEN cannot borrow.

๐Ÿ‘ฅ Group Activity

In groups of 3-4, create a decision tree for choosing a lunch option. Ask questions like: "Do you want something hot?" "Do you want rice?" etc. Present your tree.

๐Ÿง‘โ€๐Ÿ’ป Individual Activity

Write 10 if-then rules for a "smart home" system. Include rules for lights, temperature, security, and entertainment.

๐Ÿ’ฌ Classroom Discussion Questions

  • Why do computers need rules?
  • What happens if a rule is wrong?
  • How can we make rules fair?
  • What's better: rules or learning?

๐Ÿ› ๏ธ Mini Project

Build a rule-based system for a "movie recommender". Write rules that suggest a movie based on genre, age rating, and mood.

๐Ÿ“‹ Practical Assignment

Create a decision tree for a "restaurant recommender". Include questions about budget, cuisine type, and location.

๐Ÿ† Challenge Exercise

Write a set of rules for a "smart garden" system that decides when to water plants. Include rules for temperature, soil moisture, and time of day.

๐Ÿ”‘ Quiz Answers

Multiple choice answers: 1-A, 2-A, 3-A, 4-A, 5-A, 6-A, 7-A, 8-A, 9-A, 10-A, 11-A, 12-A, 13-A, 14-A, 15-A.

๐ŸŽ Key Takeaways

  • Computers use true/false for everything.
  • If-then rules are the most basic way to make decisions.
  • AND, OR, NOT help combine conditions.
  • Decision trees are chains of rules.
  • Rule-based systems are simple, reliable, and powerful.

๐Ÿš€ Preparation for the Next Module

In Module Three, we'll explore Machine Learning โ€” how computers learn from examples instead of following fixed rules. You'll see how AI can discover its own rules!

Before then, practice building rule systems for everyday problems. Try to think of 5 situations where you could use rules to make a decision. The more you practice, the better you'll understand AI!


๐ŸŽ‰ You've completed Module Two ยท You now understand how computers think! ๐ŸŽ‰

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’