Propositional Variables are variables used to denote propositions.
Typically: p, q, r, s, …
never use capitals as they are reserved for propositional functions
Negation
Negation of p denoted by ¬p
*You must use ¬ to mean “not”
same as !
Examples:
Ronnie likes Taco Bell
r: “Ronnie likes Taco Bell”
¬r: “It is not the case that Ronnie likes Taco Bell”, “Ronnie does not like Taco Bell”
Thor’s hammer is not named Mjölnir
always define prop vars as positive as below
m: “Thor’s hammer is named Mjolnir”
Negate original:
¬(¬m)⟹m
“Double negation rule”
Truth Values and Truth Tables
Suppose we have a proposition p. Create a truth table for p and ¬p
p
¬p
T
F
F
T
Conjunction
A conjunction of p and q is the statement “p and q”
it is denoted as p∧q
same as &&
Both p and q must be true for p∧q to be true
Disjunction
A disjunction of p and q is the statement “p or q”
it is denoted as p∨q
it is same as ||
p∨q is true whenever p is true, q is true, or both p, q are true
Examples:
p: “Ronnie has 3 cats”
q: “Ronnie does CrossFit”
Find p∨q
Ronnie has 3 cats or Ronnie does CrossFit
Find ¬p∧q
Ronnie does not have 3 cats and Ronnie does CrossFit
XOR
The exclusive or of p and q is the statement p XOR q
p⊕q
Same as ^
In order to eval to true, p can be true or q can be true, but not both
p⊕q=(p∨q)∧¬(p∧q)
Conditionals & More!
Implication
Let p and q be propositions
A statement in the form “if p, then q” is called a conditional statement / implication
written as p⟹q
False when p is true and q is false, otherwise true
p is called the hypothesis, sufficient condition
q is called the conclusion or the necessary condition
if sufficient condition happens, then the necessary condition must happen
p⟹q
if p, then q
if p, q
p is sufficient for q
q if p
q when p
a necessary condition for p is q
q unless ¬p
p implies q
p only if q (follows)
a sufficient condition for q is p
q whenever p
q is necessary for p
q follows from p
q provided that p
Truth Tables: p∧q,p∨q,p⊕q,p⟹q
List all possible combinations of truth values
If n is the # of unique prop vars, then there are 2n rows in the truth table
p
q
p∧q
p∨q
p⊕q
p⟹q
T
T
T
T
F
T
T
F
F
T
T
F
F
T
F
T
T
T
F
F
F
F
F
T
Converses, Inverses, Contrapositives
Given p⟹q
Converse: q⟹p
Inverse: ¬p⟹¬q
Contrapositive: ¬q⟹¬p
q⟹p=¬p⟹¬q
¬q⟹¬p=p⟹q
Biconditional
p iff q
p ⟺ q ≡ (p ⟹ q) ∧ (q ⟹ p)
p⟺q
Precedence of Logical Operators
¬
∧
∨
⟹
⟺
Logic Puzzles
In the Vikings age, there lived 2 types of people
Vikings, who are honorable and always tell the truth
Saxons, who are not honorable so they never tell the truth
Determine who is a Viking or Saxon between Ragnar and Egbert who say the following:
Ragnar: I am a Viking only when Egbert is not
^[only if]
Egbert: I am not a Saxon and Ragnar is a Saxon
p: Ragnar is a viking, ¬p: Ragnar is a saxon
q: Egbert is a viking, ¬q: Egbert is a saxon
Ragnar says: p⟹¬q
Egbert sats: q∧¬p
p
q
¬p
¬q
p⟹¬q
p⟺p⟹¬qWhether Ragnar statement and identity align
q⟺q∧¬p Whether Egbert statement and identity align
(p⟺p⟹¬q)∧(q⟺q∧¬p) Ragnar aligned && Egbert Aligned, i.e. do they go together
T
T
F
F
F
F
F
F
T
F
F
T
T
T
T
T
F
T
T
F
T
F
T
F
F
F
T
T
T
F
T
F
Based on the truth table, p≡T,q≡F
Now same situation, but different statements
Ragnar says: We are both Saxons
Egbert says: We are both Vikings
p: Ragnar is a viking, ¬p: Ragnar is a saxon
q: Egbert is a viking, ¬q: Egbert is a saxon
Ragnar says: ¬p∧¬q
Egbert says: p∧q
p
q
¬p
¬q
¬p∧¬q
p⟺(¬p∧¬q)
p∧q
q⟺(p∧q)
[p⟺(¬p∧¬q)]∧[q⟺(p∧q)]
T
T
F
F
F
F
T
T
F
T
F
F
T
F
F
F
T
F
F
T
T
F
F
T
F
F
F
F
F
T
T
T
F
F
T
F
No solution
If >=1 solution, “unable to determine”
Loki has heard of your exploits and wishes to honor you with a prize. However, being the deceiver that he is, he requires that you earn your prize by correctly determining which of three Chests actually holds the treasure. Only one Chest holds any treasure but the others are empty. You begin looking at the Chests and notice that Chests 1 and 2 are each inscribed with the message, “This Chest is empty.” The third Chest is inscribed with the message, “The treasure is in Chest 2.” Forseti, an honorable fellow, tells you that only one of these inscriptions are true. Which Chest do you select?
p: Treasure is in chest one
q: Treasure is in chest two
r: Treasure is in chest two
1: I’m empty (¬p)
2: I’m empty (¬q)
3: Treasure in 2 (q)
1 is true: (¬p∧¬q∧q)≡F
2 is true: (p∧¬q∧¬q)≡p∧¬q≡T
3 is true: (p∧q∧q)≡p∧q≡F
Treasure in one
Definitions
Compound proposition: any expression formed from propositional variables using logical operators
Tautology: always true compound prop.
Contradiction: a compound prop. that is always false
Contingency: everything else
Laws
Conditional Disjunction Equivalence
p⟹q≡¬p∨q
Absorption
p∨(p∧q)≡pp∧(p∨q)≡p
Prove Equivalence
p \equiv q \text{ iff: }$$$$
p \iff q \equiv T
A Proof for DeMorgan’s First Law
Law: ¬(p∧q)≡¬p∨q
p
q
¬p
¬q
p∧q
¬(p∧q)
¬p∧¬q
T
T
F
F
T
F
F
T
F
F
T
F
T
T
F
T
T
F
F
T
T
F
F
T
T
F
T
T
Prove logical equivalences without truth tables by using logical equivalences
Show that (p∧q)⟹(p∨q) is a tautology
(p∧q)⟹(p∨q)
Given
¬(p∧q)∨(p∨q)
Cond. Disj. Equiv.
(¬p∨¬q)∨(p∨q)
DeMorgan’s
(¬p∨p)∨(¬q∨q)
Asoc. & Comm.
T∨(¬q∨q)
Negation law
T
Domination Law
Satisfiability
A compound proposition is satisfiable if there is an assignment of truth vaues to its variables that make it true (when it is a tautology or contingency)
A compound proposition will be unsatisfiable if and only if it is a contradiction
Predicates and Quantifiers
Propositional Logic vs Predicate Logic
Example:
x > 3
x is the subject
“less than 3” is the predicate
a property of x
“x < 3” can be represented by P(x)
P denotes the predicate, x is the variable
P(77)=77<3
Let Q(x,y) denote x=3−y
Universal Quantifier
The universal quantification of P(x) is the statement “P(x) for all values of x in the domain”
∀xP(x) “for all x in P(x)”
∀ is the universal quantifier
Must include domain in statements
Existential Quantifier
The existential quantification of P(x) is the proposition: “There exists an element x in the domain such that P(x).”
“For some”, at least one / it exists
∃xP(x)
Uniqueness Quantifier
“There exists a unique”, i.e. only one
∃!xP(x)
e.g. ∃!x(x2=9)≡F, due to -3, 3
∃!xP(x)≡∃x(P(x)∧∀y(y=x⟹¬P(y))
∀,∃ takes precedent over all logical operators
Quantifiers over Finite Domains
If the domain of a quantifier is finite, then you can convert quantified statements to propositional logic
e.g. if domain = {x1,x2}
∀xP(x)≡P(x1)∧P(x2)∃xP(x)≡P(x1)∨P(x2)
Domain Shorthand example
∀x<0(x2<0) “for all x less than 0, x2<0“
De Morgan’s Laws for Quantifiers
Negation
Equivalent Statement
Negation is true when…
Negation is false when…
¬∃xP(x)
∀x¬P(x)
P(x) is false for every x
There is an x that makes P(x) true
¬∀xP(x)
∃x¬P(x)
There is an x that makes P(x) false
P(x) is true for every x.
Double quant: DeMorgan allows to move neg inside if swap quant.
Only have to be same x and y if in same scope. (Like programming)
Statement
The statement is true when…
The statement is false when…
∀x∀yP(x,y)
P(x,y) is true for all pairs x,y
There is a pair x,y that makes P(x,y) false
∀x∃yP(x,y)
For each x, you can find a y that makes P(x,y) true
There is a value for x such that no value for y can make P(x,y) true
∃x∀yP(x,y)
There is an x that makes P(x,y) true for every y
There is not a single x that makes P(x,y) true for every y
∃x∃yP(x,y)
There is a pair x,y that makes P(x,y) true
There are no pairs x,y that make P(x,y) true
End
Argument
Argument: a set of initial statements, called premises, followed by a conclusion.
An argument is valid if and only if in every case where all the premises are true, the conclusion is true. Otherwise, the argument is invalid.
An argument can be valid even if the conclusion is false. This can occur if one of the premises is false. The requirement here for “valid” is that the conclusion is true when all premises are true.
To prove a valid argument, show that the conjunction of the premises, leading to the conclusion is a tautology
Argument Name
Logical Representation
Modus Ponens
p p⟹q ∴q
Modus tollens
¬q p⟹q ∴¬p
Addition
p ∴p∨q
Simplification
p∧q ∴p
Conjunction
p q ∴p∧q
Hypothetical syllogism
p⟹q q⟹r ∴p⟹r
Disjunctive syllogism
p∨q ¬p ∴q
Resolution
p∨q ¬p∨r ∴q∨r
Example
Want conclusion to be b¬d∧ec∨d¬a⟹¬c¬a∨b
Statements
Reasons
¬d∧e
Given
c∨d
Given
¬a⟹¬c
Given
¬a∨b
Given
¬d
Simplification on ¬d∧e
c
Disjunctive Syllogism on c∨d and ¬d
a
Modus Tollens c and ¬a⟹¬c
b
Disjunctive Syllogism on ¬a∨b and a
∴b
Fallacy
Intro to Proofs: Direct Proof
Theorem a statement that can be shown to be true.
Proof a valid argument that establishes the truth of a theorem
Lemma less important theorems usually used to prove complicated theorems
Corollary a theorem that is established directly from a theorem that has been proved
Conjecture a statment that is being proposed as true
Proving one makes it a theorem
Useful definitions and axioms
The integer n is even if there exists an integer k such that n = 2k, and
n is odd if there exists an integer k such that n = 2k + 1.
Closure of multiplication in integers: The product of two integers is an integer.
Closure of addition in integers: The sum of two integers is an integer
Closure of subtraction in integers: The difference of any two integers is an integer
There is no closure of division (because of zero)
3-5 above also work for real numbers. replace all instances of the word integer with real number
The real number r is rational if there exist integers p and q with q ≠ 0 such that r = p∕q.
A real number that is not rational is called irrational.
A number m is a perfect square iff there exists some integer k such that m=k2
Proof Format
Introduction: Specify the type of proof technique you are using. E.g. I proceed with a direct proof. If proving a theorem in the form of conditional. State “Assume the hyp. Is true” where hyp. Is the hypothesis of the conditional. Outline any other things you may need to use to build this proof. Body: Write your argument for your proof. This step may typically contain multiple parts depending on both the proof technique and the theorem you are proving. Always define the domains of new variables you introduce See each proof technique for specifics. All simplification can be done in a single step. Any argument given should have a reason to go along with it. e.g. Let n be odd. By definition of odd, there’s an integer k such that n = 2k+1. Conclusion. State “Therefore by (insert proof technique)…is proven.” where … was the thing you were proving. Be careful to specify the entire theorem and not just the conclusion.
Direct Proof is a type of proof that directly leads to a conclusion, i.e. p⟹q. The assumption is that p is true, and we prove that q must follow.
Two Column Proof a proof with statements and reasons.
Z set of int
R set of real
Q set of rational
C set of complex
Example:
Give a direct proof of “If n is an even integer then n2 is an even integer”
Pf:
I proceed directly and assume n is even.
Statement
Reasons
n is even
Premise
Let n = 2k, where k∈Z
Definition of even
n2=4k2
Square both sides of the equation
n2=2(2k2)
Factoring out a 2
Let j=2k2 for some j∈Z
Closure of multiplication in Z
n2=2j
Substitution
n2 is even
Definition of even
We see that if n is even, then n2 is also even is proven. Have proved p⟹q
Paragraph proof do your proof in a paragraph.
You write a box at the end or smth.
Proof by Contraposition
p⟹q goes to ¬q⟹¬p
Example 1:
Prove that if n2 is an even and n is an integer, then n is even
This proof is probably easier using the contrapositive
n is odd ⟹n2 is odd
This is the contrapositive
n=2k+1n2=4k2+4k+1n2=2(2k2+2k)+1z=2k2+2kn2=2z+1n2 is odd
Not all full proof btw, just showing how you can use the contrapositive
Example 2
Actual proof
Prove that if n = ab, where a and b are positive integers, then a ≤ √n or b ≤ √n.
We will be using a contrapositive
n = ab
n=ab
dead end, so use cp
Scratch
!( a ≤ √n or b ≤ √n) ⟹ !(n = ab)
(a > √n and b > √n) ⟹ n != ab
(ab > b√n and bn>√n2 ) ⟹ n != ab
(ab > b√n and bn > n ) ⟹ n != ab
Pf:
I proceed by proving the contrapositive which states
if a > n and b>n, then n != ab, for all a, b, ∈Z
1
a>n
Premise
2
b>n
Premise
3
ab>bn
mult 1 by b
4
bn>n2
mult 2 by sqrtn
5
bn>n
simplify 4
6
ab > n
Transitivity on 3 & 5
7
ab=n
def of >
Therefore, our proof by contrapositive suceeded, and thus, the equivalent “For all a, b ∈Z, if n = ab then a\leq\sqrt{n}$
b ≤n” is true.
□
Proof by Contradiction
All props are either true or false
When trying to prove p is true, assume that p is false. Given this, break some equality or property of mathematics. Thus, p is true.
We’d assume if p then q is false
Giving us: ¬(p⟹q)
Leading to p∧¬q (with simplification) is true
Example 1
Give a proof by contradiction of the theorem “If 5n + 2 is odd, then n is odd.”
In a proof by contradiction, assume p∧¬q is true, and find a contradiction.
Pf:
I proceed using a proof by contradiction, where I assume 5n + 2 is odd, and n is even.
1
5n+2 is odd
premise
2
n is even
premise
3
n = 2k, for some k
def of even
4
5n = 10k
multi (3) by value of 5
5
5n + 2 = 10k + 2
add 2 to (4)
6
5n + 2 = 2(5k + 1)
factor (5)
7
5k + 1 = z, for z in Z
closure mult + add in z, meaning that multiplication and addition with integers, gives an integer
8
5n + 2 = 2z
sub (7) into (6)
9
5n + 2 is even
def. even
By (9) and (1), 5n+2 is both even and odd, which is a contradiction. Therefore, the original assumption that n is even is false, and “if 5n + 2 is odd, then n is odd” is proven.
□
Example 2
Show that at least four of any 22 days must fall on the same day of the week.
Scratch:
Assume not p.
At most, 3 of any 22 days must fall on the same day of the week.
3 * 7 = 21
Contradiction
Pf:
Using proof by contradiction, I assume “At most, 3 of any 22 days must fall on the same day of the week”.
Since there are 7 named days, and at most 3 fall on the same day, we have used at most
3x7=21 days, which contradicts that we have 22 days. Thus, our assumption was wrong, and at least 4 of any 22 days must feel on the same day of the week”
□
Example 3
Prove that √2 is irrational by giving a proof by contradiction
Pf: I proceed using contradiction and assume 2∈Q
We also note that a rational number can be written in simplest form.
Thus, we have 2=qp where p,q∈Z, q=0, and p,q have no common factors
2=q2p2, by squaring
2q2=p2
Thus p2 is even, by closue prop. and def of even
Since p2 is even, p is also even. And p = 2k for some k∈Z
Then through sub, we have 2q2=(2k)22q2=4k22q2=2(2k2)q2=2k2
and thus, q2 is even
Thus q is even, and so q = 2m for some m∈Z
We see p and q both have a common factor of 2, which contradicts the premise that they had no common factors.
Thus, our assumption that 2 is ration is false, and we are left with 2 as irrational.
Example 6
Let a and b be positive integers with the property that ab+1 divides a^2+b^2. Show that (a^2+b^2)/ (ab+1) is a perfect square.
Pf:
Just watch the lecture, view the notes later
□
When to use direct vs indirect proofs
Simple suggestion: Just try it. Start with a direct proof and see what happens. Do scratch work. Never try to write a proof before doing scratch work.
Longer suggestion: Hypotheses that can’t be easily reasoned from might suggest that you use an indirect proof. Look back to example 3.
Vacuous Proof, with p⟹q, if p≡F, then the original statement must be true, regardless of q.
Trivial Proof
with p⟹q, whenever q≡T, then the original statement must be true, regardless of q.
Backwards Reasoning (Strategy)
This is a strategy that you can use in your scratch work.
Suppose you’re proving that q is true from a list of givens.
However, you’re unable to figure out where to start based on those givens.
In this case, you might start with q and work backwards to something that you can prove using your givens.
Then when you write up your formal proof, you can do all the steps backwards.
Example:
Prove that (x+y)/2 > √(xy) for all distinct positive real numbers x,y
x=y,x≥0,y≥0
Scratch:
Start assuming conclusion is true.
2x+y>xyx+y>2xy(x+y)2>4xyx2+y2+2xy>4xyx2+y2−2xy>0(x−y)2>0
Not equal, thus LHS will be gt0
Now for the Pf, just go backwards
Pf:
Let x,y∈R, be arb. where x=y. Then x−y=0.
Thus, (x−y)2>0 * since the square of a nonzero real number is postive.
S
R
1) (x−y)2>0
By *
2) x2+y2−2xy>0
Distr.
3) x2+y2+2xy>4xy
Add 4xy
4) (x+y)2>4xy
Factor LHS
5) xy>2xy
sqrt 4)
6) 2x+y>xy
div by 2
We see that whenever x, y are distinct real # s, then 2x+y>xy
□
Exhaustive Proofs
In an exhaustive proof we try every possibility of the proposition. If all cases are true, then the proposition is proven.
e.g.
Prove that (n+1)3≥4n if n is a positive integer with n ≤ 3.
Pf:
I proceed by exhaustion
Let P(n)≡(n+1)3≥4nCase: P(1)P(1)≡(1+1)3≥41≡8≥4≡T
Case: P(2)P(2)≡(2+1)3≥42≡27≥16≡T
Case: P(3)P(3)≡(3+1)3≥43≡64≥64≡T
∴ By exhaustion, P(n) is true for all pos. int. where n≤3□
Proof By Cases
A proof by cases is used when you must break your proof up into different cases due to a single argument not being enough to prove all cases.
e.g.
Prove that if n is an integer, then n2≥n.
n=0⟹n2=0=n⟹n2=nn<0⟹n≤−1⟹n2≥0⟹n2>01≥n⟹n2≥nn>1⟹n2>n
Pf:
Assume n∈Z is arbitrary. We have 3 cases: n=0,n≤−1,n≥1
Case: n=0
Since n=0, n2=0=n⟹n2=n⟹n2≥n
Case: n≤−1n2≥0 since the square of an int is nonnegative. We know 0≥−1≥n by transitivity, we have n2≥n
Case: n≥1
Mult ineq by n gives n2≥n
Since we have proven all cases, then the original statement is true.
□
Without Loss of Generality
Sometimes we can eliminate cases inproof when the cases are very similar.
e.g.
x>0,y<0 vs y>0,x<0
You can say WLOG because the proofs for these cases with be exactly the same, except the x’s and y’s with be flipped.
Induction
Let P(n) be a proposition. To prove P(n) for all integers k.
Basis step where we show P(1)
Inductive step where we show that if P(k) then P(k+1)
Ex:
Prove that
∑j=1nj2n(n+1),n∈Z+
Pf:
Let P(n) be ∑j=1nj2n(n+1). I use inductionto show P(n) is true for all int. n >= 1.
Basis:
P(1) is true bc 1=21⋅2=21(1+1)
Inductive Hypothesis:
Assume that P(k)=1+2+...+k=2k(k+1) is true for a fixed arbitrary integer k≥1
Inductive Step:
1 + 2 + … k
2k(k+1)
1 + 2 + … k + (k + 1)
2k(k+1)+(k+1)
""""
2k2+k+2k+2
""""
2k2+3k+2
""""
2(k+1)(k+2)
""""
2(k+1)((k+1)+1)
We see that P(k)⟹P(k+1) is true, completing the inductive step.
By math induction, P(n) is true for all int n >= 1
□
Make sure to add the (k+1)th term, not just k + 1
Let a be constant and r be a common ratio
∑j=0narj=a+ar+ar2+...+arn=r−1arn+1−a,r=1
Pf: Let P(n) be ∑j=0narj=a+ar+ar2+...+arn=r−1arn+1−a,r=1. We us math. ind. to prove P(n) for all in n≥0
Basis Step:
P(0) is true because ∑j=00ar0=ar0=r−1ar−a,r=1
Thus P(k)⟹P(k+1) is proven, completing the inductive step. By induction, P(n) is true for all int. n≥0
Induction with Inequalities and Division
Use backwards reasoning in induction proofs in the SW to get the answer
~
Prove that n people can divide the cake fairly.
n = 1 → whole cake
n = 2 → 1/2 of whole cake
n = 3 → 1/3 of each 1/2
n = 4 → 1/4 of each 1/3
Pf:
Let P(n) be that n people can divide a cake fairly, so that each person has n1 of the cake. I use induction to prov P(n) is true for all integers n≥1
Basis:
P(1) is true because one person would get the entire cake. 1/1
Inductive Hypothesis:
Assume k people can divide the cake equally into k1 pieces where k∈Z+
Inductive Step:
Consider k people, by the inductive hypothesis, they split the cake such that each person has k1 of the cake. Let another person join, now we have k+1 people. We will take k+11 of each existing person’s slice.
In order words, they take k+11⋅k1 of the original cake, from each of the original k people.
Since this occurred k times, they now have kk+11⋅k1=k+11. Each of the original k, originally had k1 from which we took away 1+k1. Meaning k1−(k+11⋅k1)=k+11 each other person also has k+11 of the original cake.
Thus by math ind, P(k)⟹P(k+1); ∀n∈Z+P(n)□
Strong Induction
Induction but you do (P(1)∧P(2)∧...P(k))⟹P(k+1)
You can also be like P(j) for j∈ domain such that b<=j<=k
Set Theory
The study of Sets, which are collections of distinct objects.
The Universe, Universal Set, or Universe of Discourse, denoted by U is the Set that contains all the entities one wishes to consider in a given situation.
In Set Theory, a Venn Diagram is a diagram that visually demonstrates the relationship between Sets, their overlap, and their relation to the Universe of Discourse
Definition 1: Let A and B be nonempty sets. A function f from A to B is an assignment of exactly one element of B to each element of A. We write f (a) = b if b is the unique element of B assigned by the function f to the element a of A. If f is a function from A to B, we write f : A → B.
Definition 2: If f is a function from A to B, we say that A is the domain of f and B is the codomain of f. If f (a) = b, we say that b is the image of a and a is a preimage of b. The range, or image, of f is the set of all images of elements of A. Also, if f is a function from A to B, we say that f maps A to B.
You must specify the domain, codomain and the mapping of elements of the domain to elements in the codomain when defining a function. The range does not need to be explicitly specified
Two functions are equal when they have the same domain, codomain, and map each element of their common domain to the same element in their common domain.
Changing the domain, codomain or mapping creates a new function
Ex:
What is the domain, codomain, and range of a function that assigns the last two bits of a bit string of length 2 or greater to that string. (E.g. f(11010) = 10)
Domain
The set of all bit strings ≥ 2
Codomain
{11, 01, 10, 00}
Range
{11, 01, 10, 00}
Range and Codomain here happen to be equal
Let f : R→ R assign the square of a real number to this real number. Then, f (x) = x2 .. What is the domain, codomain, and range of f.
Domain
R
Codomain
R
Range
R−R−
set operators have to order of precedence, except with union, intersect, and remove
()
~ complement
Everything else left to right
Real-valued and Integer-Valued
A function is called real-valued if its codomain is the set of real numbers
it is called integer-valued if its codomain is the set of integers.
You can add and multiply both real-valued and integer-valued functions
A not necessarily a set of numbers
Ex
Let f1 and f2 be functions from R to R such that f1 (x) = x2 and
f2 (x) = x − x2 . What are the functions f1 + f2 and f1 f2 ?
Some functions never assign the same value to two different domain elements. These functions are said to be one-to-one.
At most one mapping from the domain for every element of the codomain
Note that a function f is one-to-one if and only if f (a) ≠ f (b) whenever a ≠ b, and vice versa.
Note 2 in the codomain below
Example: Determine whether the function f (x) = x2 from the set of integers to the set of integers is one-to-one.
False, every value square is also hit by its opposite squared
Assume domain if not given, to be the most reasonable real numbered domain or something similar.
Example: Prove that the function f (x) = x + 1 from the set of real numbers to itself is one-to-one.
You need to show that if f(a) = f(b), then a = b
By inspection it is 1-1 because it just shifts any value in the domain up by one.
f: R→R
Pf:
Let a,b ∈R be arbitrary and assume f(a) = f(b). Then by def of f(x):
a + 1 = b+1
a=b
Since f(a)=f(b) → a=b f(x) is 1-1, by definition
A function has to map all element in the domain to something in the codomain. Let the domain be R, the codomain be R. then f(x) = 1/x is not a function.
Increasing and Decreasing
Given x<y, and x, y are in the proper domains, f is called:
increasing if f (x) ≤ f (y)
strictly increasing if f (x) < f (y)
decreasing if f (x) ≥ f (y)
strictly decreasing if f (x) > f (y)
Its defined exactly as what you’d think it would mean.
Not all function match.
Horizontal line would be both. Vertical line would be neither.
Example: show that f(x)=x2 from R+ to R+ is strictly increasing.
let x, y be positive reals and x<yx<yx2<xyxy<y2x2<y2f(x)<f(y)∴x<y⟹f(x)<f(y)
Onto Functions
A function f from A to B is called onto, or a surjection, if and only if for every element b ∈ B there is an element a ∈ A with f (a) = b. A function f is called surjective if it is onto.
The range of the function equals the codomain. (every element in codomain is used.)
All elements of codomain are hit at least once
range = codomain
Let f be the function from {a, b, c, d} to {1, 2, 3} defined by f (a) = 3, f (b) = 2, f (c) = 1, and f (d) = 3. Is f an onto function?
Yes.
Is the function f (x) = x2 from the set of integers to the set of integers onto?
No. Not onto. All non square integers will be missed from the codomain. For example: 2,Z−
Is f (x) = x + 1 from the set of integers to the set of integers onto?
Consider an arbitrary element y ∈ B and find an element x ∈ A such that f (x) = y.
Let y in Z (codomain). Try to find x in the domain that makes x+1=y.
x = y-1 ← Guaranteed to be in domain? (Yes for this case bc closure).
Bijections
The function f is a one-to-one correspondence, or a bijection, if it is both one-to-one and onto. We also say that such a function is bijective. Exactly one domain element for every codomain element.
Bijections have special properties
All bijections have an inverse function
Inverse
Let f be a one-to-one correspondence from the set A to the set B. The inverse function of f is the function that assigns to an element b belonging to B the unique element a in A such that f (a) = b. The inverse function of f is denoted by f −1 . Hence, f −1(b) = a when f (a) = b.
Let f : Z → Z be such that f (x) = x + 1. Is f invertible, and if it is, what is its inverse?
f(x) is a bijection ⟹ f(x) is invertible
Get inverse.
Replace f(x) with x. Replace x with f(x)−1
Let f be the function from R to R with f (x) = x2. Is f invertible?
f(x) not a bijection
Composition of Functions
Let g be a function from the set A to the set B and let f be a function from the set B to the set C. The composition of the functions f and g, denoted for all a ∈ A by f ◦g, is the function from A to C defined by
(f ◦ g)(a) = f (g(a)).
Let g be the function from the set {a, b, c} to itself such that g(a) = b, g(b) = c, and g(c) = a.
Let f be the function from the set {a, b, c} to the set {1, 2, 3} such that f (a) = 3, f (b) = 2, and f (c) = 1.
What is the composition of f and g, and what is the composition of g and f ?
a → 3, c→1,b→2
a→undefined; g(f(x)) undefined, so the composition does not exist
Let f and g be the functions from the set of integers to the set of integers defined by
f (x) = 2x + 3 and g(x) = 3x + 2.
What is the composition of f and g?
f(g(x))=2(3x+2)+3=6x+4+3=6x+7
What is the composition of g and f ?
g(f(x))=3(2x+3)+2=6x+9+2=6x+11
f(g(x))=g(f(x)), but it is possible, just in general
Floor and Ceiling Functions
Floor
largest integer less than or equal to x⌊x⌋
Ceiling
smallest number greater than or equal to x⌈x⌉
Big-O Notation
Definition
Memorize:
C and k are called witnesses to the relationship f(x) is O(g(x)).
Trying to find an upper bound estimate of our function, i.e. if f(x) is a quadratic, its big O is O(x2)
In this class, not trying to find smallest upper bound, unlike in computing
We are just finding an upper bound
p(xn)=O(xn)
k for when g(x) is growing faster than f(x) and is ≥ than f(x)
k doesn’t need to be the first x where this occurs, just one of them
What C means is that we only care about the parent function, i.e. we consider if f(x)=3x2 then C=3 where g(x)=x2, so that the functions are comparable.
Pf:
show that f(x)=x2+2x+1 is O(x2)
I proceed directly. (This proof only works for polynomials)
Prove each term is O(x2)x2≤_x22x≤_x21≤_x2
∣x2∣≤∣1x2∣,∀x>0∣2x∣≤∣2x2∣,∀x>1 Did not have to pick this value, its just easier
∣1∣≤∣1x2∣,∀x>1x2+2x+1≤4x2,∀x>1
Thus C=4, k=1 as witnesses: f(x) is O(x2)□
Big-O Complexity
O(nn)
O(n!)
O(2n)
O(n2)
O(nlogn)
O(n)
O(logn)
O(1)
Have to memorize the theorem numbers.
Cardinality of Sets
Equal sets
Two sets A and B have the same cardinality if and only if you can find a bijection from A to B. When A and B have the same cardinality, we write |A| = |B|
Different Sets
If there is only a one-to-one function from A to B, the cardinality of A is less than or the same as the cardinality of B and we write
|A| ≤ |B|.
Furthermore, if there is a one-to-one function from A to B but there is no bijection, then |A| < |B|
Countable
Finite sets are countable
The set of positive integers is countable
Any infinite set that has the same cardinality as the set of of positive integers is countable.
When an infinite set S is countable, we denote cardinality of S by ℵ0 (read as aleph null). |S| = ℵ0
Hilbert’s Grand Hotel
Consider a hotel with a finite number of rooms. Suppose all rooms are occupied. A new guest arrives. Then there is no way to accommodate this guest without evicting a current guest.
Hilbert’s Grand Hotel: Consider a hotel with an infinitely countable number of rooms. Assume all rooms are occupied. Suppose a new guest arrives. Show that this guest can always be accommodated. In other words, show that we can always find a room for this guest without evicting a current guest.
Cantor’s Diagonalization Technique
The one that proves Q is countable with the diagonals
Uncountable Sets
Show that the set of real numbers is uncountable. Hint: Show that (0,1) as a subset of R is uncountable which would show R is also uncountable