Chapter 10: Mathematical Logic
In this chapter, we introduce the basic concepts of mathematical logic. The principles we explore here are not purely theoretical: they form part of the foundation for digital circuits in computers and for the conditional logic used in programming. Both hardware and software rely on the same algebra of propositions that we will study.
Propositions
A proposition is a declarative statement that can be assigned a definite truth value: true or false, but never both.
The following are examples of propositions:
- "Four is even." (True)
- "1 + 1 is 3." (False)
- "." (True)
- "." (False)
In mathematical logic, propositions mirror the reasoning we use in everyday language, but with strict precision. They can also be compound, formed using logical connectives such as and, or, and not.
This foundation allows us to reason about more complex systems, from proofs in mathematics to conditional statements in computer programs like if and else.
Logical Operations
Simple propositions can be combined to form compound propositions using logical connectives such as and, or, not, if...then..., and if and only if. To avoid ambiguity, we define the meaning of each connective precisely and introduce its standard symbolic representation.
Except for negation (not), which acts on a single proposition, all logical operations act on pairs of propositions. Since each proposition can be either true () or false (), there are four possible combinations of truth values for two propositions. The effect of a logical operation on these combinations is most clearly shown using a truth table.
Logical Conjunction (AND)
If and are propositions, their conjunction, " and ," denoted by , is defined by the truth table:
Each row in the table represents one possible case. The conjunction is true only when both and are true, just as in ordinary language.
The symbols , , and are commonly used as placeholders for propositions, similar to how , , and are used for numeric variables.
Suppose we want to solve for such that and . This means must satisfy both conditions simultaneously:
In Python, we can write this as:
x = 3
if x > 0 and x < 5:
print("x is between 0 and 5")
Logical Disjunction (OR)
If and are propositions, their disjunction, " or ," denoted by , is defined by:
This operation reflects the inclusive or, meaning the result is true if either or both propositions are true.
A quadratic equation has two possible solutions:
In Python, we can write this as:
x = -3
if x == 3 or x == -3:
print("x is a solution to x^2 = 9")
Logical Negation (NOT)
Negation, denoted by , is the only standard operation that applies to a single proposition.
To express that is not equal to , we write
In Python, we can write this as:
x = 7
if not x == 5:
print("x is not 5")
Conditional Statement (IF...THEN...)
The conditional statement "If then ," denoted , is defined by:
The conditional is false only when is true and is false.
The statement "If , then " can be written as
In Python, we can write:
x = 2
if x == 2:
print("Then x squared is", x**2)
Converse and Contrapositive
The converse of is .
For example:
- Original: "If you score 95 or better on the exam, then you will receive an A."
- Converse: "If you receive an A, then you scored 95 or better."
These statements are not logically equivalent.
The contrapositive of is . Unlike the converse, the contrapositive is logically equivalent to the original conditional. This equivalence is often used in proofs because proving the contrapositive can be simpler.
Biconditional (IF AND ONLY IF)
If and are propositions, the biconditional, " if and only if ," denoted , is defined by:
The biconditional is true when and share the same truth value, i.e., both true or both false.
A number is zero if and only if both and :
In Python, we can write:
x = 0
if (x == 0) == (x >= 0 and x <= 0):
print("x is zero")
Logical Implication
A proposition logically implies a proposition (written as or ) if whenever is true, is also true.
Equivalently, the conditional statement is a tautology, meaning it is true in every possible case.
Let be "It is raining" and let be "The ground is wet."
If every time it rains the ground is wet, then we can write:
This does not mean it is currently raining or that the ground is wet; it simply states that the truth of guarantees the truth of .
Note on \rightarrow vs \Rightarrow
The symbols and are related but have different roles:
| Symbol | Usage | Example | Meaning |
|---|---|---|---|
| Conditional inside logic | "If it is raining, then the ground is wet." | Defines a logical relationship between and . | |
| Inference in reasoning | Given "It is raining" and "If it rains, the ground is wet," we can conclude "The ground is wet." | Expresses a reasoning step or consequence. |
Think of as part of the formula itself and as indicating a conclusion or reasoning step in a proof.
Logical Equivalence
Two propositions and are logically equivalent (written as ) if they always have the same truth value.
Equivalently, the biconditional
is a tautology.
Consider:
- : "I have been to Toronto."
- : "I have been to Chicago."
Now compare these two propositions:
- : "I have not been to both Toronto and Chicago."
- : "I have not been to Toronto or I have not been to Chicago."
At first glance, they appear different. But if you examine all possible truth values for and , you will find they always match. Thus:
This relationship is an example of De Morgan's Law.
The condition " is not less than " is equivalent to " is greater than or equal to ":
In Python, we can write this as:
x = 7
if not x < 5:
print("x is greater than or equal to 5")
Tautologies and Contradictions
Understanding tautologies and contradictions is key to working with implication and equivalence.
Tautology
A tautology is a logical expression that is true in every possible case. The symbol is often used to denote a tautology.
Examples of tautologies include:
- ("Either is true, or it is not.")
- ("If both and are true, then is true.")
In any equation, "" is always true.
In Python, we can write this as:
x = 42
if x == x:
print("This is always true")
Contradiction
A contradiction is a logical expression that is false in every possible case. The symbol is often used to denote a contradiction.
Examples of contradictions include:
- (" and not ," which is impossible to be true simultaneously.)
- ("Either or is true, but neither nor is true.")
" and " can never be true:
In Python, we can write this as:
x = 5
if x > 5 and x < 5:
print("This will never run")
Why Tautologies Matter
- Implication: A statement holds if and only if the conditional is a tautology.
- Equivalence: Two statements and are equivalent if the biconditional is a tautology.
This connection between tautologies, implication, and equivalence is fundamental to mathematical logic and proof techniques.