Mathematics for Computer Science
Mathematical Logic, Proofs, and Sets
What Is a Proof?
A proof is a method for establishing that a mathematical statement is true.
Different fields and situations use different methods for determining truth:
Physical sciences: experiments, observations, and the scientific method
Statistics and elections: sampling and generalization
Law: trials and evaluation of evidence
Investigation: collecting evidence and identifying the explanation that best fits the observations
Authority: accepting a claim because a trusted person or institution makes it
Religion: accepting claims based on religious teachings or divine authority
Inner conviction: accepting something because it feels or seems true
Mathematics uses a more formal method: mathematical proof.
A mathematical proof is a verification of a proposition by a chain of logical deductions from a base set of axioms.
This definition contains three central ideas:
Proposition: the statement being proved
Logical deduction: the reasoning steps used to derive the conclusion
Axioms: the foundational statements assumed to be true
Propositions and Predicates
Propositions
A proposition is a statement that is either true or false.
A proposition must be complete enough that it makes sense to ask whether it is true or false.
Examples:
“Today is Tuesday.”
“Today is Thursday.”
2+3=5
2+3=4
“For every natural number n, n2+n+41 is prime.”
A proposition does not have to be true. A false statement can still be a proposition, as long as it has a definite truth value.
For example:
2+3=5 is a true proposition.
2+3=4 is a false proposition.
Predicates
A predicate is a statement involving one or more variables whose truth depends on the values assigned to those variables.
For example:
“p is prime” is not yet a proposition because the value of p has not been specified.
If p=7, then “7 is prime” is a proposition.
If p=12, then “12 is prime” is a proposition.
A predicate becomes a proposition once values are assigned to all of its variables.
A predicate is a parameterized statement whose truth depends on variables.
Quantifiers Can Turn Predicates into Propositions
Consider the predicate:
Its truth depends on n, so by itself it is not a complete proposition. Adding a universal quantifier creates the proposition:
The phrase “for every” means that the predicate must be true for all values of n in the specified set.
Natural Numbers and Testing a Universal Claim
The natural numbers used in the course are
In this setting, 0 is a natural number.
Consider the claim:
Testing values gives:
n=0: 02+0+41=41, which is prime
n=1: 12+1+41=43, which is prime
n=2: 22+2+41=47, which is prime
Many values from n=0 through n=39 also produce primes
n=40: 402+40+41=1681=412, which is not prime
n=41:
which is not prime
The statement is therefore false.
Counterexamples
A counterexample is a specific example showing that a universal claim is false.
For a claim of the form
one counterexample is enough to disprove it:
For the prime-generating claim, n=40 or n=41 is a counterexample.
To disprove a statement claiming that something is true for every possible case, it is enough to find one case where it fails.
Testing many examples cannot prove a universal statement. Even if the first 40 or 40,000 cases work, a later counterexample may exist.
Goldbach’s Conjecture
Goldbach’s Conjecture states:
Every even number greater than 2 is the sum of two prime numbers.
Examples:
4=2+2
12=7+5
20=17+3
The fact that 20=9+11 does not matter because 9 is not prime. The number 20 still satisfies the conjecture through the representation 20=17+3.
The statement is called a conjecture because it is a mathematical claim that has not been proved or disproved.
This illustrates an important distinction:
A statement may be simple to formulate.
It may be verified for an enormous number of examples.
It may still remain unproved because mathematical proof must establish the claim in all cases.
Some mathematical questions are beyond the reach of currently available mathematical techniques.
Boolean Operators
Boolean operators combine propositions into larger propositions. The three fundamental operators are:
NOT
AND
OR
If A and B are propositions, these operators produce new propositions whose truth values depend on the truth values of A and B.
NOT
The statement not A is written in several equivalent ways:
¬A
A
Other notation may be used depending on the text or course
It means that A is false.
Truth behavior of NOT
If A is true, then ¬A is false.
If A is false, then ¬A is true.
Thus, NOT reverses the truth value of its proposition.
AND
The statement A and B, written
is true exactly when both A and B are true.
Its truth behavior is:
A true and B true: A∧B is true
A true and B false: A∧B is false
A false and B true: A∧B is false
A false and B false: A∧B is false
The symbol ∧ resembles an unadorned capital A and is often used for AND.
OR
The mathematical statement A or B, written
is true when at least one of A and B is true.
Its truth behavior is:
Both true: A∨B is true
A true and B false: A∨B is true
A false and B true: A∨B is true
Both false: A∨B is false
Mathematical OR is inclusive OR. It allows both statements to be true.
In mathematics, “A or B” means “at least one of A and B,” including the possibility that both are true.
Mathematical Language Versus Everyday Language
Words such as “and,” “or,” and “not” have precise meanings in mathematics. In everyday English, however, their meanings depend heavily on context.
Exclusive OR
At a wedding, a waiter might ask:
“Did you order the chicken or the pasta?”
The expected choices may be:
Chicken
Pasta
The waiter probably does not expect:
Both chicken and pasta
Neither chicken nor pasta
This is exclusive OR, often called XOR. It means exactly one of the alternatives is allowed.
Exclusive OR is different from mathematical OR because mathematical OR permits both alternatives to be true.
NAND-like use of “or”
A waiter might ask:
“Would you like coffee or tea?”
The expected answers might be:
Coffee
Tea
Neither
The only disallowed answer is both coffee and tea. This is not ordinary mathematical OR. It is equivalent to saying that it is not the case that both are selected, a condition related to NAND.
“Anything goes”
A waiter might ask:
“Would you like cream or sugar?”
Possible responses may include:
Cream only
Sugar only
Both
Neither
Here, “or” simply lists available options and does not impose a logical restriction.
Practical lesson
When mathematical operators appear in a formula, they should be interpreted according to their formal definitions rather than their conversational meanings.
If a sentence is ambiguous, clarification is necessary. Precise mathematical reasoning depends on precise language.
Implication
Definition and Notation
An implication is written as
It may be read as:
“A implies B”
“If A, then B”
The statement A⟹B is false only in one situation:
A is true
B is false
In every other situation, the implication is true.
Truth behavior of implication
A true and B true: implication is true
A true and B false: implication is false
A false and B true: implication is true
A false and B false: implication is true
The critical rule is:
An implication fails only when its hypothesis is true and its conclusion is false.
Understanding Implication Through Rules
Consider the rule:
On Wednesdays, people wear pink.
This can be represented as:
The possible situations are:
It is Wednesday and the person wears pink: the rule is obeyed.
It is Wednesday and the person does not wear pink: the rule is violated.
It is not Wednesday and the person wears pink: the rule is not violated.
It is not Wednesday and the person does not wear pink: the rule is not violated.
The rule only makes a requirement about Wednesdays. On other days, it says nothing about clothing.
This explains why an implication with a false hypothesis is considered true: the rule has not been violated because its condition never occurred.
Implication Does Not Mean Causation or Time
In ordinary English, “A implies B” may suggest:
A causes B
A occurs before B
B happens as a consequence of A
Mathematical implication has none of these additional meanings.
In mathematics, A⟹B only describes a relationship between the truth values of A and B. It does not claim that:
A causes B
A happens first
B happens later
There is any physical or temporal connection between them
Each of A and B has its own truth value, regardless of whether that value is currently known.
For example, an unresolved statement such as Goldbach’s Conjecture is still a proposition. It is either true or false, even though mathematicians do not yet know which.
Implication as a Combination of NOT and OR
Implication can be rewritten using the earlier Boolean operators:
This means that either:
A is false, or
B is true
The only way for ¬A∨B to be false is for:
¬A to be false, meaning A is true
B to be false
Therefore, the only failure case is exactly the failure case for A⟹B.
Examples of Implication
Inequalities
The statement
is true because every number less than 3 is also less than 4.
The first statement is stronger than the second:
x<3 gives more information.
x<4 is weaker because it allows more possible values of x.
A stronger statement can imply a weaker statement, but the reverse need not be true. For example, x<4 does not imply x<3 because x=3.5 satisfies x<4 but not x<3.
Descartes’ statement
The statement commonly associated with Descartes is:
I think, therefore I am.
This contains two ideas:
The assertion that “I think” is true.
The implication:
The statement does not merely present an implication; it also asserts the truth of the hypothesis.
A humorous reversal such as
“I do not think, therefore I do not exist”
uses the inverse implication:
which is not generally equivalent to A⟹B.
An object could fail to think while still existing. In that case:
A is false
B is true
A⟹B is true
¬A⟹¬B is false
Converse, Inverse, and Contrapositive
Starting with the implication
several related statements can be formed.
Converse
The converse switches the order:
The converse is not generally equivalent to the original implication.
Inverse
The inverse negates both propositions without switching their order:
The inverse is also not generally equivalent to the original implication.
Contrapositive
The contrapositive switches the order and negates both propositions:
The contrapositive is logically equivalent to the original implication:
For the rule “Wednesday implies wearing pink,” the contrapositive is:
If a person is not wearing pink, then it is not Wednesday.
Both statements identify the same prohibited situation: Wednesday without pink.
The converse and inverse are equivalent to each other:
However, neither is generally equivalent to the original implication.
Sets
Definition
A set is a collection of objects called its elements.
Sets are written using curly braces.
For example:
Order Does Not Matter
The order in which elements are listed does not affect a set:
Repetition Does Not Matter
A set cannot meaningfully contain the same element multiple times. Repeating an element in the notation does not create a new element:
Both sets contain exactly the four elements 6, 1, 2, and 0.
The essential question for a set is:
Which objects belong to the set, and which objects do not?
Common Number Sets
Natural numbers
The natural numbers are
Integers
The integers are
They include the natural numbers and their negatives.
Rational numbers
The rational numbers are written Q.
A rational number is a number that can be written as
where a and b are integers and b=0.
Real numbers
The real numbers are written R. They include rational numbers and irrational numbers such as 2 and π.
Complex numbers
The complex numbers are written C. They include numbers involving the imaginary unit and extend the real numbers.
The Empty Set
The empty set is the set containing no elements.
It is represented by either:
∅
{}
The empty set is still a set. It is an object with zero elements.
Important distinctions:
A set may contain finitely many elements.
A set may contain infinitely many elements.
The empty set contains no elements but still exists as a mathematical object.
Elements and Membership
The notation
means that x is an element of A.
The notation
means that x is not an element of A.
Consider the set
The elements of B are:
The number 2
The set {3,4}
The empty set ∅
The number 3 is not an element of B:
Although 3 appears inside the element {3,4}, it is nested inside that element rather than being directly listed as an element of B.
Similarly:
but
Subsets
The notation
means that A is a subset of B.
It means that every element of A is also an element of B:
The set B may contain additional elements that are not in A.
For example, if
then
The empty set is a subset of every set:
for 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.
Element versus subset
The statements
and
have different meanings:
x∈A: x is one of the elements of A
A⊆B: every element of A is also an element of B
A set can be a subset of another set without being an element of it.
For example:
∅⊆A for every set A
But ∅∈A only if ∅ is explicitly listed among the elements of A
Set Operations
Sets can be combined using operations analogous to logical operators.
Union
The union of A and B is written
It contains every element that is in A, in B, or in both:
Using
and
the union is
The element 2 appears only once because repetition does not matter in a set.
Intersection
The intersection of A and B is written
It contains the elements belonging to both sets:
For the example sets, the only shared element is 2:
The empty set is not included in A∩B merely because it is a subset of both sets. It would need to be an element of both sets. In the example, ∅∈B but ∅∈/A.
Set difference
The set difference of A and B is written either
or
It contains the elements of A that are not elements of B:
For the example sets:
The element 2 is removed because 2∈B.
If A also contained 3 and 4 as direct elements, they would remain in A∖B because 3 and 4 are not direct elements of B. The set {3,4} is an element of B, but its internal elements do not automatically become elements of B.
Set-Builder Notation
Set-builder notation describes a set by specifying:
The larger set from which elements are selected
A predicate that the selected elements must satisfy
For example, the set of all natural numbers that are prime is
The vertical bar or colon means “such that.”
This notation means:
Begin with all n∈N
Keep only those n satisfying the predicate “n is prime”
The resulting set is
Set-builder notation demonstrates the close relationship between predicates and sets: a predicate identifies which elements belong to a set.
Tuples
A tuple is an ordered list of elements.
Tuples are written with parentheses rather than curly braces:
A tuple differs from a set in two essential ways.
Order Matters
The tuples
and
are different because their elements occur in different orders.
Repetition Matters
The tuples
and
are different because the first has four elements and the second has five.
Sets versus tuples
For sets:
Order does not matter.
Repeated elements do not create additional elements.
Union, intersection, and difference are meaningful operations.
For tuples:
Order matters.
Repetition is allowed and significant.
Set operations such as union and intersection are generally not applied.
Axioms and Mathematical Foundations
Definition of an Axiom
An axiom is a proposition assumed to be true within a particular mathematical system.
A proof needs a starting point. It is not necessary to prove every statement from nothing. Instead, mathematics begins with a specified collection of axioms and derives additional results from them.
Axioms are foundational assumptions from which other mathematical statements are logically deduced.
Axioms are sometimes described as “self-evident,” but this can be misleading. An axiom does not have to be universally or philosophically true. It is accepted as true for the mathematical system being studied.
Different systems can use different axioms, even axioms that cannot all be used together.
Euclid’s Parallel Postulate
Euclidean geometry is based on axioms traditionally associated with Euclid. One important axiom is the parallel postulate:
Given a point p not on a line ℓ, there exists a unique line ℓ′ through p parallel to ℓ.
Symbolically, if
then there is exactly one line through p that does not intersect ℓ.
For centuries, mathematicians attempted 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.
This means that changing the parallel postulate can produce different, internally meaningful geometries.
Spherical Geometry
In spherical geometry:
The geometric surface is a sphere rather than a flat plane.
A line is represented by a great circle.
A point may be considered together with its antipodal point, directly opposite it on the sphere.
Any two great circles intersect.
Therefore, there are no parallel lines.
This geometry results from replacing Euclid’s unique-parallel-line postulate with a statement that no parallel lines exist.
Hyperbolic Geometry
In hyperbolic geometry:
A point not on a given line has infinitely many lines through it that do not intersect the original line.
“Parallel” can be understood as nonintersection.
The geometry may be represented using a circular model in which lines appear as arcs perpendicular to the boundary.
Thus, the possible number of lines through a point parallel to a given line can be:
Exactly one in Euclidean geometry
Zero in spherical geometry
Infinitely many in hyperbolic geometry
The different conclusions arise because the underlying axioms differ.
A mathematical theory is determined not only by its definitions but also by the axioms from which its conclusions are derived.
Consistency and Completeness
When choosing axioms, mathematicians want the resulting system to have certain desirable properties.
Consistency
A system of axioms is consistent if it does not allow a contradiction to be proved.
Equivalently, no proposition should be both provable and disprovable within the system.
Consistency is essential because if a system proves that a contradiction is true, then logical reasoning can become meaningless.
Principle of explosion
In classical logic, a false statement can imply anything. This is sometimes called the principle of explosion.
If a system proves that false is true, then every proposition could be derived. As a result, the system would prove both a statement and its negation.
Such a system would be uninformative because every claim would become simultaneously true and false.
Completeness
A system of axioms is complete if every true proposition expressible within the system can be proved from those axioms.
Ideally, a mathematical system would have both properties:
Consistency: contradictions cannot be proved.
Completeness: every true statement can be proved.
Gödel’s Incompleteness Theorem
Gödel’s Incompleteness Theorem shows that a sufficiently powerful mathematical system—one capable of expressing basic arithmetic involving addition and multiplication—cannot be both consistent and complete.
Therefore:
If the system is consistent, there are true statements that cannot be proved using its axioms.
Adding new axioms may allow some previously unprovable statements to be proved.
However, the enlarged system will itself contain new true statements that cannot be proved from the enlarged set of axioms.
This means that mathematical truth and mathematical provability are not always identical.
A statement may be true but unprovable within a particular axiomatic system. It is possible, for example, that an unresolved statement such as Goldbach’s Conjecture could be true but unprovable from the standard axioms being used.
Axioms Used in Ordinary Mathematical Work
A mathematical course must specify what facts students are allowed to assume.
The working assumptions in an elementary proof course are approximately the familiar facts of high-school mathematics. These include basic results that are:
General
Familiar
Simple
Commonly included in standard mathematics curricula
Even when a fact is accepted without proof, it is good mathematical practice to identify it explicitly.
For example:
The product of two even numbers is even.
A proof may use this fact as an accepted theorem or previously established result. At every step of a proof, the justification should be clear:
It may follow from a definition.
It may follow from an axiom.
It may follow from a previously proved theorem.
It may follow from a logical rule.
The goal is for every conclusion in a proof to have a traceable reason.

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