Chapter 2 · Computational Thinking & Algorithms
2.10Applying Predicate Logic to Real-World Problems
Using predicates, quantifiers and reasoning to describe a library system and make decisions in it.
Written and checked by Muhammad Raheel(opens in a new tab)
Full Stack Developer · AI Engineer · Reviewed 21 Oct 2026 · 3 min read
On this page
So far, predicate logic has been about symbols. This topic puts it to work. The book uses one example all the way through: a library system, with its students, books and teachers. We describe who is connected to whom, write the library's rules, and then reason with them.
Predicate logic lets us describe objects, their properties and the links between them. Once the knowledge is written clearly, we can study a problem, make decisions and find answers in a logical way.
Representing Relationships Using Predicates
A predicate with two variables can describe a link between two objects. The book gives two:
- Borrows(x, y) means "student x borrows book y,"
- Teaches(t, s) means "teacher t teaches student s."
In the book's words, these predicates "clearly describe how students, books, and teachers are connected." The book calls the people and things "entities". Writing their links as predicates makes the whole system easier to organise and understand.
Writing Logical Statements With Quantifiers
Relationships describe single facts. Rules need quantifiers (topic 2.9). The book gives two library statements:
| Statement | Meaning (book wording) |
|---|---|
| ∀x, Student(x) → Borrows(x, Book) | "every student borrows a book." |
| ∃y, Book(y) ∧ Available(y) | "there exists at least one book that is available." |
The arrow → is read "if ... then". The symbol ∧ is read "and". So the first line says: for every x, if x is a student, then x borrows a book. The second says: there is at least one y that is a book and is available.
The first statement is a general rule about everyone. The second is about a specific case. Quantifiers let us describe both.
The book's CLASS ACTIVITY asks you to write rules like "All students must attend class" using universal quantifiers. Try it in the same style as the first formula.
Reasoning and drawing conclusions
Now we can reason. Take a rule and a fact:
- Rule: "∀x, Student(x) → HasLibraryCard(x)" (every student has a library card).
- Fact: "Ali is a student."
- Conclusion: "Ali has a library card."
The rule is true for every student, and Ali is a student, so it must be true for Ali.
This kind of reasoning helps the library make decisions, such as whether a student can borrow a book. Because every conclusion follows the same rules, the answers are correct and consistent. That makes the system reliable and easy to manage.
Practice this topic
Short questions
1.How can predicate logic be used to solve real-world problems?3 marks
Answer
From the book: "Predicate logic can be used to solve real-world problems by representing knowledge clearly and systematically. It helps us model situations involving objects, their properties, and relationships. Using predicate logic, we can analyze problems, make decisions, and find solutions logically."
2.How can predicates represent relationships? Give the book's two examples.3 marks
Answer
From the book: "Predicates can represent relationships between objects in the real world. For example, Borrows(x, y) means "student x borrows book y," and Teaches(t, s) means "teacher t teaches student s." These predicates clearly describe how students, books, and teachers are connected."
3.Write the meaning of "∀x, Student(x) → Borrows(x, Book)" and "∃y, Book(y) ∧ Available(y)".2 marks
Answer
From the book: "∀x, Student(x) → Borrows(x, Book) means "every student borrows a book." ∃y, Book(y) ∧ Available(y) means "there exists at least one book that is available."" Note: in the first formula "Book" is used like the name of one object; a fully formal version is ∀x (Student(x) → ∃y (Book(y) ∧ Borrows(x, y))). In the exam, write the book's formula and meaning as printed.
4.How do we draw conclusions using predicate logic? Give the book's example.3 marks
Answer
From the book: "Using predicate logic, we can draw conclusions from given facts. For example, if "∀x, Student(x) → HasLibraryCard(x)" and "Ali is a student," then we conclude "Ali has a library card.""
5.Why is logical reasoning useful in a library system?2 marks
Answer
From the book: "This logical reasoning helps in decision making, such as checking whether a student can borrow a book. It ensures correct and consistent conclusions, making the system reliable and easy to manage."
6.How do quantifiers help in writing rules about the library?2 marks
Answer
From the book: "Quantifiers help us write general rules about the library." "These statements help define rules and conditions in a precise way. Quantifiers allow us to describe both general situations and specific cases in the library system."
Long questions
1.Explain predicate logic and quantifiers. Discuss how predicate logic is applied to real-world problems.8 marks
Answer
This book question spans three topics. Parts 1 and 2 come from topics 2.8 and 2.9 (marked); part 3 is this topic, 2.10.
- Predicate logic (topic 2.8, verbatim): "Predicate logic is an extension of propositional logic. It allows us to express more detailed statements about objects and their properties." "A predicate is a statement that can be true or false depending on the values of the variables." Example from 2.8: Tall(Ali).
- Quantifiers (topic 2.9, verbatim): "Quantifiers are used in predicate logic to describe how many objects satisfy a condition." Universal quantifier "∀" (for all): ""∀x, x > 0" means "For all x, x is greater than 0."" Existential quantifier "∃" (there exists): ""∃x, x is even" means "There exists at least one x that is even."" Figure 2.8: "For all x, P(x)" and "For some x, P(x)".
- Applying predicate logic to real-world problems (topic 2.10, verbatim): "Predicate logic can be used to solve real-world problems by representing knowledge clearly and systematically. It helps us model situations involving objects, their properties, and relationships."
- Relationships: Borrows(x, y) means "student x borrows book y," and Teaches(t, s) means "teacher t teaches student s." "Using such relationships, we can model the working of the library system."
- Rules with quantifiers: "∀x, Student(x) → Borrows(x, Book) means "every student borrows a book." ∃y, Book(y) ∧ Available(y) means "there exists at least one book that is available.""
- Reasoning: if "∀x, Student(x) → HasLibraryCard(x)" and "Ali is a student," then we conclude "Ali has a library card." "This logical reasoning helps in decision making, such as checking whether a student can borrow a book."
- DO YOU KNOW?: "Predicate logic can model family trees, social networks, and even computer programs!"
Aim for 300-400 words.
2.Explain, with the book's library example, how predicates, quantifiers and reasoning are used to model a real-world system.6 marks
Answer
Cover the three sub-headings of 2.10 in order, using the book's text:
- Representing Relationships Using Predicates: "Predicates can represent relationships between objects in the real world." Borrows(x, y) means "student x borrows book y," and Teaches(t, s) means "teacher t teaches student s." "These predicates clearly describe how students, books, and teachers are connected." "This makes it easier to organize and understand interactions between different entities."
- Writing Logical Statements With Quantifiers: "Quantifiers help us write general rules about the library." The two formulas and their meanings ("every student borrows a book"; "there exists at least one book that is available"). "Quantifiers allow us to describe both general situations and specific cases in the library system."
- Reasoning and drawing conclusions: "Using predicate logic, we can draw conclusions from given facts." The Ali example (student, so has a library card). "It ensures correct and consistent conclusions, making the system reliable and easy to manage."
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 Framework
- 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 ProblemsYou are here
- 2.11Logic-Based Reasoning and Inference