[WIP] Mathematics for Computer Science

Chapter 1: What is a proof?

Symbol Meaning
Z+\mathbb{Z}^+ Positive integers.
:=:= Equal by definition: It implies that the equality is based on a specific definition or set of rules rather than just numerical equivalence. It’s always ok simply to write == instead of ::=::= because something that is equal by definition is a form of equality.
\forall For all.
N Non-negative integers.
\in Element of.

🙊 Propositions

A proposition is a statement that is either true or false. e.g. Fermat’s last theorem is a proposition that states “there are no positive integers xx, yy, and zz such that $x^n + y^n = z^n$”. The proposition was shared by Fermat in 1630 and was only proven in 1994.

💡 You can't check a claim about an infinite set by checking a finite sample of its elements, no matter how large the sample.

A conjecture is a proposition that is believed to be true based on limited evidence but has not been proven. e.g. Goldbach’s conjecture states that “every even integer greater than 2 is the sum of two prime numbers”.

A predicate is a proposition whose truth depends on the value of one or more variables. e.g “n is a perfect square”.

Like propositions, predicates are named with letters, often with function notation. The output is either true or false depending on the input. This is in contrast to ordinary functions where the output is a numerical value. e.g. p(n) ::= n is a perfect square.

💡 Euler is pronounced “oiler”.

🧩 Logical operators

Logical operators or connectives are used to combine or modify logical propositions. These are the common logical connectives:

🙃 1. Negation (NOT)

Symbol: ¬\neg

Negation is a unary logical connective that takes a proposition PP to another proposition “not P$”, standing for “$P is not true”. It is interpreted intuitively as being true when PP is false, and false when PP is true.

PP ¬P\neg P
T F
F T

🪢 2. Conjunction (AND)

Symbol: \land

A conjunction is a (binary) logical connective on two propositions that produces a value of true if and only if both propositions are true.

AA BB ABA \land B
F F F
F T F
T F F
T T T

💁 3. (Inclusive) Disjunction (OR)

Symbol: \lor

A disjunction is a (binary) logical connective on two propositions that produces a value of true if either one of the propositions is true.

AA BB ABA \lor B
F F F
F T T
T F T
T T T

👉 4. Implication (if…then)

Symbol:     \implies

A material implication or material conditional is a (binary) logical connective on two propositions that produces a value of true unless its first proposition (antecedent) is true and its second proposition (consequent) is false.

The only circumstance in which a conditional is false is if the consequent ($Q$) does not follow when the antecedent ($P$) is true. The material conditional is only concerned with the hypothetical relationship between PP and QQ, not their actual truth values.

✏️ I have always scratched my head as to why the conditional was defined to be true if the antecedent is false.

One explanation is that if the antecedent is false, then the relationship (implication) doesn't matter. But then this begs the question: Why not define it to be false?

One argument against that is that it would make the implication operator have the same truth table as the conjunction operator. But why is that a problem?

The argument that sits well with me so far is: The logical connectives must be truth-functional, i.e. its truth value is determined exclusively by the truth values of its arguments. Hence, we must define them to have a stable value. When PP is false, we have two viable options: return false or return true. We are using the latter option because of legacy reasons and because it “plays nicely” with the rest of the subject.

The material conditional ($P \implies Q$) can be expressed in various ways:

  1. If PP, then QQ.
  2. PP implies QQ.
  3. PP only if QQ
  4. QQ if PP.
  5. QQ whenever PP.
PP QQ P    QP \implies Q
F F T
F T T
T F F
T T T

👉👈 5. Equivalence (if and only if)

Symbol:     \iff

A material equivalence is a (binary) logical connective on two propositions that produces a value of true only if both both propositions are true or both are false.

"PP if and only if Qquot; can be decomposed into "$P if Qquot; and "$P only if $Qquot;:

So, PP if and only if QQ is logically equivalent to (Q    P)(P    Q)(Q \implies P) \land (P \implies Q)

PP QQ P    QP \implies Q Q    PQ \implies P P    QP \iff Q
T T T T T
T F F T F
F T T F F
F F T T T

👫 Sufficiency and necessity

In implications relationships, a necessary condition is one (possibly one of multiple conditions) that must be present in order for another condition to occur, while a sufficient condition is one that produces the said condition.

In a conditional statement ($P \implies Q$) that is true, the antecedent ($P$) is a sufficient condition for the consequent ($Q$) and the consequent is a necessary condition for the antecedent:

Sufficiency and necessity venn diagram

Being in the purple region is sufficient for being in AA, but not necessary. Being in AA is necessary for being in the purple region, but not sufficient. Being in AA and being in BB is necessary and sufficient for being in the purple region.

e.g.

A number's being divisible by 4 is sufficient (but not necessary) for it to be even, but being divisible by 2 is both sufficient and necessary for it to be even.

🕵️ Inference rules

An inference is a set of premises together with a conclusion.

A rule of inference is a way or schema of drawing a conclusion from a set of premises, usually based only on the logical form of the premises.

Some common inference rules:

  1. Modus ponens:

  2. Modus tollens:

  3. Hypothetical syllogism:

  4. Disjunctive syllogism

  5. Contraposition:

✅ Validity & Soundness

An inference is valid if, assuming its premises are true, the conclusion must be true.

An inference is sound if it is valid and all of its premises are true (and as a consequence its conclusion is true as well).

e.g.

A sound inference

(premises)

All men are mortal.

Socrates is a man.

(conclusion)

Therefore, Socrates is mortal.

e.g.

A valid but unsound inference

All birds can fly.

Penguins are birds.

Therefore, penguins can fly.

✒️ Standard form

The standard form for inference rules is:

Premise 1Premise 2Conclusion\begin{gathered} \frac{ \begin{aligned} \text{Premise 1} \\ \text{Premise 2} \end{aligned} }{\text{Conclusion}} \end{gathered}

When the statements above the line (the premises or antecedents) are proved, then the statement below the line (the conclusion or consequent) is considered to also be proved.

❌ Fallacies

  1. Affirming the consequent:

    My cat has four legs.

    Therefore, my cat is a dog.

  2. Denying the antecedent:

  3. Begging the question:

🧑‍⚖️ Proofs

An axiom or postulate is a proposition that is taken to be true, to serve as a premise or starting point for further reasoning and arguments. For instance, Euclid begun with five assumptions (axioms) about geometry, which seemed undeniable based on direct experience, e.g. “There is a straight line segment between every pair of points”.

A proof is a sequence of logical deductions from axioms or previously proved statements (like theorems) that concludes with the proposition of interest.

Logical deductions or inference rules are used to prove new propositions using axioms or previously proved propositions.

The axiomatic method, invented by Euclid, is the standard procedure for establishing truth in mathematics using axioms and proofs.

📜 Proof terminologies

  1. Important true propositions are called theorems.
  2. A lemma is a preliminary proposition useful for proving later propositions.
  3. A corollary is a proposition that follows in just a few logical steps from a theorem.
  4. When an implication is translated by a hypothetical (or conditional) judgment, the antecedent is called the hypothesis (or the condition) and the consequent is called the thesis.

🧱 Types of proofs

1. 🎯 Direct proof

To prove p    qp \implies q directly, assume pp is true, then use axioms, definitions, rules of inference, and logical equivalences to prove qq is also true.

A useful technique in constructing direct proofs is working backwards:

e.g.

Proposition: “If a number is divisible by 66, then it is also divisible by $3$”

Proof:


2. 🙃 Proof by contraposition (a type of indirect proof)

To prove p    qp \implies q by contraposition, assume qq is false, then use axioms, definitions, rules of inference, and logical equivalences to prove pp is also false. This is essentially a direct proof that ¬q    ¬p\neg q \implies \neg p.

The best approach in doing a proof by contrapositive is to restate the original problem in the form, If pp, then qq. The contrapositive is then, If not qq, then not pp.

e.g.

Proposition: “If xx is divisible by 66, then x is divisible by $3$”

Proof:


3. 🙅 Proof by contradiction (also a type of indirect proof)

This method works by assuming your implication is not true, then deriving a contradiction. Recall that if pp is false then p    qp \implies q is always true, thus the only way our implication can be false is if pp is true and qq is false.

In practice then, we assume our premise is true but our conclusion is false and use this to derive a contradiction: either a violation of a law or a previously established result. Having derived the contradiction you can then conclude that your assumption (that p    qp \implies q is false) was false and so the implication is true.

e.g.

Proposition: If x+x=xx + x = x then x=0x = 0

Proof:


4. 🙄 Trivial proof

A proof is trivial if the statement qq in the implication p    qp \implies q is true regardless of the truth value of $p$.

e.g.

Prove A{}    AA \neq \{\} \implies A is a subset of ABA \cup B for any set BB.


5. 🤷 Vacuous proof

If the statement pp in the implication p    qp \implies q is false then the implication is always true.

e.g.

AA is a proper subset of A    AA \implies A is a proper subset of ABA \cap B for any set BB, where the containments here are strict.

🧱 8. Proof by cases

Some implications come in the form, p1p2...pn    qp_1 \lor p_2 \lor ... \lor p_n \implies q. Often these cases will be derived in the course of the proof. In this case you must prove that EACH of the separate implications, pi    qp_i \implies q is true.

👉👈 7. Proving an if and only if (iff)

🤝 Method 1: Prove each statement implies the other

The statement P    QP \iff Q is equivalent to the the two statements:

Hence, P    QP \iff Q can be proved by proving the two implications.

e.g.

Proposition: “$P \iff Q$”

Proof: First, we show P    QP \implies Q Use any of the types of proof above to prove this.

Finally, we show Q    PQ \implies P Use any of the types of proof above to prove this.

This proves the proposition because P    Q=(P    Q)(Q    P)P \iff Q = (P \implies Q) \land (Q \implies P) \blacksquare

⛓️ Method 2: Construct a chain of Iffs

To prove P    QP \iff Q is true, prove PP is equivalent to a second statement which is equivalent to a third statement and so forth until you reach QQ.

This method can lead to short & elegant proofs, but it requires more ingenuity than the first.

e.g.

Proposition: The standard deviation of a sequence of values x1x_1, … , xnx_n is zero iff all the values are equal to the mean ($\bar{x}$).

Proof: We construct a chain of “iff” implications, starting with the statement that the standard deviation is zero: $ \sqrt{\frac{ (x_1 - \bar{x})^2 + (x_2 - \bar{x})^2 + ... + (x_n - \bar{x})^2}{n}} = 0 $

Now, since zero is the only number whose square root is zero, the equation above holds iff: $(x_1 - \bar{x})^2 + (x_2 - \bar{x})^2 + ... + (x_n - \bar{x})^2 = 0$

Squares of real numbers are always non-negative, so every term on the left-hand side of the equation above is non-negative. This means the above equation holds iff: Every term on the left-hand side of the equation is zero.

But a term (xixˉ)2(x_i - \bar{x})^2 is zero iff xi=xˉx_i = \bar{x}, so the above statement is true iff: Every xix_i equals the mean (\bar{x}$) $\blacksquare

💪 Properties of a good proof

The same rigorous thinking needed for proofs is essential in the design of critical computer systems. When algorithms and protocols only "mostly work" due to reliance on hand-waving arguments, the results can range from problematic to catastrophic

  1. Concise — Not unnecessarily long.
  2. Clear — A proof is an essay, not a calculation. Keep it unambiguous and include explanations.
  3. Linear & logical — Every statement logically follows from prior statements.
  4. Complete — Doesn't skip intermediary steps.
  5. Rigorous — Uses mathematical expressions.

Links