COMP9020 Lecture 3 Session 2, 2016 Sets, Functions, and Sequences. Revision: 1.3

Similar documents
COMP9020 Lecture 3 Session 2, 2014 Sets, Functions, and Sequences. Revision: 1.3

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

Mathematics Review for Business PhD Students

Chapter 1 : The language of mathematics.

2.1 Sets. Definition 1 A set is an unordered collection of objects. Important sets: N, Z, Z +, Q, R.

Week Some Warm-up Questions

Mathematics Review for Business PhD Students Lecture Notes

Automata Theory and Formal Grammars: Lecture 1

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

Introduction to Automata

Part IA Numbers and Sets

Chapter Summary. Sets The Language of Sets Set Operations Set Identities Functions Types of Functions Operations on Functions Computability

Sets McGraw-Hill Education

POL502: Foundations. Kosuke Imai Department of Politics, Princeton University. October 10, 2005

Propositional Logic, Predicates, and Equivalence

Sets and Functions. (As we will see, in describing a set the order in which elements are listed is irrelevant).

Sets and Functions. MATH 464/506, Real Analysis. J. Robert Buchanan. Summer Department of Mathematics. J. Robert Buchanan Sets and Functions

0 Sets and Induction. Sets

Chapter Summary. Sets (2.1) Set Operations (2.2) Functions (2.3) Sequences and Summations (2.4) Cardinality of Sets (2.5) Matrices (2.

Mathematical Background and Basic Notations

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Discrete Mathematics. (c) Marcin Sydow. Sets. Set operations. Sets. Set identities Number sets. Pair. Power Set. Venn diagrams

Notation Index. gcd(a, b) (greatest common divisor) NT-16

Analysis I. Classroom Notes. H.-D. Alber

Introduction to Proofs

Background for Discrete Mathematics

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

Chapter 2 - Basics Structures MATH 213. Chapter 2: Basic Structures. Dr. Eric Bancroft. Fall Dr. Eric Bancroft MATH 213 Fall / 60

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

CHAPTER THREE: RELATIONS AND FUNCTIONS

CSCE 222 Discrete Structures for Computing

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions

Part I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS

CSCE 222 Discrete Structures for Computing. Review for Exam 1. Dr. Hyunyoung Lee !!!

1.A Sets, Relations, Graphs, and Functions 1.A.1 Set a collection of objects(element) Let A be a set and a be an elements in A, then we write a A.

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

MAT115A-21 COMPLETE LECTURE NOTES

Automata and Languages

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

2.2 Lowenheim-Skolem-Tarski theorems

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

With Question/Answer Animations. Chapter 2

586 Index. vertex, 369 disjoint, 236 pairwise, 272, 395 disjoint sets, 236 disjunction, 33, 36 distributive laws

CISC 1100: Structures of Computer Science

1 Chapter 1: SETS. 1.1 Describing a set

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

BASIC MATHEMATICAL TECHNIQUES

Exercises for Unit VI (Infinite constructions in set theory)

Discrete Mathematics. W. Ethan Duckworth. Fall 2017, Loyola University Maryland

Section 0. Sets and Relations

A Semester Course in Basic Abstract Algebra

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 2336 Discrete Mathematics

Sets. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Fall 2007

A function is a special kind of relation. More precisely... A function f from A to B is a relation on A B such that. f (x) = y

Outline. Sets. Relations. Functions. Products. Sums 2 / 40

Chapter 2 - Basics Structures

Sets. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

A B is shaded A B A B

FOUNDATIONS & PROOF LECTURE NOTES by Dr Lynne Walling

Foundations of Mathematics

Sets and Motivation for Boolean algebra

Discrete Basic Structure: Sets

Math 455 Some notes on Cardinality and Transfinite Induction

BOOLEAN ALGEBRA INTRODUCTION SUBSETS

Topics in Logic and Proofs

Computer Science Foundation Exam

2 Lecture 2: Logical statements and proof by contradiction Lecture 10: More on Permutations, Group Homomorphisms 31

9 FUNCTIONS. 9.1 The Definition of Function. c Dr Oksana Shatalov, Fall

Final Exam Review. 2. Let A = {, { }}. What is the cardinality of A? Is

Lecture Notes on Discrete Mathematics. October 15, 2018 DRAFT

Notes on Sets for Math 10850, fall 2017

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161

Reading 11 : Relations and Functions

Math 13, Spring 2013, Lecture B: Midterm

Math Fall 2014 Final Exam Solutions

5 FUNCTIONS. 5.1 Definition and Basic Properties. c Dr Oksana Shatalov, Fall

Chapter 1 The Real Numbers

Chapter 2 Sets, Relations and Functions

Notes. Functions. Introduction. Notes. Notes. Definition Function. Definition. Slides by Christopher M. Bourke Instructor: Berthe Y.

18.S097 Introduction to Proofs IAP 2015 Lecture Notes 1 (1/5/2015)

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

Discrete Mathematics

Chapter 0. Introduction: Prerequisites and Preliminaries

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

Foundations Revision Notes

X-MA2C01-1: Partial Worked Solutions

S15 MA 274: Exam 3 Study Questions

Number Theory and Counting Method. Divisors -Least common divisor -Greatest common multiple

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

SETS AND FUNCTIONS JOSHUA BALLEW

A set is an unordered collection of objects.

ICS141: Discrete Mathematics for Computer Science I

Boolean Algebras. Chapter 2

Supplement. Dr. Bob s Modern Algebra Glossary Based on Fraleigh s A First Course on Abstract Algebra, 7th Edition, Sections 0 through IV.

Review CHAPTER. 2.1 Definitions in Chapter Sample Exam Questions. 2.1 Set; Element; Member; Universal Set Partition. 2.

Review 1. Andreas Klappenecker

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

In this initial chapter, you will be introduced to, or more than likely be reminded of, a

Transcription:

1 COMP9020 Lecture 3 Session 2, 2016 Sets, Functions, and Sequences Revision: 1.3

2 Divisibility Let m, n Z. m n means m is a divisor of n, defined by n = km for some k Z (Also stated as: n is divisible by m, m is a divisor of n.) m n - negation of m n Notion of divisibility applies to all integers positive, negative and zero. 1 m, 1 m, m m, m m, for every m 0 n 0 for every n; 0 n except n = 0

3 Notions derived from divisibility Numbers > 1 divisible only by 1 and themselves are primes. The greatest common divisor of m, n Z is gcd(m, n) = max { d N d m d n }. Numbers m and n s.t. gcd(m, n) = 1 are said to be relatively prime or co-prime. The least common multiple of n, m Z is lcm(m, n) = min { d N m d n d }. NB gcd(m, n) and lcm(m, n) are always taken as positive gcd( 4, 6) = gcd(4, 6) = gcd( 4, 6) = gcd(4, 6) = 2 lcm( 5, 5) =... = 5

4 Absolute Value x = { x, if x 0 x, if x < 0 NB gcd(m, n) lcm(m, n) = m n

5 NB Representing fractions (i.e. rational numbers) in the form r = 1 n 1 + 1 n 2 +... + 1 n k, n 1 > n 2 >... > n k is called Egyptian fractions. Note that all denominators must be different; it is always possible, but not always easy.

6 Sets A set is defined by the collection of its elements. Sets are typically described by: (a) Explicit enumeration of their elements S 1 = {a, b, c} = {a, a, b, b, b, c} = {b, c, a} =... three elements S 2 = {a, {a}} S 3 = {a, b, {a, b}} S 4 = {} S 5 = {{{}}} S 6 = { {}, {{}} } two elements zero elements three elements one element two elements

7 (b) Specifying the properties their elements must satisfy; the elements are taken from some universal domain. A typical description involves a logical property P(x) S = { x x X P(x) } = { x X P(x) } We distinguish between an element and the set comprising of this single element. Thus always a {a}. Set {} is empty (no elements); set {{}} is nonempty it has one element. There is only one empty set; only one set consisting of a single a; only one set of all natural numbers.

8 (c) Constructions from other sets (S, T, already defined) Union S T, intersection S T, set difference S \ T, symmetric difference S T, complementation S Power set pow(x ) = { A A X } Cartesian product (below) Empty set, also written {} X for all sets X. S T S is a subset of T ; includes the case of T T S T a proper subset: S T and S T NB An element of a set and a subset of that set are two different concepts a {a, b}, a {a, b}; {a} {a, b}, {a} / {a, b}

9 Cardinality Number of elements in a set X ; (various notations) X = #(X ) = card(x ) Always pow(x ) = 2 X [m.. n] interval of integers; it is empty if n < m [m.. n] = n m + 1, for n m = 0 pow( ) = { } pow( ) = 1 pow(pow( )) = {, { }}... {a} = 1 pow({a}) = {, {a}} pow({a}) = 2...

10 Examples Find the cardinalities of sets 1 { 1 n n [1.. 4] } = 4 four indices, no repetitions of values 2 { n 2 n n [0.. 4] } = 4 one repetition of value 3 { 1 n 2 n N >0 2 n n < 11 } = 5 4 { 2 + ( 1) n n N } = 2 which are the two elements?

11 Sets of Numbers Natural numbers N = {0, 1, 2,...} Positive integers N >0 = {1, 2,...} common notation N >0 = Z >0 = N \ 0 Integers Z = {..., n, (n 1),..., 1, 0, 1, 2,...} Rational numbers (fractions) Q = { } m n m, n Z, n 0 Real numbers R In N >0 N Z different symbols denote different numbers. In Q and R the standard representation is not necessarily unique.

12 NB Proper ways to introduce reals include Dedekind cuts and Cauchy sequences, neither of which will be discussed here. Natural numbers etc. are either axiomatized or constructed a from sets (0 = def {}, n + 1 = def n {n}) a If we need to emphasise that an object (expression, formula) is defined through an equality we use the symbol def =. It denotes that the object on the left is defined by the formula/expression given on the right.

13 Number sets and their containments Derived sets of positive numbers N >0 N Z Q R N >0 = Z >0 = {n : n 1} Q >0 = {r : r = k l > 0} R >0 Derived sets of integers 2Z = { 2x x Z } 3Z + 1 = { 3x + 1 x Z } the even numbers

14 Intervals of numbers (applies to any type) [a, b] = { x a x b } (a, b) = { x a < x < b } [a, b] [a, b) (a, b] (a, b) NB (a, a) = (a, a] = [a, a) = ; however [a, a] = {a}. Intervals of N >0, N, Z are finite: if m n [m.. n] = {m, m + 1,..., n} [m.. n] = n m + 1

15 Set Operations Union A B; Intersection A B Note that there is a correspondence between set operations and logical operators One can match set A with that subset of the universal domain, where the property a holds, then match B with the subset where b holds. Then A B a or b; A B a and b We say that A, B are disjoint if A B =. NB A B = B A B A B = B A B

16 Other set operations A \ B difference, set difference, relative complement. It corresponds (logically) to a but not b A B symmetric difference A B = def (A \ B) (B \ A) It corresponds to a and not b or b and not a; it is termed xor (exclusive or) A c = A set complement w.r.t. the universe. It corresponds to not a.

17 Cartesian Product S T = def { (s, t) s S, t T }, where (s, t) is an ordered pair n i=1s i def = { (s 1,..., s n ) s k S k, for 1 k n } S 2 = S S, S 3 = S S S,..., S n = n 1 S,... S =, for every S S T = S T, n i=1 S i = n i=1 S i

18 Venn diagrams are a simple graphical tool to reason about the algebraic properties of set operations. S T S T De Morgan laws are the rules satisfied by set operations, esp. those involving complementation. They are often termed set algebra rules, due to their partial correspondence to the algebra of positive integers.

19 Examples Σ = {a, b} (a) All subsets of Σ :, {a}, {b}, {a, b} (b) pow(σ) = 4 A A =?, A =? A for all A Relate the cardinalities A B = A + B A B hence A B + A B = A + B A \ B = A A B A B = A + B 2 A B

20 Formal Languages Σ alphabet, a finite, nonempty set Examples (of various alphabets and their intended uses) Σ = {a, b,..., z} for single words (in lower case) Σ = {,, a, b,..., z} for composite terms Σ = {0, 1} for binary integers Σ = {0, 1,..., 9} for decimal integers The above cases all have a natural ordering; it is not required in general, thus the set of all Chinese characters forms a (formal) alphabet.

21 word - any finite string of symbols from Σ ω = aba, ω = 01101... 1,... also: empty word λ length(ω) # of symbols in ω length(aaa) = 3, length(λ) = 0 The only operation on words (discussed here) is concatenation, written as juxtaposition νω, ωνω, abω, ωbν,... NB λω = ω = ωλ length(νω) = length(ν) + length(ω)

22 Notation: Σ k set of all words of length k We often identify Σ 0 = {λ}, Σ 1 = Σ. Σ set of all words (of all lengths) Σ + set of all nonempty words (of any positive length) Σ = Σ 0 Σ 1 Σ 2... ; Σ n = Σ + = Σ 1 Σ 2... = Σ \ {λ} n i=0 Σ i A language is a subset of Σ. Typically, only the subsets that can be formed (or described) according to certain rules are of interest. Such a collection of descriptive/formative rules is termed a grammar.

23 Examples Number of elements in the sets (cont d) (e) Σ where Σ = {a, b, c} Σ = (f) { ω Σ length(ω) 4 } where Σ = {a, b, c} Σ 4 = 3 0 + 3 1 +... + 3 4 = 35 1 3 1 = 243 1 2 = 121

24 Examples Number of elements in the sets (cont d) (e) Σ where Σ = {a, b, c} Σ = (f) { ω Σ length(ω) 4 } where Σ = {a, b, c} Σ 4 = 3 0 + 3 1 +... + 3 4 = 35 1 3 1 = 243 1 2 = 121

25 Functions and their Properties We deal with functions as a set-theoretic concept, it being a special kind of correspondence (between two sets). In [LLM], the term function refers to partial mappings f : S T that, for every element s S, either assign to a unique element t T or is undefined. To emphasise where a specific element is sent, we can write f : x y, which is equivalent to f (x) = y. dom(f ) = def { s S t T (f (s) = t) } the domain of f. (Which means LLM have no name for A.) We call f total if dom(f ) = S. f (A) = { f (s) s A dom(f ) } the image of A under f. We call Codom(f ) = def T the codomain of f. Not to be confused with ran(f ) = def f (S) = { f (x) x dom(f ) } the range of f. We observe that every function maps its domain onto its image, but only into its codomain. A function is called surjective (or onto) if its codomain equals its range. (LLM write S surj T if there exists a surjective function

26 A function f : S T is called injective (or 1 1, one-to-one) (LLM write S inj T if such a function exists) if different x implies different f (x), i.e. x, y dom(f ) (f (x) = f (y) x = y) Examples (of functions that are not injective) absolute value floor, ceiling length of a word most functions of two or more arguments, when viewed as a function of a single pair of arguments

Composition of Functions Composition of functions is described as g f : x g(f (x)), requiring ran(f ) dom(g) If a function maps a set into itself, i.e. when dom(f ) = Codom(f ) (and thus ran(f ) dom(f )), the function can be composed with itself iterated 27 f f, f f f,..., written also f 2, f 3,... Composition is associative h (g f ) = (h g) f, can write h g f Identity function on S Id S (x) = x, for x S; dom(id S ) = Codom(Id S ) = ran(id S ) = S For g : S T g Id S = g and Id T g = g

28 gcd Example Reconsider gcd as a higher-order function, defined by m if m = n gcd(f )(m, n) = f (m n, n) if m > n f (m, n m) if m < n Its type is now gcd : (N 2 >0 N >0 ) (N 2 >0 N >0 ) that is, it maps each partial function (from pairs of positive integers to a positive integer) to a (partial) function of the same type. The worst such function is the nowhere defined function f (m, n) =.

29 Consider the sequence gcd Example cont d f, gcd(f ), gcd(gcd(f )),..., gcd i (f ),... and observe that the i th element of this sequence is an approximation of the gcd function that works as long as the depth of the recursion is less than i 1. Since we proved that the original gcd function terminates, we can deduce that the limit of this sequence exists, and is the original gcd. It also is the least fixpoint of gcd i.e. the simplest solution f to the equation f = gcd(f ). This, in a nutshell, explains how the semantics of recursive procedures is defined in CS. How all this works is somewhat beyond the scope of COMP9020 but still serves the purpose of motivating why we discuss functions, their composition, iteration, and fixpoints.

30 Properties of Functions We ve met: injective, surjective Inverse function f 1 : T S; for a given f : S T exists exactly when f is both 1 1 and onto. Image of a subdomain A under a function f (A) = { f (s) s A } = { t T t = f (s) for some s A } Inverse image - f (B) = { s S f (s) B } S; it is defined for every f If f 1 exists then f (B) = f 1 (B) f ( ) =, f ( ) = dom(f )