0% found this document useful (0 votes)
30 views

Mathematical Foundations of Computer Science Lecture Outline

This document outlines an introduction to logic and mathematical foundations of computer science. It discusses propositions, logical connectives like negation and conjunction, truth tables, quantification, and proofs involving integers. Key concepts covered include necessary and sufficient conditions, logical equivalence, proofs by contradiction using universal and existential quantification, and proving properties of integers like showing if a sum is even, the difference is even.

Uploaded by

Chenyang Fang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Mathematical Foundations of Computer Science Lecture Outline

This document outlines an introduction to logic and mathematical foundations of computer science. It discusses propositions, logical connectives like negation and conjunction, truth tables, quantification, and proofs involving integers. Key concepts covered include necessary and sufficient conditions, logical equivalence, proofs by contradiction using universal and existential quantification, and proving properties of integers like showing if a sum is even, the difference is even.

Uploaded by

Chenyang Fang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mathematical Foundations of Computer Science

Lecture Outline
August 28, 2018

Introduction to Logic
A proposition is a statement that is either true or false. For example, “2 + 2 = 4” and
“Donald Knuth is a faculty at Rutgers-Camden” are propositions, whereas “What time is
it?”, x2 < x + 40 are not propositions.

We can construct compound propositions from simpler propositions by using some of the
following connectives. Let p and q be arbitrary propositions.

Negation: p̃ (read as “not p”) is the proposition that is true when p is false and vice-versa.

Conjunction: p ∧ q (read as “p and q”) is the proposition that is true when both p and q
are true.

Disjunction: p ∨ q (read as “p or q”) is the proposition that is true when at least one of
p or q is true.

Exclusive Or: p ⊕ q (read as “p exclusive-or q”) is the proposition that is true when
exactly one of p and q is true is false otherwise.

Implication: p → q (read as “p implies q”) is the proposition that is false when p is true
and q is false and is true otherwise.

The implication q → p is called the converse of the implication p → q. The implication


¬p → ¬q is called the inverse of p → q. The implication ¬q → ¬p is the contrapositive of
p → q. p only if q means “if not q then not p”, or equivalently if p then q.

Biconditional: p ↔ q (read as “p if, and only if, q”) is the proposition that is true if p and q
have the same truth values and is false otherwise. “If and only if” is often abbreviated as iff.

The following truth table makes the above definitions precise.

p q ¬p p∧q p∨q p⊕q p→q q→p p↔q


T T F T T F T T T
T F F F T T F T F
F T T F T T T F F
F F T F F F T T T

Necessary and Sufficient Conditions: For propositions p and q,


2 Lecture Outline August 28, 2018

p is a sufficient condition for q means that p → q.


p is a necessary condition for q means that ¬p → ¬q, or equivalently q → p.
Why is p ∧ q not the correct answer?

Thus p is a necessary and sufficient condition for q means “p iff q”.

Logical Equivalence
Two compound propositions are logically equivalent if they always have the same truth
value. Two statement p and q can be proved to be logically equivalent either with the aid
of truth tables or using a sequence of previously derived logically equivalent statements.

Example. Show that p → q ≡ ¬p ∨ q ≡ ¬q → ¬p.

Solution. The truth table below proves the above equivalence.

p q ¬p ¬q p→q ¬p ∨ q ¬q → ¬p
T T F F T T T
T F F T F F F
F T T F T T T
F F T T T T T

Example. Show that p ≡ ¬p → C and p → q ≡ (p ∧ ¬q) → C.

p q ¬p ¬q p→q p ∧ ¬q C ¬p → C (p ∧ ¬q) → C
T T F F T F F T T
T F F T F T F T F
F T T F T F F F T
F F T T T F F F T

The above equivalence forms the basis of proofs by contradiction.

The logic of Quantified Statements


Consider the statement x < 15. We can denote such a statement by P (x), where P denotes
the predicate “is less than 15” and x is the variable. This statement P (x) becomes a
proposition when x is assigned a value. In the above example, P (8) is true while P (18) is
false.
Another way to convert the statement P (x) into a proposition is through quantifica-
tion. The two types of quantification that we will study are universal quantification and
existential quantification. Using universal quantifier ∀ (“for all”) alongside P (x) means
that the statement P (x) is true for all elements in the domain of x. Thus the proposition
∀x ∈ D, P (x) is true when P (x) is true for all x ∈ D and is false if there is an element
August 28, 2018 Lecture Outline 3

x0 ∈ D for which P (x0 ) is false. Using existential quantifier ∃ (“there exists”) alongside
P (x) means that there exists an element in the domain of x for which P (x) is true. Thus
the proposition ∃x ∈ D, P (x) is true if there is an x0 ∈ D for which P (x0 ) is true and is
false if P (x) is false for all x ∈ D.
Examples of propositions using quatifiers are as follows.
1. ∀x ∈ Z, x3 + 1 is composite.
2. ∀x ∈ Z, x is even → x + 1 is odd.
3. ∃x ∈ N, x2 6> x.
4. ∃x ∈ Z, 2|x and 2|x + 1.
5. ∀x ∈ Z ∃y ∈ Z, x + y = 0.
6. ∃x ∈ Z ∀y ∈ Z, x > y.
Sometimes it helps (in proofs) to consider the negation of a proposition. Verify the following
equivalence.

¬(∀x ∈ D, P (x)) ≡ ∃x ∈ D, ¬P (x)


¬(∃x ∈ D, P (x)) ≡ ∀x ∈ D, ¬P (x)

Proofs
We will illustrate some proof techniques by proving some properties about numbers. Before
we do that let’s go through some basic definitions given below.

An integer n is even iff n = 2k for some integer k. An integer is odd iff n = 2k + 1 for some
integer k. Symbolically,

n is even ↔ ∃ an integer k s.t. n = 2k


n is odd ↔ ∃ an integer k s.t. n = 2k + 1

An integer n is prime iff n > 1 and for all positive integers r and s, if n = r · s, then r = 1
or s = 1. Otherwise n is composite.

Given any real number x, the floor of x, denoted by bxc, is defined as follows

bxc = n ↔ n ≤ x < n + 1, where n is an integer

Given any real number x, the ceiling of x, denoted by dxe, is defined as follows

dxe = n ↔ n − 1 < x ≤ n, where n is an integer

A real number is rational iff it can be expressed as a ratio of two integers with a non-zero
denominator. A real number that is not rational is irrational. More formally,

r is rational ↔ ∃ integers a and b such that r = a/b and b 6= 0.


4 Lecture Outline August 28, 2018

Example. Prove the following: If the sum of two integers is even then so is their difference.

Solution. Let m and n be particular but arbitrarily chosen integers such that m + n is
even. By definition of even, we have m + n = 2k, for some integer k. Then

m = 2k − n

Now m − n can be written as follows.

m − n = 2k − n − n
= 2(k − n)

Since k and n are integers, k − n is an integer, 2(k − n) is even and hence m − n is even.

Example. Prove that, for all integers n, if n is odd then n2 + n + 1 is odd.

Solution. Since n is odd n = 2k + 1 for some integer k. Then,

n2 + n + 1 = (2k + 1)2 + 2k + 1 + 1
= 4k 2 + 4k + 1 + 2k + 2
= 4k 2 + 6k + 2 + 1
= 2(2k 2 + 3k + 1) + 1

Since k is an integer, p = 2k 2 +3k+1 is an integer and n2 +n+1 is odd, since n2 +n+1 = 2p+1
where p is an integer.

Example. Let x be an integer. If x > 1, then x3 + 1 is composite.

Solution. Let x be an arbitrary but specific integer such that x > 1. We can rewrite
x3 + 1 as (x + 1)(x2 − x + 1). Note that since x is an integer both (x + 1) and (x2 − x + 1)
are integers. Hence (x + 1)|x3 + 1 and (x2 − x + 1)|x3 + 1. We now need to show that
x + 1 > 1 and x2 − x + 1 > 1. Since x > 1, clearly, x + 1 > 1. x2 − x + 1 > 1 by the
following reasoning.

x > 1
x2 > x (Multiplying both sides by x.)
2
x −x > 0 (Subtracting both sides by x.)
2
x −x+1 > 1 (Adding 1 to both sides.)

We can also argue that x2 − x + 1 > 1 by showing that x + 1 < x3 + 1. Since x > 1 we have
x2 > x and hence x2 > 1. Multiplying both sides by x again we get x3 > x. This means
that x + 1 < x3 + 1 and since (x + 1)|x3 + 1, we conclude that x3 + 1 is composite.

Note: One student asked the question that why can’t we write x3 + 1 as x3 (1 + x13 ). The
reason is that for an integer x > 1, (1 + x13 ) is not an integer and the proof breaks down.

You might also like