Chapter 2 · Computational Thinking & Algorithms
2.3Logic as a Knowledge Representation Framework
How logic lets a computer store facts and rules, follow them, and reach correct, consistent decisions.
Written and checked by Muhammad Raheel(opens in a new tab)
Full Stack Developer · AI Engineer · Reviewed 21 Oct 2026 · 2 min read
On this page
A computer does not guess. It needs a clear way to keep facts and to use them. Logic gives it that way. In this topic you will see how logic stores knowledge, and how it helps computers and people make good decisions.
"Knowledge representation" simply means: how we write knowledge down so a computer can use it. Logic is a framework for this. A long, messy description becomes a few short facts and rules.
Logic in Computer Science
Inside a computer, logic is about rules and correct decisions.
Logic lets a computer work with two kinds of conditions: true and false. With them, the system can process information correctly. Programs and algorithms are full of logical statements. These statements decide which part of a program runs next. We call this the flow of the program. That is why the book calls logic the basis of many computer operations. It helps the computer think in a structured, orderly way.
Role of Logic in Reasoning and Decision Making
Reasoning means going from what you know to a new conclusion. Logic makes sure that conclusion is correct.
With logic, a decision is based on facts and rules, not on a feeling. This has several benefits, as the book explains:
- It removes confusion and guesswork.
- It helps solve problems step by step.
- It helps computers choose the correct action.
- It keeps decisions consistent and accurate. The same facts always give the same decision.
This is true for computers and for humans. The book also names two places where logic is used: expert systems and artificial intelligence. An expert system is a program that stores an expert's knowledge as rules, so it can give the same careful advice every time.
Practice this topic
Short questions
1.What is logic in computer science?2 marks
Answer
From the book: "In computer science, logic means using rules to make correct decisions. Logic helps computers understand true and false conditions. It allows systems to process information correctly." "Logical statements are used in programs and algorithms. These statements help control the flow of programs."
2.Define logic.2 marks
Answer
From the book: "Logic is the science of true reasoning and is an important concept in computer science. It helps computers store, understand, and use information correctly." The chapter Summary (page 30) also says: "Logic is a formal method of representing facts, statements, and rules so that correct reasoning and decision-making can be performed."
3.Why is logic called a knowledge representation framework?2 marks
Answer
Because logic is used to store and represent information. From the book: "It helps computers store, understand, and use information correctly. Using logic, complex information can be represented in a simple way."
4.What is the role of logical statements in programs and algorithms?2 marks
Answer
From the book: "Logical statements are used in programs and algorithms. These statements help control the flow of programs. Logic is the basis of many computer operations. It helps computers think in a structured way."
5.How does logic help in reasoning and decision making?3 marks
Answer
From the book: "It helps computers and humans draw correct conclusions. Using logic, decisions are made based on facts and rules. It removes confusion and guesswork. Logical reasoning helps solve problems step by step." "Logic ensures that decisions are consistent and accurate."
6.Name two areas where logic is used, according to the book.2 marks
Answer
From the book: "It is used in expert systems and artificial intelligence."
7.How does logic help computers "think"?2 marks
Answer
From the book's TIDBIT: "Logic gives computers a way to "think" about facts and make decisions, almost like a brain." The topic text adds: "Computers use logic to choose the correct action."
Long questions
1.What is logic as a knowledge representation framework? Explain its role in reasoning and decision making.8 marks
Answer
Cover the whole topic, using the book's text:
- Logic as a knowledge representation framework (verbatim): "Logic is the science of true reasoning and is an important concept in computer science. It helps computers store, understand, and use information correctly. Using logic, complex information can be represented in a simple way." The chapter Summary (page 30) adds: "Logic is a formal method of representing facts, statements, and rules so that correct reasoning and decision-making can be performed."
- Logic in Computer Science: "In computer science, logic means using rules to make correct decisions. Logic helps computers understand true and false conditions." Logical statements "are used in programs and algorithms" and "help control the flow of programs". "Logic is the basis of many computer operations. It helps computers think in a structured way."
- Role of Logic in Reasoning and Decision Making: "It helps computers and humans draw correct conclusions. Using logic, decisions are made based on facts and rules. It removes confusion and guesswork. Logical reasoning helps solve problems step by step. Computers use logic to choose the correct action. Logic ensures that decisions are consistent and accurate. It is used in expert systems and artificial intelligence."
- TIDBIT: "Logic gives computers a way to "think" about facts and make decisions, almost like a brain."
- An "if-then" example from the CLASS ACTIVITY: "If it rains, then we will stay indoors."
Aim for 200-300 words.
In this chapter
- 2.1Introduction to Computational Thinking
- 2.2Problem Solving Using Computational Thinking
- 2.3Logic as a Knowledge Representation FrameworkYou are here
- 2.4Propositional Logic
- 2.5Truth Tables
- 2.6Propositional Equivalence
- 2.7Propositional Satisfiability
- 2.8Predicate Logic
- 2.9Quantifiers in Predicate Logic
- 2.10Applying Predicate Logic to Real-World Problems
- 2.11Logic-Based Reasoning and Inference