CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Final review 2
What did we study? Boolean logic: propositions, predicates, formulas, truth tables, CNFs, DNFs Data representation: graphs, sets, functions, relations, equivalence relations Proofs: direct, contrapositive, contradiction, cases, induction, strong induction Number theory: factorization to primes, GCD, basis representation, modular arithmetics Number theory algorithms: div-mod, fast exponentiation, casting out 9s 3
What did we really study? Language of mathematics Expression intuitive (or not) ideas in a formal language Giving formal proofs for mathematical theorems 4
Boolean logic 5
Propositional logic What is a proposition? How to translate from English to logic, and vice versa Connectives Truth tables CNFs, DNFs Equivalence rules 6
Propositional logic You should know: Translating English from/to logic Negating / De-Morgan laws Computing truth tables from formulas Computing CNFs / DNFs from truth table Equivalence rules, derivation rules 7
Predicate logic Universal / existential quantifiers Multiple quantifiers Negation / De-Morgan laws The importance of the domain 8
Predicate logic You should know: Translating English from/to logic Negating / De-Morgan laws Equivalence rules, derivation rules Deciding if a quantified formula is true/false in a specific domain 9
Data representation 10
Graphs What do graphs represent? Examples.. Terminology: vertices, edges, degree Directed / undirected graphs (Eulerian graphs – not for final) 11
Sets Definition, notations, examples Operations: union, intersection, complement, difference, power set, Cartesian product Expressing sets (eg primes) using set builder notation Venn diagrams, algebraic / symbolic proofs Set sizes, and how these change under the above operations Infinite sets 12
Relations What do they represent? Examples.. Connection to graphs Types: reflexive, symmetric, transitive How to prove / disprove that a relation is reflexive / symmetric / transitive 13
Equivalence relations Definition How to prove/disprove Important example: modular arithmetics (equivalent MOD m) 14
Functions Definition, examples Injective, surjective, bijective Inverse function Proving properties of set sizes using functions 15
Proofs 16
Direct proof To prove p q Assume p, plug in definitions, derive q 17
Contrapositive proof To prove p q Prove instead ~q ~p Assume ~q, plug in definitions, derive ~p 18
Proof by contradiction To prove p q Assume p,~q and derive a contradiction (either to one of the assumptions, or to a basic axiom) 19
Proof by cases To prove p q Partition assumption p into cases Prove each case individually, using any of the previous proof techniques 20
Induction Useful to prove theorems of the form: for all n>=1, some P(n) holds Base: n=1 (say) Basic induction: assume true for n-1, prove for n Strong induction: assume true for all k=1,…,n-1, prove for n 21
Number theory + algorithms 22
Primes Definition of primes / composites Every integer has a unique factorization as a product of prime numbers If p is prime, p|xy p|x or p|y Hard to find – basis for RSA encryption 23
GCD Greatest common divisor of 2 numbers Can find efficiently using Euclid’s algorithm 24
Modular arithmetics Definitions “x MOD m” Addition, multiplication Inversion when m is prime 25
Number theory algorithms DIV-MOD: Divide a by b, get quotient q and reminder r: a=bp+r Fast exponentiation: compute a b using only ~log(b) multiplications Casting out 9s: check if a number is divisible by 9 26
Review questions 27
Question 1 28
Question 2 29
Question 3 Let G be an undirected graph with n vertices and no loops. What is the maximal possible number of edges in G? A. n B. n 2 C. n(n-1)/2 D. n 2 /2 30
Question 4 31
Question 5 32
Question 6 33
Some words for conclusion I enjoyed teaching you, I hope that you enjoyed the class as well I hope that it opened your mind to the wonderful world of mathematics, and its many applications in computer science; this was just the first step Good luck in the final! 34