Mathematics for Computer Science
Foundations of Mathematical Reasoning
Mathematics is not only about calculating answers. It is also about determining which statements are true, explaining why they are true, and communicating that reasoning precisely. The central tool for doing this is the mathematical proof.
A proof depends on several foundational ideas:
- Propositions are statements that can be true or false.
- Logical operators combine propositions into more complicated statements.
- Axioms provide the starting assumptions.
- Logical deductions connect the axioms to a conclusion.
- Sets and predicates provide a language for describing mathematical objects and conditions.
Together, these ideas form the basic language of mathematical reasoning.
What Is a Proof?
Different fields use different methods to determine truth. Physical scientists use experiments and observations. Pollsters use sampling to estimate opinions. Courts use trials and evidence to decide what happened and who is responsible. Investigators search for evidence and the explanation that best fits the observations.
Mathematics uses a different method: proof.
A mathematical proof verifies a proposition through a chain of logical deductions from a base set of axioms.
This definition contains three important ideas:
- A proposition is the statement being verified.
- Axioms are statements accepted as starting assumptions.
- Logical deductions are the valid reasoning steps that connect the assumptions to the proposition.
A proof is therefore not merely evidence that a statement seems likely. It is a logically complete argument showing that the conclusion must follow from the accepted starting points.
Proof versus Examples
Examples can provide evidence, but they do not usually establish a universal mathematical claim.
Suppose a statement claims:
For every natural number n, the number n2+n+41 is prime.
Testing values gives:
[ \begin{array}{c|c} n & n^2+n+41 \ \hline 0 & 41 \ 1 & 43 \ 2 & 47 \ 3 & 53 \end{array} ]
The expression also produces primes for many further values, including values through n=39. This may make the statement look convincing. However, the statement says for every natural number, not merely for the first several dozen.
At n=40,
402+40+41=1681=412,which is not prime. At n=41,
412+41+41=41(41+1+1)=41⋅43,which is also not prime.
Thus, the original universal statement is false. One value that violates the claim is enough to disprove it. Such a value is called a counterexample.
This illustrates a general principle:
- To prove that a statement is true for every object, a complete argument is needed.
- To disprove a universal statement, one counterexample is enough.
Understanding a Proof versus Writing One
Reading a proof and thinking, “That makes sense,” is not the same as constructing the proof independently. Understanding someone else’s reasoning is usually easier than discovering and organizing that reasoning from scratch.
This difference can be called the P versus NP fallacy in the informal sense used here: recognizing that a solution works is easier than producing the solution unaided.
Proof writing requires several skills:
- identifying the relevant facts,
- arranging them in a logical order,
- explaining why each step follows,
- avoiding hidden assumptions,
- expressing the argument precisely enough for another reader to verify.
Collaborative discussion can help with discovering an approach, but a polished proof must be expressed independently in the writer’s own words. The goal is not only to reach the correct conclusion, but also to demonstrate understanding through a readable, precise argument.
Solving a problem and writing a proof of the solution are related but distinct mathematical skills.
Think About It
Why can a large collection of successful examples fail to prove a statement that begins with “for every”?
Propositions and Predicates
Propositions
A proposition is a statement that is either true or false.
Examples include:
- “Today is Tuesday.”
- “Today is Thursday.”
- “2+3=5.”
- “2+3=4.”
A proposition does not have to be true. The statement “2+3=4” is false, but it is still a proposition because it has a definite truth value.
A sentence such as “What time is it?” is not a proposition because it is a question rather than a statement that can be classified as true or false.
Predicates
A predicate is a statement whose truth depends on one or more variables. It can be viewed as an incomplete proposition that becomes a proposition once values are assigned to its variables.
For example,
p is primeis not yet a proposition if the value of p is unspecified. Once a value is assigned, the statement becomes a proposition:
- “7 is prime” is true.
- “12 is prime” is false.
The predicate becomes a proposition after the variable is given a value.
Another example is
n2+n+41 is prime.Its truth depends on n. The statement may be true for some values of n and false for others.
Quantifiers Turn Predicates into Propositions
A quantifier specifies how widely a predicate applies. The phrase “for all” is a universal quantifier.
The statement
For all n∈N, n2+n+41 is primeis a proposition because it makes a complete claim: every natural number must satisfy the predicate.
Here, N denotes the natural numbers. In this setting,
N={0,1,2,3,…}.In particular, 0 is included as a natural number.
The expression
∀n∈Nis another way to write “for every natural number n.”
Goldbach’s Conjecture
A famous example of a mathematical proposition is Goldbach’s Conjecture:
Every even number greater than 2 is the sum of two prime numbers.
Examples include:
12=7+5and
20=17+3.The expression 20=9+11 does not work because 9 is not prime, but that does not disprove the conjecture. A different valid representation, 20=17+3, still exists.
The word conjecture indicates that the statement is believed to be true or has substantial supporting evidence, but no proof or disproof is currently known. Checking many examples cannot settle a claim about every even number. A proof would need to cover all cases, while a disproof would require one even number greater than 2 that cannot be expressed as the sum of two primes.
Think About It
What is the difference between the predicate “p is prime” and the proposition “7 is prime”?
Boolean Operators and Truth Tables
Propositions can be combined to create new propositions. The basic tools for combining them are called Boolean operators or logical operators.
The most important operators are:
- not
- and
- or
- implies
A truth table lists every possible combination of truth values and gives the resulting truth value of the larger statement.
NOT
The statement not A means that A is false. It is written in several equivalent ways:
¬A,A,not A.Its truth table is:
| A | ¬A |
|---|---|
| True | False |
| False | True |
The operator reverses the truth value. If A is true, then ¬A is false; if A is false, then ¬A is true.
AND
The statement A and B is true only when both A and B are true.
It may be written as
A∧B.Its truth table is:
| A | B | A∧B |
|---|---|---|
| True | True | True |
| True | False | False |
| False | True | False |
| False | False | False |
The word “and” requires both conditions. For example, the statement “a number is even and positive” requires the number to satisfy both properties.
OR
The mathematical statement A or B is true when at least one of A and B is true. It may be written as
A∨B.Its truth table is:
| A | B | A∨B |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
Mathematical “or” is normally inclusive. If both A and B are true, then A∨B is also true.
This differs from some everyday uses of “or.” At a wedding, a waiter asking whether a guest ordered chicken or pasta may expect exactly one choice. That is exclusive OR, often written XOR: one choice or the other, but not both.
Other conversational uses of “or” may allow one choice, the other choice, or neither. Natural language depends heavily on context, while mathematical notation is intended to have a fixed meaning. When a mathematical statement uses ∨, it means inclusive OR unless explicitly stated otherwise.
NAND and XOR
Two less central operators are:
Exclusive OR
XOR is true when exactly one of A and B is true. It is false when both are true or both are false.
| A | B | XOR |
|---|---|---|
| True | True | False |
| True | False | True |
| False | True | True |
| False | False | False |
NAND
NAND means “not both.” It is the negation of AND:
¬(A∧B).It is false only when both A and B are true. In all other cases, it is true.
The key lesson is that ordinary English can be ambiguous, but logical notation is defined by its truth table.
Implication
The statement A implies B is written as
A⟹B.It can also be written with an arrow:
A→B.It is read as:
- “A implies B,” or
- “If A, then B.”
The truth table is:
| A | B | A⟹B |
|---|---|---|
| True | True | True |
| True | False | False |
| False | True | True |
| False | False | True |
The only false case is when A is true but B is false.
Why Is False Implies True True?
Consider the rule:
If it is Wednesday, then a person wears pink.
This rule is violated only when:
- it is Wednesday, and
- the person does not wear pink.
The rule does not make any demand on other days. If it is Tuesday, then wearing pink satisfies the rule, and not wearing pink also satisfies the rule.
Thus:
- Wednesday and pink: true implication.
- Wednesday and not pink: false implication.
- Not Wednesday and pink: true implication.
- Not Wednesday and not pink: true implication.
The implication is not asserting that A actually occurs. It only says what must be true if A occurs. When A is false, the rule has not been violated.
No Necessary Causation or Time
In everyday English, “A implies B” may suggest that A causes B or happens before B. Mathematical implication has neither requirement.
The statement
A⟹Bsimply has the truth table above. It does not claim that:
- A causes B,
- A happens before B,
- B is produced by A,
- anyone knows whether A or B is currently true.
For example, a conjecture can serve as A even when its truth value is not yet known. The compound statement A⟹B is still a well-defined proposition.
Equivalent Form of Implication
The implication A⟹B can be rewritten using NOT and OR:
A⟹B≡¬A∨B.This expression is true whenever A is false or B is true. It is false only when A is true and B is false.
The essential idea is:
The only way to violate A⟹B is for A to occur without B.
Strength of Statements
Suppose x<3. Then it is necessarily true that
x<4.Therefore,
x<3⟹x<4.The condition x<3 is stronger than x<4 because it restricts x more severely. Every number less than 3 is also less than 4, but not every number less than 4 is less than 3.
The implication goes from the stronger condition to the weaker condition.
Converse, Inverse, and Contrapositive
Starting with
A⟹B,several related statements can be formed.
The converse switches the two parts:
B⟹A.The inverse negates both parts without switching them:
¬A⟹¬B.The contrapositive switches and negates both parts:
¬B⟹¬A.The important logical relationships are:
A⟹B≡¬B⟹¬Aand
B⟹A≡¬A⟹¬B.Thus, a statement is logically equivalent to its contrapositive, not generally to its converse or inverse.
For example, the rule
If it is Wednesday, then a person wears pink
has the contrapositive:
If a person is not wearing pink, then it is not Wednesday.
The converse would be:
If a person wears pink, then it is Wednesday.
That converse is not guaranteed. A person may wear pink on Tuesday.
The Error in “I Do Not Think, Therefore I Do Not Exist”
The statement traditionally associated with Descartes is:
I think, therefore I am.
Its logical form can be represented as:
T⟹E,where T means “I think” and E means “I exist.”
The contrapositive is:
¬E⟹¬T.The inverse is:
¬T⟹¬E.The phrase “I do not think, therefore I do not exist” uses the inverse, not the contrapositive. The inverse does not generally follow from the original implication.
A nonthinking object, such as a shoe, can still exist. Therefore, “not thinking” does not imply “not existing.”
Think About It
For the implication A⟹B, which single combination of truth values makes the statement false, and why?
Sets
A set is a collection of objects. The objects in a set are called its elements.
Sets are written using curly braces. For example,
{6,1,2,0}is a set containing four elements.
Order and Repetition
For sets:
- Order does not matter.
- Repetition does not create a new element.
Therefore,
{6,1,2,0}={2,1,6,0}and
{6,1,2,0}={6,1,2,0,0}.The set records only whether an object is present, not where it was written or how many times it was listed.
Important Number Sets
Several standard sets appear frequently:
- Natural numbers:
- Integers:
- Rational numbers:
- Real numbers: R
- Complex numbers: C
The rational numbers consist of numbers expressible as the quotient of an integer by a nonzero integer.
The Empty Set
The empty set is the set containing no elements. It can be written as
∅or
{}.The empty set is still a set. It simply has zero elements.
This distinction is important:
- ∅ is a set.
- ∅ contains no elements.
- A set can contain ∅ as one of its elements.
For example,
B={2,{3,4},∅}has three elements:
- the number 2,
- the set {3,4},
- the empty set ∅.
The number 3 is not an element of B. It is an element of the set {3,4}, which is itself an element of B.
This distinction separates:
3∈Bfrom
{3}⊆Bor from the idea that 3 is nested inside one of the elements of B.
Elements and Subsets
The notation
x∈Ameans that x is an element of A.
The notation
A⊆Bmeans that A is a subset of B. Every element of A must also be an element of B, although B may contain additional elements.
For example,
{1,2}⊆{0,1,2,6}.The empty set is a subset of every set:
∅⊆A.This is true because there is no element of ∅ that could violate the subset condition. To disprove ∅⊆A, one would need to find an element of ∅ that is not in A, but no such element exists.
However, the empty set is not automatically an element of every set. For instance,
∅∈Bin the example above because it was explicitly listed in B, but generally
∅∈/Aif it was not listed among A’s elements.
Set Operations
Sets can be combined in ways that resemble logical operations.
Union
The union of A and B, written
A∪B,contains everything that is in A, in B, or in both.
Using
A={6,1,2,0}and
B={2,{3,4},∅},the union is
A∪B={0,1,2,6,{3,4},∅}.The element 2 appears only once because sets do not contain duplicate copies of an element.
Union corresponds closely to logical OR: membership in A∪B means membership in A or membership in B.
Intersection
The intersection of A and B, written
A∩B,contains precisely the elements that belong to both sets.
For the example sets, the only shared element is 2, so
A∩B={2}.Intersection corresponds closely to logical AND: membership in A∩B requires membership in both A and B.
Set Difference
The difference of A and B, written either
A−Bor
A∖B,contains the elements of A that are not elements of B.
For the example sets,
A∖B={0,1,6}.The element 2 is removed because it belongs to B. The set {3,4} does not cause 3 or 4 to be removed from A, because 3 and 4 are not themselves elements of B; the single set {3,4} is an element of B.
This shows why the difference between an element and a nested set matters.
Set-Builder Notation
Set-builder notation describes a set by specifying the elements that satisfy a predicate.
For example,
{n∈N:n is prime}means “the set of all natural numbers n such that n is prime.”
The colon can be read as “such that.” The same set could be written using a vertical bar:
{n∈N∣n is prime}.The predicate determines which elements are selected from the larger set N. The result is the set of prime natural numbers:
{2,3,5,7,11,…}.Set-builder notation therefore creates a direct connection between predicates and sets.
Think About It
Why is ∅ a subset of every set, but not an element of every set?
Tuples
A tuple is an ordered list of elements. Unlike a set, a tuple:
- preserves order,
- allows repetition,
- is written with parentheses.
For example,
(6,1,2,0)is a four-element tuple, while
(6,1,2,0,0)is a five-element tuple.
These are different tuples because their lengths differ and one contains an additional entry.
Likewise,
(6,1,2,0)=(2,1,6,0)because the order is different.
Sets and tuples therefore behave differently:
{6,1,2,0}={2,1,6,0},but
(6,1,2,0)=(2,1,6,0).It generally does not make sense to ask for the union, intersection, or set difference of tuples, because those operations are defined for sets and depend on set membership rather than position.
Axioms and Mathematical Systems
A proof needs a starting point. An axiom is a proposition assumed to be true within a particular mathematical system.
This does not necessarily mean that an axiom is universally or philosophically self-evident. It means that the system begins by accepting it. Further statements are then derived from it using logical reasoning.
A mathematical system is therefore built from:
- chosen axioms,
- definitions,
- rules of logic,
- theorems derived from the preceding ingredients.
The same proposition may be an axiom in one system and a theorem, false statement, or irrelevant statement in another.
Euclidean Geometry and the Parallel Postulate
Euclidean geometry is based on axioms associated with Euclid. One famous axiom is the parallel postulate:
Given a point p not on a line ℓ, there exists a unique line through p parallel to ℓ.
Symbolically, if
p∈/ℓ,then exactly one line ℓ′ passes through p and is parallel to ℓ.
For a long time, mathematicians tried to prove this postulate from Euclid’s other axioms. Eventually, it was shown that the parallel postulate is independent of the others: it cannot be derived from them.
The significance of this result is that changing the parallel postulate creates other coherent geometries.
Spherical Geometry
In spherical geometry:
- the surface of a sphere serves as the geometric space,
- a point is paired conceptually with its antipodal point,
- a line is represented by a great circle,
- any two great circles intersect.
Because every pair of great circles intersects, there are no parallel lines. This corresponds to replacing Euclid’s unique-parallel statement with a statement that no parallel line exists.
Hyperbolic Geometry
In hyperbolic geometry:
- a point is an ordinary point,
- lines can be represented in a suitable model by arcs perpendicular to a boundary,
- through a point not on a given line, infinitely many lines can pass without intersecting the original line.
Thus, the parallel statement is replaced by one asserting infinitely many parallel lines.
Spherical and hyperbolic geometries are not meaningless contradictions. They are mathematically coherent systems built from different axioms. Their conclusions differ because their starting assumptions differ.
A mathematical theorem is always understood relative to the axioms from which it is derived.
Think About It
If two mathematical systems use different axioms, why should it be expected that they produce different theorems?
Consistency and Completeness
When choosing axioms, mathematicians want the resulting system to behave reliably. Two desirable properties are consistency and completeness.
Consistency
A set of axioms is consistent if it does not allow a proposition and its negation both to be proved. Equivalently, the system should not be able to prove that a contradiction is true.
Consistency matters because of the principle of explosion:
From a contradiction, anything can be logically deduced.
In logical notation, if falsehood were available as a valid conclusion, then falsehood could imply any statement:
False⟹Pfor any proposition P.
If a system proves both a statement and its negation, then it effectively loses the ability to distinguish truth from falsehood. Every statement could become derivable, making the system mathematically uninformative.
Completeness
A set of axioms is complete if every true proposition expressible within the system can be proved from those axioms.
Completeness would be attractive because it would mean that every mathematical truth has a proof using the system’s rules and assumptions. If a statement were not provable, its negation would ideally be provable instead.
Gödel’s Incompleteness Theorem
Kurt Gödel showed that a sufficiently powerful formal system—one capable of expressing basic arithmetic involving addition and multiplication—cannot be both consistent and complete.
In simplified terms:
- If the system is consistent, there will be true statements that cannot be proved within the system.
- If the system is made stronger by adding new axioms to prove some of those statements, the expanded system will have new undecidable truths of its own.
This result does not mean that mathematics is useless or that mathematical truth is arbitrary. It means that no single sufficiently powerful, consistent formal system can capture every mathematical truth through proof alone.
A statement may be true in the intended mathematical interpretation but unprovable from a particular collection of axioms. Proving it may require adding further assumptions.
Goldbach’s Conjecture illustrates the type of question that raises this possibility: it may eventually be proved, disproved, or—conceivably—be true but not provable from a chosen formal system.
Axioms in Ordinary Mathematical Work
In ordinary mathematics, mathematicians do not begin by rebuilding all of mathematics from the foundations each time. They use a broad background of familiar results.
For example, a proof might use the fact:
The product of two even numbers is even.
If that fact is being treated as already established, the proof can cite it rather than reprove it. Good mathematical writing still identifies the reason a step is valid, whether that reason is:
- an axiom,
- a definition,
- a previously proved theorem,
- or a logical consequence of earlier statements.
Comprehensive Review
The central structure of mathematical reasoning can now be summarized.
A proposition is a complete statement with a truth value. A predicate is a statement involving variables whose truth depends on the values assigned to those variables. Quantifiers such as “for every” can turn a predicate into a proposition.
Logical operators combine propositions:
- ¬A is true exactly when A is false.
- A∧B is true only when both are true.
- A∨B is true when at least one is true, including the case where both are true.
- A⟹B is false only when A is true and B is false.
The implication A⟹B is equivalent to its contrapositive:
A⟹B≡¬B⟹¬A,but it is not generally equivalent to its converse or inverse.
A set is a collection of objects. Sets ignore order and repetition, while tuples preserve order and allow repetition. The symbols ∈ and ⊆ express different relationships:
- x∈A means x is an element of A.
- A⊆B means every element of A is also an element of B.
The empty set is a subset of every set, but it is an element only of sets that explicitly contain it. Set operations mirror logical operations:
- union corresponds to OR,
- intersection corresponds to AND,
- set difference selects elements that satisfy membership in one set but not another.
An axiom is an assumed starting proposition. A proof derives further propositions from axioms through valid logical steps. Different axiom choices can generate different mathematical systems, as demonstrated by Euclidean, spherical, and hyperbolic geometry.
Finally, a useful axiomatic system aims for consistency and completeness, but Gödel’s Incompleteness Theorem shows that any sufficiently powerful consistent system must contain true statements that cannot be proved within that system. Mathematical proof remains the method for establishing conclusions relative to chosen assumptions, even though no single formal framework can contain every mathematical truth.

Ask anything
We've read this whole study set, so questions about it get the best answers.