Propositional Logic Fundamentals
# CHAPTER 2
Propositional Logic Fundamentals
1. Introduction
Before you can build an algorithm, a database, or a CPU, you must have a system to determine reality. In computer programming, every decision a computer makes is based on whether a specific condition isTrue or False.
This binary decision-making framework is mathematically formalized as Propositional Logic. It is the absolute bedrock of computational thought. If you have ever written an if/else statement in Python, Java, or C++, you have already been executing Propositional Logic.
2. Learning Objectives
By the end of this chapter, you will be able to:- Define what constitutes a valid "Proposition" in mathematics.
- Identify sentences that are NOT propositions.
- Assign Truth Values to discrete statements.
- Understand how single propositions combine to form compound logical architectures.
3. What is a Proposition?
A Proposition is a declarative sentence that is either strictly True or strictly False, but *never both*, and *never neither*.Valid Propositions:
- "Paris is the capital of France." *(True)*
- "$2 + 2 = 5$." *(False - It is wrong, but it is still a valid declarative proposition!)*
- "The server is currently online." *(True or False)*
NOT Propositions:
- "What time is it?" *(A question cannot be true or false).*
- "Read the documentation!" *(A command cannot be true or false).*
- "$x + 5 = 10$." *(This is an open sentence. We cannot determine if it is true or false without knowing the value of $x$.)*
- "This statement is false." *(A paradox. It cannot be assigned a truth value).*
4. Variables and Truth Values
In algebra, we use variables like $x$ and $y$ to represent numbers. In Propositional Logic, we use variables (usually $p, q, r$) to represent entire propositional sentences.Let:
- $p =$ "The user is logged in."
- $q =$ "The file exists."
Every propositional variable possesses exactly one Truth Value:
- T (True) or 1
- F (False) or 0
If the user is currently logged in, then $p = T$. If the file is missing, then $q = F$.
5. Compound Propositions
A single proposition ($p$) is simple. But real-world computer science requires evaluating multiple conditions simultaneously. "If the user is logged in AND the file exists, THEN allow download."When we link multiple simple propositions together using Logical Operators (AND, OR, NOT), we create a Compound Proposition.
*Example:*
- $p$: "It is raining."
- $q$: "I will bring an umbrella."
- Compound: "It is raining, AND I will bring an umbrella."
6. The Programming Connection
How does this mathematical theory translate to software engineering? Variables in code that hold True/False values are called Booleans (named after George Boole, a pioneer of propositional logic).7. Logical State Evaluation Table
To systematically track all possible states of a proposition, mathematicians use a foundational visualization called a Truth Table. For a single proposition $p$, there are exactly 2 possible states:| $p$ | State Meaning |
|---|---|
| T | The proposition is functionally True. |
| F | The proposition is functionally False. |
For two propositions ($p$ and $q$), there are exactly $2^2 = 4$ possible combinations of reality:
| $p$ | $q$ | Combination Reality |
|---|---|---|
| T | T | Both are True. |
| T | F | First is True, Second is False. |
| F | T | First is False, Second is True. |
| F | F | Both are False. |
8. Common Mistakes
- Confusing facts with propositions: Remember, a proposition does not have to be scientifically accurate. "The moon is made of cheese" is a perfectly valid mathematical proposition because it can be definitively evaluated as False.
- Treating variables as numbers: In logic, $p$ does not equal 5. $p$ exclusively equals $T$ or $F$.
9. Exercises
- 1. Which of the following are valid propositions?
- 2. If you have 3 distinct propositions ($p, q, r$), how many total possible True/False combinations exist? (Hint: Base-2 mathematics).
10. MCQs with Answers
What is the strict mathematical definition of a Proposition in discrete logic?
Which of the following sentences formally qualifies as a valid Proposition?
Why does the sentence "$x + 10 = 20$" FAIL to qualify as a mathematical proposition?
In standard programming architectures (Java, C++, Python), what specific primitive data type directly maps to the mathematical concept of a Proposition?
How many explicit Truth Values exist in standard classical Propositional Logic?
If a mathematician defines the variables $p=$"It is raining" and $q=$"The street is wet", what constitutes a "Compound Proposition"?
When constructing a Truth Table mapping all possible reality states for three distinct, independent propositional variables ($p, q, r$), how many explicit rows of combinations are generated?
Is the sentence "The binary number 10 equals the decimal number 5" a valid proposition?
What severe logical anomaly occurs when attempting to evaluate the sentence "This statement is false"?
11. Interview Preparation
Top Interview Questions:- *Algorithmic translation:* "An API requires three separate Boolean flags to be passed. If you need to test every single possible combination of these flags to ensure the system doesn't crash, how many tests must you write?" *(Answer: $2^n$ combinations. With 3 flags, you must write exactly $2^3 = 8$ distinct unit tests to achieve 100% absolute logical coverage!)*