Functions Aritra Hazra Department of Computer Science and - - PowerPoint PPT Presentation

functions
SMART_READER_LITE
LIVE PREVIEW

Functions Aritra Hazra Department of Computer Science and - - PowerPoint PPT Presentation

Functions Aritra Hazra Department of Computer Science and Engineering, Indian Institute of Technology Kharagpur, Paschim Medinipur, West Bengal, India - 721302. Email: aritrah@cse.iitkgp.ac.in Autumn 2020 Aritra Hazra (CSE, IITKGP) CS21001 :


slide-1
SLIDE 1

Functions

Aritra Hazra

Department of Computer Science and Engineering, Indian Institute of Technology Kharagpur, Paschim Medinipur, West Bengal, India - 721302. Email: aritrah@cse.iitkgp.ac.in

Autumn 2020

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 1 / 17

slide-2
SLIDE 2

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-3
SLIDE 3

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-4
SLIDE 4

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j. (2) Floor and ceiling functions, f : R → Z, are defined by, f (x) = ⌊x⌋ and g(y) = ⌈y⌉ (x, y ∈ R). f (2.7) = 2, f (−2.7) = −3, f (2) = 2, f (−2) = −2 and g(2.7) = 3, g(−2.7) = −2, g(2) = 2, g(−2) = −2.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-5
SLIDE 5

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j. (2) Floor and ceiling functions, f : R → Z, are defined by, f (x) = ⌊x⌋ and g(y) = ⌈y⌉ (x, y ∈ R). f (2.7) = 2, f (−2.7) = −3, f (2) = 2, f (−2) = −2 and g(2.7) = 3, g(−2.7) = −2, g(2) = 2, g(−2) = −2. Image and Pre-image: If f (a) = b, then b is the image of a under f and a is the pre-image of b.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-6
SLIDE 6

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j. (2) Floor and ceiling functions, f : R → Z, are defined by, f (x) = ⌊x⌋ and g(y) = ⌈y⌉ (x, y ∈ R). f (2.7) = 2, f (−2.7) = −3, f (2) = 2, f (−2) = −2 and g(2.7) = 3, g(−2.7) = −2, g(2) = 2, g(−2) = −2. Image and Pre-image: If f (a) = b, then b is the image of a under f and a is the pre-image of b. Domain and Codomain: In f : A → B, A is the domain of f and B is the codomain of f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-7
SLIDE 7

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j. (2) Floor and ceiling functions, f : R → Z, are defined by, f (x) = ⌊x⌋ and g(y) = ⌈y⌉ (x, y ∈ R). f (2.7) = 2, f (−2.7) = −3, f (2) = 2, f (−2) = −2 and g(2.7) = 3, g(−2.7) = −2, g(2) = 2, g(−2) = −2. Image and Pre-image: If f (a) = b, then b is the image of a under f and a is the pre-image of b. Domain and Codomain: In f : A → B, A is the domain of f and B is the codomain of f . Range: Set of all images for elements of A in B, f (A) ⊆ B.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-8
SLIDE 8

Basics of Functions

Functions: For two sets, A, B = φ, a function (or mapping) f from A to B, denoted as f : A → B, is a relation from A to B in which every element

  • f A appears exactly once in the first component of an ordered pair in

the relation. f (a) = b (a ∈ A, b ∈ B) when (a, b) is an ordered pair in the function f associating each a to an unique b. Thus, (a, b), (a, c) ∈ f ⇒ b = c. Example: (1) Access function of 2-D array in memory, f : A → N (A = (aij)m×n is an m × n array) is defined by, f (aij) = (i − 1)n + j. (2) Floor and ceiling functions, f : R → Z, are defined by, f (x) = ⌊x⌋ and g(y) = ⌈y⌉ (x, y ∈ R). f (2.7) = 2, f (−2.7) = −3, f (2) = 2, f (−2) = −2 and g(2.7) = 3, g(−2.7) = −2, g(2) = 2, g(−2) = −2. Image and Pre-image: If f (a) = b, then b is the image of a under f and a is the pre-image of b. Domain and Codomain: In f : A → B, A is the domain of f and B is the codomain of f . Range: Set of all images for elements of A in B, f (A) ⊆ B.

A B f(A)

a b f(a) = b image Range pre−image Domain Codomain

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 2 / 17

slide-9
SLIDE 9

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-10
SLIDE 10

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-11
SLIDE 11

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-12
SLIDE 12

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f . Restriction: If f : A → B and A′ ⊆ A, then f |A′ : A′ → B is called the restriction of f to A′ if f |A′(a) = f (a) for all a ∈ A′.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-13
SLIDE 13

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f . Restriction: If f : A → B and A′ ⊆ A, then f |A′ : A′ → B is called the restriction of f to A′ if f |A′(a) = f (a) for all a ∈ A′. Extension: Let A′ ⊆ A and f : A′ → B. If g : A → B and g(a) = f (a) for all a ∈ A′, then g is called an extension of f to A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-14
SLIDE 14

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f . Restriction: If f : A → B and A′ ⊆ A, then f |A′ : A′ → B is called the restriction of f to A′ if f |A′(a) = f (a) for all a ∈ A′. Extension: Let A′ ⊆ A and f : A′ → B. If g : A → B and g(a) = f (a) for all a ∈ A′, then g is called an extension of f to A. Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊆ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊆ f (A1) ∩ f (A2).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-15
SLIDE 15

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f . Restriction: If f : A → B and A′ ⊆ A, then f |A′ : A′ → B is called the restriction of f to A′ if f |A′(a) = f (a) for all a ∈ A′. Extension: Let A′ ⊆ A and f : A′ → B. If g : A → B and g(a) = f (a) for all a ∈ A′, then g is called an extension of f to A. Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊆ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊆ f (A1) ∩ f (A2). Proof: (ii) For each b ∈ B, b ∈ f (A1 ∩ A2) ⇒ b = f (a), for some a ∈ (A1 ∩ A2)

⇒ [b = f (a) for some a ∈ A1] ∧ [b = f (a) for some a ∈ A2] ⇒ b ∈ f (A1) ∧ b ∈ f (A2) ⇒ b ∈ f (A1) ∩ f (A2), implying the result.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-16
SLIDE 16

Properties of Functions

Number of Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = nm = |B||A| (by rule-of-product). Image of Subset: If f : A → B and A′ ⊆ A, then f (A′) = {b ∈ B | b = f (a)} (for some a ∈ A′), and f (A′) is called the image of A′ under f . Restriction: If f : A → B and A′ ⊆ A, then f |A′ : A′ → B is called the restriction of f to A′ if f |A′(a) = f (a) for all a ∈ A′. Extension: Let A′ ⊆ A and f : A′ → B. If g : A → B and g(a) = f (a) for all a ∈ A′, then g is called an extension of f to A. Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊆ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊆ f (A1) ∩ f (A2). Proof: (ii) For each b ∈ B, b ∈ f (A1 ∩ A2) ⇒ b = f (a), for some a ∈ (A1 ∩ A2)

⇒ [b = f (a) for some a ∈ A1] ∧ [b = f (a) for some a ∈ A2] ⇒ b ∈ f (A1) ∧ b ∈ f (A2) ⇒ b ∈ f (A1) ∩ f (A2), implying the result.

(i) and (ii) Left for You as an Exercise!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 3 / 17

slide-17
SLIDE 17

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-18
SLIDE 18

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-19
SLIDE 19

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|. Examples: (i) f : R → R where f (x) = 2x + 1, ∀x ∈ R is one-to-one; because for all x1, x2 ∈ R, we have f (x1) = f (x2) ⇒ 2x1 + 1 = 2x2 + 1 ⇒ x1 = x2.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-20
SLIDE 20

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|. Examples: (i) f : R → R where f (x) = 2x + 1, ∀x ∈ R is one-to-one; because for all x1, x2 ∈ R, we have f (x1) = f (x2) ⇒ 2x1 + 1 = 2x2 + 1 ⇒ x1 = x2. (ii) g : R → R where g(x) = x2 + x, ∀x ∈ R is NOT one-to-one; because g(−1) = 0 and g(0) = 0.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-21
SLIDE 21

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|. Examples: (i) f : R → R where f (x) = 2x + 1, ∀x ∈ R is one-to-one; because for all x1, x2 ∈ R, we have f (x1) = f (x2) ⇒ 2x1 + 1 = 2x2 + 1 ⇒ x1 = x2. (ii) g : R → R where g(x) = x2 + x, ∀x ∈ R is NOT one-to-one; because g(−1) = 0 and g(0) = 0. Number of Injective Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n) (m ≤ n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-22
SLIDE 22

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|. Examples: (i) f : R → R where f (x) = 2x + 1, ∀x ∈ R is one-to-one; because for all x1, x2 ∈ R, we have f (x1) = f (x2) ⇒ 2x1 + 1 = 2x2 + 1 ⇒ x1 = x2. (ii) g : R → R where g(x) = x2 + x, ∀x ∈ R is NOT one-to-one; because g(−1) = 0 and g(0) = 0. Number of Injective Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n) (m ≤ n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = n(n − 1) · · · (n − m + 1) =

n! (n−m)! = P(|B|, |A|).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-23
SLIDE 23

One-to-One or Injective Functions

One-to-one (Injective) Function: f : A → B is a one-to-one (or injective) function, if each element in B appears at most once as image of an element of A. For arbitrary sets A, B, f : A → B is one-to-one if and only if ∀a1, a2 ∈ A, f (a1) = f (a2) ⇒ a1 = a2. If f : A → B is one-to-one with A, B finite, then |A| ≤ |B|. Examples: (i) f : R → R where f (x) = 2x + 1, ∀x ∈ R is one-to-one; because for all x1, x2 ∈ R, we have f (x1) = f (x2) ⇒ 2x1 + 1 = 2x2 + 1 ⇒ x1 = x2. (ii) g : R → R where g(x) = x2 + x, ∀x ∈ R is NOT one-to-one; because g(−1) = 0 and g(0) = 0. Number of Injective Functions: Let A = {a1, . . . , am} (|A| = m) and B = {b1, . . . , bn} (|B| = n) (m ≤ n). f : A → B is described as, {(a1, x1), (a2, x2), . . . , (am, xm)}. So, Total Count = n(n − 1) · · · (n − m + 1) =

n! (n−m)! = P(|B|, |A|).

f : A → B, with A1, A2 ⊆ A. Then, f (A1 ∩ A2) = f (A1) ∩ f (A2), if f is one-to-one.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 4 / 17

slide-24
SLIDE 24

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-25
SLIDE 25

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-26
SLIDE 26

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|. Examples: (i) f : R → R where f (x) = x3 + 1, ∀x ∈ R is onto; because for each y = x3 + 1 ∈ R, there is an x =

3

√y − 1.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-27
SLIDE 27

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|. Examples: (i) f : R → R where f (x) = x3 + 1, ∀x ∈ R is onto; because for each y = x3 + 1 ∈ R, there is an x =

3

√y − 1. (ii) f : R → R where f (x) = x2, ∀x ∈ R is NOT onto; because for an y = −4 ∈ R, we get x =√y = 2i or − 2i ∈ R.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-28
SLIDE 28

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|. Examples: (i) f : R → R where f (x) = x3 + 1, ∀x ∈ R is onto; because for each y = x3 + 1 ∈ R, there is an x =

3

√y − 1. (ii) f : R → R where f (x) = x2, ∀x ∈ R is NOT onto; because for an y = −4 ∈ R, we get x =√y = 2i or − 2i ∈ R. Number of Onto Functions: Counting is non-trivial and will be addressed later!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-29
SLIDE 29

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|. Examples: (i) f : R → R where f (x) = x3 + 1, ∀x ∈ R is onto; because for each y = x3 + 1 ∈ R, there is an x =

3

√y − 1. (ii) f : R → R where f (x) = x2, ∀x ∈ R is NOT onto; because for an y = −4 ∈ R, we get x =√y = 2i or − 2i ∈ R. Number of Onto Functions: Counting is non-trivial and will be addressed later!

One-to-one & Onto (Bijective) Function:

f : A → B is bijective if it is both one-to-one (injective) and onto (surjective).

For arbitrary sets A, B, f : A → B is bijective if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b and ∀a′(= a) ∈ A, f (a′) = b. If f : A → B is bijective with A, B finite, then |A| = |B|.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-30
SLIDE 30

Onto or Surjective Functions

Onto (Surjective) Function: f : A → B is a onto (or surjective) function, if f (A) = B, i.e. for all b ∈ B there is at least one a ∈ A with f (a) = b. For arbitrary sets A, B, f : A → B is onto if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b. If f : A → B is onto with A, B finite, then |A| ≥ |B|. Examples: (i) f : R → R where f (x) = x3 + 1, ∀x ∈ R is onto; because for each y = x3 + 1 ∈ R, there is an x =

3

√y − 1. (ii) f : R → R where f (x) = x2, ∀x ∈ R is NOT onto; because for an y = −4 ∈ R, we get x =√y = 2i or − 2i ∈ R. Number of Onto Functions: Counting is non-trivial and will be addressed later!

One-to-one & Onto (Bijective) Function:

f : A → B is bijective if it is both one-to-one (injective) and onto (surjective).

For arbitrary sets A, B, f : A → B is bijective if and only if ∀b ∈ B, ∃a ∈ A, so that f (a) = b and ∀a′(= a) ∈ A, f (a′) = b. If f : A → B is bijective with A, B finite, then |A| = |B|.

Neither One−to−one, nor Onto (but a Relation) Not a Function Onto, but not One−to−one One−to−one, but not Onto One−to−one and Onto

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 5 / 17

slide-31
SLIDE 31

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-32
SLIDE 32

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Properties: Let f : A × A → B is a binary operation.

Commutativity: If ∀(x, y) ∈ A × A, f (x, y) = f (y, x) then f is commutative. Associativity: If f is closed and ∀x, y, z ∈ A, f (f (x, y), z) = f (x, f (y, z)), then f is associative.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-33
SLIDE 33

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Properties: Let f : A × A → B is a binary operation.

Commutativity: If ∀(x, y) ∈ A × A, f (x, y) = f (y, x) then f is commutative. Associativity: If f is closed and ∀x, y, z ∈ A, f (f (x, y), z) = f (x, f (y, z)), then f is associative.

Example

1

g : Z+ × Z+ → Z defined as g(x, y) = x − y, is a binary operation on Z which is NOT closed as g(1, 2) = −1 ∈ Z+, though 1, 2 ∈ Z+.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-34
SLIDE 34

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Properties: Let f : A × A → B is a binary operation.

Commutativity: If ∀(x, y) ∈ A × A, f (x, y) = f (y, x) then f is commutative. Associativity: If f is closed and ∀x, y, z ∈ A, f (f (x, y), z) = f (x, f (y, z)), then f is associative.

Example

1

g : Z+ × Z+ → Z defined as g(x, y) = x − y, is a binary operation on Z which is NOT closed as g(1, 2) = −1 ∈ Z+, though 1, 2 ∈ Z+.

2

h : R+ → R+ defined as h(x) = 1

x is an unary operation on R+. Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-35
SLIDE 35

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Properties: Let f : A × A → B is a binary operation.

Commutativity: If ∀(x, y) ∈ A × A, f (x, y) = f (y, x) then f is commutative. Associativity: If f is closed and ∀x, y, z ∈ A, f (f (x, y), z) = f (x, f (y, z)), then f is associative.

Example

1

g : Z+ × Z+ → Z defined as g(x, y) = x − y, is a binary operation on Z which is NOT closed as g(1, 2) = −1 ∈ Z+, though 1, 2 ∈ Z+.

2

h : R+ → R+ defined as h(x) = 1

x is an unary operation on R+. 3

f : Z × Z → Z defined as f (x, y) = x − y, is a closed binary operation on Z which is neither commutative nor associative. (Why?)

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-36
SLIDE 36

(Binary) Operations and Properties

Definition

Binary Operation: For non-empty sets, A, B, any function f : A × A → B is called a binary operation on A. If B ⊆ A then the binary operation is closed on A (also A is closed under f ). (Count: |B||A|2) Unary Operation: A function g : A → A is called unary (or monary) operation on A.

Properties: Let f : A × A → B is a binary operation.

Commutativity: If ∀(x, y) ∈ A × A, f (x, y) = f (y, x) then f is commutative. Associativity: If f is closed and ∀x, y, z ∈ A, f (f (x, y), z) = f (x, f (y, z)), then f is associative.

Example

1

g : Z+ × Z+ → Z defined as g(x, y) = x − y, is a binary operation on Z which is NOT closed as g(1, 2) = −1 ∈ Z+, though 1, 2 ∈ Z+.

2

h : R+ → R+ defined as h(x) = 1

x is an unary operation on R+. 3

f : Z × Z → Z defined as f (x, y) = x − y, is a closed binary operation on Z which is neither commutative nor associative. (Why?)

4

f : Z × Z → Z defined as f (a, b) = a + b − ab is both commutative and associative.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 6 / 17

slide-37
SLIDE 37

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-38
SLIDE 38

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-39
SLIDE 39

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

(Proof: Let two identities, x1, x2 ∈ A. Then, by definition f (x1, x2) = x1 = f (x2, x1) = x2, leading to contradiction!)

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-40
SLIDE 40

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

(Proof: Let two identities, x1, x2 ∈ A. Then, by definition f (x1, x2) = x1 = f (x2, x1) = x2, leading to contradiction!)

Example: f : Z × Z → Z defined as f (a, b) = a + b − ab has 0 as the unique identity, because f (a, 0) = a + 0 + a.0 = a = 0 + a + 0.a = f (0, a).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-41
SLIDE 41

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

(Proof: Let two identities, x1, x2 ∈ A. Then, by definition f (x1, x2) = x1 = f (x2, x1) = x2, leading to contradiction!)

Example: f : Z × Z → Z defined as f (a, b) = a + b − ab has 0 as the unique identity, because f (a, 0) = a + 0 + a.0 = a = 0 + a + 0.a = f (0, a). Projection: For sets A, B, if C ⊆ A × B, then – (i) πA : C → A defined by πA(a, b) = a, is called the projection on the first coordinate. (ii) πB : C → B defined by πB(a, b) = b, is called the projection on the second coordinate.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-42
SLIDE 42

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

(Proof: Let two identities, x1, x2 ∈ A. Then, by definition f (x1, x2) = x1 = f (x2, x1) = x2, leading to contradiction!)

Example: f : Z × Z → Z defined as f (a, b) = a + b − ab has 0 as the unique identity, because f (a, 0) = a + 0 + a.0 = a = 0 + a + 0.a = f (0, a). Projection: For sets A, B, if C ⊆ A × B, then – (i) πA : C → A defined by πA(a, b) = a, is called the projection on the first coordinate. (ii) πB : C → B defined by πB(a, b) = b, is called the projection on the second coordinate. Property: If C = A × B, then πA and πB both are onto functions.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-43
SLIDE 43

More Properties of Binary Operation

Properties: Let f : A × A → B is a binary operation.

Identity: x ∈ A is an identity (or identity element) for f if f (a, x) = f (x, a) = a, ∀a ∈ A. Property: If f has an identity, then that identity is unique.

(Proof: Let two identities, x1, x2 ∈ A. Then, by definition f (x1, x2) = x1 = f (x2, x1) = x2, leading to contradiction!)

Example: f : Z × Z → Z defined as f (a, b) = a + b − ab has 0 as the unique identity, because f (a, 0) = a + 0 + a.0 = a = 0 + a + 0.a = f (0, a). Projection: For sets A, B, if C ⊆ A × B, then – (i) πA : C → A defined by πA(a, b) = a, is called the projection on the first coordinate. (ii) πB : C → B defined by πB(a, b) = b, is called the projection on the second coordinate. Property: If C = A × B, then πA and πB both are onto functions. Example: Let A = B = R and C ⊆ A × B where C = {(x, y) | y = x2, x, y ∈ R}

representing the Euclidean plane that contains points on the parabola y = x2. Here, πA(3, 9) = 3 and πB(3, 9) = 9. Note that, πA(C) = R and hence πA is

  • nto (and one-to-one as well). Whereas, πB(C) = [0, +∞] ⊂ R and hence πB

is NOT onto (nor it is one-to-one as πB(2, 4) = 4 = πB(−2, 4)).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 7 / 17

slide-44
SLIDE 44

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-45
SLIDE 45

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-46
SLIDE 46

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-47
SLIDE 47

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g. Composite Function: If f : A → B and g : B → C, we define the composite function, g ◦ f : A → C by (g ◦ f )(a) = g(f (a)), ∀a ∈ A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-48
SLIDE 48

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g. Composite Function: If f : A → B and g : B → C, we define the composite function, g ◦ f : A → C by (g ◦ f )(a) = g(f (a)), ∀a ∈ A. Range of f ⊆ Domain of g – sufficient for Function Composition!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-49
SLIDE 49

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g. Composite Function: If f : A → B and g : B → C, we define the composite function, g ◦ f : A → C by (g ◦ f )(a) = g(f (a)), ∀a ∈ A. Range of f ⊆ Domain of g – sufficient for Function Composition! For two identity functions 1A : A → A and 1B : B → B, f ◦ 1A = f = 1B ◦ f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-50
SLIDE 50

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g. Composite Function: If f : A → B and g : B → C, we define the composite function, g ◦ f : A → C by (g ◦ f )(a) = g(f (a)), ∀a ∈ A. Range of f ⊆ Domain of g – sufficient for Function Composition! For two identity functions 1A : A → A and 1B : B → B, f ◦ 1A = f = 1B ◦ f . Example: Let f , g : R → R defined as, f (x) = x2 and g(x) = x + 1. Then,

(f ◦ g)(x) = x2 + 2x + 1 and (g ◦ f )(x) = x2 + 1. So, (f ◦ g)(x) = (g ◦ f )(x).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-51
SLIDE 51

Equal, Identity and Composite Functions

Identity Function: The function, 1A : A → A defined by 1A(a) = a (∀a ∈ A), is called the identity function for A. Equal Functions: Two functions f , g : A → B are said to be equal (denoted as f = g) if f (a) = g(a), ∀a ∈ A. Note: Domain and Codomain of f , g must also be the same! Example: f , g : R → Z are defined as, f (x) =

  • x,

if x ∈ Z ⌊x⌋ + 1, if x ∈ R − Z and g(x) = ⌈x⌉, then f (x) = g(x) for every x ∈ R (Why?). So, f = g. Composite Function: If f : A → B and g : B → C, we define the composite function, g ◦ f : A → C by (g ◦ f )(a) = g(f (a)), ∀a ∈ A. Range of f ⊆ Domain of g – sufficient for Function Composition! For two identity functions 1A : A → A and 1B : B → B, f ◦ 1A = f = 1B ◦ f . Example: Let f , g : R → R defined as, f (x) = x2 and g(x) = x + 1. Then,

(f ◦ g)(x) = x2 + 2x + 1 and (g ◦ f )(x) = x2 + 1. So, (f ◦ g)(x) = (g ◦ f )(x).

Commutativity of Function Compositions: Does NOT Hold!

Function Composition is NOT Commutative, that is, we shall NOT always have f ◦ g(x) = g ◦ f (x) for any two functions, f , g : A → A (and x ∈ A).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 8 / 17

slide-52
SLIDE 52

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-53
SLIDE 53

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-54
SLIDE 54

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Recursive Compositions of Functions

Let f : A → A. Then, f 1 = f , and for n ∈ Z+, f n+1 = f ◦ (f n) = (f n) ◦ f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-55
SLIDE 55

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Recursive Compositions of Functions

Let f : A → A. Then, f 1 = f , and for n ∈ Z+, f n+1 = f ◦ (f n) = (f n) ◦ f .

Bijective Nature of Function Compositions

If f : A → B and g : B → C both are one-to-one , then g ◦ f : A → C is one-to-one.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-56
SLIDE 56

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Recursive Compositions of Functions

Let f : A → A. Then, f 1 = f , and for n ∈ Z+, f n+1 = f ◦ (f n) = (f n) ◦ f .

Bijective Nature of Function Compositions

If f : A → B and g : B → C both are one-to-one , then g ◦ f : A → C is one-to-one. Proof: Let a1, a2 ∈ A.

(g ◦ f )(a1) = (g ◦ f )(a2) ⇒ g(f (a1)) = g(f (a2)) ⇒ f (a1) = f (a2) (as g is one-to-one). Again, f (a1) = f (a2) ⇒ a1 = a2 (as f is one-to-one). Hence, g ◦ f is one-to-one.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-57
SLIDE 57

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Recursive Compositions of Functions

Let f : A → A. Then, f 1 = f , and for n ∈ Z+, f n+1 = f ◦ (f n) = (f n) ◦ f .

Bijective Nature of Function Compositions

If f : A → B and g : B → C both are one-to-one , then g ◦ f : A → C is one-to-one. Proof: Let a1, a2 ∈ A.

(g ◦ f )(a1) = (g ◦ f )(a2) ⇒ g(f (a1)) = g(f (a2)) ⇒ f (a1) = f (a2) (as g is one-to-one). Again, f (a1) = f (a2) ⇒ a1 = a2 (as f is one-to-one). Hence, g ◦ f is one-to-one.

If f : A → B and g : B → C both are onto, then g ◦ f : A → C is onto.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-58
SLIDE 58

Composite Function Properties

Associativity of Function Compositions

If f : A → B, g : B → C and h : C → D, then (h ◦ g) ◦ f = h ◦ (g ◦ f ). Proof: For every x ∈ A, we can show, (h ◦ g ◦ f )(x) = (h ◦ g) ◦ f (x) = (h ◦ g)(f (x)) = h(g(f (x))) = h(g ◦ f (x)) = h ◦ (g ◦ f )(x).

C D B A

h o (g o f) (h o g) o f h o g g o f f g h

Recursive Compositions of Functions

Let f : A → A. Then, f 1 = f , and for n ∈ Z+, f n+1 = f ◦ (f n) = (f n) ◦ f .

Bijective Nature of Function Compositions

If f : A → B and g : B → C both are one-to-one , then g ◦ f : A → C is one-to-one. Proof: Let a1, a2 ∈ A.

(g ◦ f )(a1) = (g ◦ f )(a2) ⇒ g(f (a1)) = g(f (a2)) ⇒ f (a1) = f (a2) (as g is one-to-one). Again, f (a1) = f (a2) ⇒ a1 = a2 (as f is one-to-one). Hence, g ◦ f is one-to-one.

If f : A → B and g : B → C both are onto, then g ◦ f : A → C is onto. Proof: For any z ∈ C, ∃y ∈ B (as g is onto) and y ∈ B, ∃x ∈ A (as f is onto).

So, z = g(y) = g(f (x)) = (g ◦ f )(x) and Range of (g ◦ f ) = C = Codomain of (g ◦ f ).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 9 / 17

slide-59
SLIDE 59

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-60
SLIDE 60

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one). Explanation: f is one-to-one (Proof): Assuming f is NOT one-to-one, implies ∃x1, x2 ∈ A such that f (x1) = f (x2). So, g ◦ f (x1) = g ◦ f (x2), contradicting g ◦ f is injective!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-61
SLIDE 61

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one). Explanation: f is one-to-one (Proof): Assuming f is NOT one-to-one, implies ∃x1, x2 ∈ A such that f (x1) = f (x2). So, g ◦ f (x1) = g ◦ f (x2), contradicting g ◦ f is injective! g is not one-to-one (Example): f , g : R → R are defined as, f (x) = ex and g(x) = x2 (x ∈ R). Here, g ◦ f : R → R is defined as, g ◦ f (x) = e2x. So, (g ◦ f ) is one-to-one, but g is NOT (note that, f is one-to-one as proven)!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-62
SLIDE 62

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one). Explanation: f is one-to-one (Proof): Assuming f is NOT one-to-one, implies ∃x1, x2 ∈ A such that f (x1) = f (x2). So, g ◦ f (x1) = g ◦ f (x2), contradicting g ◦ f is injective! g is not one-to-one (Example): f , g : R → R are defined as, f (x) = ex and g(x) = x2 (x ∈ R). Here, g ◦ f : R → R is defined as, g ◦ f (x) = e2x. So, (g ◦ f ) is one-to-one, but g is NOT (note that, f is one-to-one as proven)! Let f : A → B and g : B → C and the composition g ◦ f : A → C is a onto (surjective)

  • function. Then, g is onto (however, f need NOT be onto).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-63
SLIDE 63

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one). Explanation: f is one-to-one (Proof): Assuming f is NOT one-to-one, implies ∃x1, x2 ∈ A such that f (x1) = f (x2). So, g ◦ f (x1) = g ◦ f (x2), contradicting g ◦ f is injective! g is not one-to-one (Example): f , g : R → R are defined as, f (x) = ex and g(x) = x2 (x ∈ R). Here, g ◦ f : R → R is defined as, g ◦ f (x) = e2x. So, (g ◦ f ) is one-to-one, but g is NOT (note that, f is one-to-one as proven)! Let f : A → B and g : B → C and the composition g ◦ f : A → C is a onto (surjective)

  • function. Then, g is onto (however, f need NOT be onto).

Explanation: g is onto (Proof): As (g ◦ f ) is onto, for any z ∈ C, ∃x ∈ A such that, z = g ◦ f (x) = g(f (x)), implying that z has a pre-image defined as f (x) ∈ B – thus making g onto.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-64
SLIDE 64

Composite Function Properties

Bijective Nature of Function Compositions

Let f : A → B and g : B → C and the composition g ◦ f : A → C is a one-to-one (injective) function. Then, f is one-to-one (however, g need NOT be one-to-one). Explanation: f is one-to-one (Proof): Assuming f is NOT one-to-one, implies ∃x1, x2 ∈ A such that f (x1) = f (x2). So, g ◦ f (x1) = g ◦ f (x2), contradicting g ◦ f is injective! g is not one-to-one (Example): f , g : R → R are defined as, f (x) = ex and g(x) = x2 (x ∈ R). Here, g ◦ f : R → R is defined as, g ◦ f (x) = e2x. So, (g ◦ f ) is one-to-one, but g is NOT (note that, f is one-to-one as proven)! Let f : A → B and g : B → C and the composition g ◦ f : A → C is a onto (surjective)

  • function. Then, g is onto (however, f need NOT be onto).

Explanation: g is onto (Proof): As (g ◦ f ) is onto, for any z ∈ C, ∃x ∈ A such that, z = g ◦ f (x) = g(f (x)), implying that z has a pre-image defined as f (x) ∈ B – thus making g onto. f is not onto (Example): f , g : Z → Z are defined as, f (x) = 2x and g(x) = ⌊ x

2 ⌋

(x ∈ Z). Here, g ◦ f : Z → Z is defined as, g ◦ f (x) = x. So, (g ◦ f ) is

  • nto, but f is NOT (note that, g is onto as proven)!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 10 / 17

slide-65
SLIDE 65

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-66
SLIDE 66

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively. Invertible Functions: A function f : A → B is said to be invertible if there exist a function f −1 : B → A such that f −1 ◦ f = 1A and f ◦ f −1 = 1B. f −1 is called the inverse function of f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-67
SLIDE 67

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively. Invertible Functions: A function f : A → B is said to be invertible if there exist a function f −1 : B → A such that f −1 ◦ f = 1A and f ◦ f −1 = 1B. f −1 is called the inverse function of f . Unique Inverse: An invertible function f : A → B has a unique inverse f −1 : B → A.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-68
SLIDE 68

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively. Invertible Functions: A function f : A → B is said to be invertible if there exist a function f −1 : B → A such that f −1 ◦ f = 1A and f ◦ f −1 = 1B. f −1 is called the inverse function of f . Unique Inverse: An invertible function f : A → B has a unique inverse f −1 : B → A.

(Proof: Assume two inverses, f −1

1

and f −1

2

. Using the definition, we get, f −1

1

= f −1

1

  • 1B = f −1

1

  • (f ◦ f −1

2

) = (f −1

1

  • f ) ◦ f −1

2

= 1A ◦ f −1

2

= f −1

2

.)

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-69
SLIDE 69

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively. Invertible Functions: A function f : A → B is said to be invertible if there exist a function f −1 : B → A such that f −1 ◦ f = 1A and f ◦ f −1 = 1B. f −1 is called the inverse function of f . Unique Inverse: An invertible function f : A → B has a unique inverse f −1 : B → A.

(Proof: Assume two inverses, f −1

1

and f −1

2

. Using the definition, we get, f −1

1

= f −1

1

  • 1B = f −1

1

  • (f ◦ f −1

2

) = (f −1

1

  • f ) ◦ f −1

2

= 1A ◦ f −1

2

= f −1

2

.)

Examples: (1) Let f , g : Z → Z are defined as f (x) = 2x and g(x) = ⌊ x+1

2 ⌋

(x ∈ Z). So, g ◦ f , f ◦ g : Z → Z are defined by, g ◦ f (x) = g(2x) = x and f ◦ g(x) = f (⌊ x+1

2 ⌋) =

x + 1, if x is odd x, if x is even . So, g ◦ f = 1Z

meaning g is the left inverse of f , but f ◦ g = 1Z meaning g is NOT the right inverse of f .

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-70
SLIDE 70

Inverse Functions and Invertibility

Inverse Functions: For a function f : A → B, if f −1

L

, f −1

R

: B → A are defined such that f −1

L

  • f = 1A and f ◦ f −1

R

= 1B, then f −1

L

and f −1

R

are called the left inverse and right inverse of f , respectively. Invertible Functions: A function f : A → B is said to be invertible if there exist a function f −1 : B → A such that f −1 ◦ f = 1A and f ◦ f −1 = 1B. f −1 is called the inverse function of f . Unique Inverse: An invertible function f : A → B has a unique inverse f −1 : B → A.

(Proof: Assume two inverses, f −1

1

and f −1

2

. Using the definition, we get, f −1

1

= f −1

1

  • 1B = f −1

1

  • (f ◦ f −1

2

) = (f −1

1

  • f ) ◦ f −1

2

= 1A ◦ f −1

2

= f −1

2

.)

Examples: (1) Let f , g : Z → Z are defined as f (x) = 2x and g(x) = ⌊ x+1

2 ⌋

(x ∈ Z). So, g ◦ f , f ◦ g : Z → Z are defined by, g ◦ f (x) = g(2x) = x and f ◦ g(x) = f (⌊ x+1

2 ⌋) =

x + 1, if x is odd x, if x is even . So, g ◦ f = 1Z

meaning g is the left inverse of f , but f ◦ g = 1Z meaning g is NOT the right inverse of f . (2) Let f , g : R → R are defined as f (x) = 2x and g(x) = x

2 (x ∈ R).

So, g ◦ f , f ◦ g : R → R are defined by, g ◦ f (x) = g(2x) = x and f ◦ g(x) = f ( x

2 ) = x. So, g ◦ f = f ◦ g = 1R meaning g is inverse of f . Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 11 / 17

slide-71
SLIDE 71

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-72
SLIDE 72

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-73
SLIDE 73

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective. [Only-If] Since f is bijective, y ∈ B has one and only one pre-image x ∈ A. We define f −1 : B → A as f −1(y) = x (pre-image of y under f ), y ∈ B. So, f −1 ◦ f (x) = f −1(y) = x and f ◦ f −1(y) = f (x) = y, implying f −1 ◦ f = 1A and f ◦ f −1 = 1B ⇒ f is invertible.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-74
SLIDE 74

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective. [Only-If] Since f is bijective, y ∈ B has one and only one pre-image x ∈ A. We define f −1 : B → A as f −1(y) = x (pre-image of y under f ), y ∈ B. So, f −1 ◦ f (x) = f −1(y) = x and f ◦ f −1(y) = f (x) = y, implying f −1 ◦ f = 1A and f ◦ f −1 = 1B ⇒ f is invertible. If f : A → B, g : B → C are invertible, then g ◦ f : A → C is invertible and (g ◦ f )−1 = f −1 ◦ g −1.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-75
SLIDE 75

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective. [Only-If] Since f is bijective, y ∈ B has one and only one pre-image x ∈ A. We define f −1 : B → A as f −1(y) = x (pre-image of y under f ), y ∈ B. So, f −1 ◦ f (x) = f −1(y) = x and f ◦ f −1(y) = f (x) = y, implying f −1 ◦ f = 1A and f ◦ f −1 = 1B ⇒ f is invertible. If f : A → B, g : B → C are invertible, then g ◦ f : A → C is invertible and (g ◦ f )−1 = f −1 ◦ g −1. Proof: f , g are invertible implies that f , g are bijective functions. So, (g ◦ f ) is also bijective and hence invertible (using above property).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-76
SLIDE 76

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective. [Only-If] Since f is bijective, y ∈ B has one and only one pre-image x ∈ A. We define f −1 : B → A as f −1(y) = x (pre-image of y under f ), y ∈ B. So, f −1 ◦ f (x) = f −1(y) = x and f ◦ f −1(y) = f (x) = y, implying f −1 ◦ f = 1A and f ◦ f −1 = 1B ⇒ f is invertible. If f : A → B, g : B → C are invertible, then g ◦ f : A → C is invertible and (g ◦ f )−1 = f −1 ◦ g −1. Proof: f , g are invertible implies that f , g are bijective functions. So, (g ◦ f ) is also bijective and hence invertible (using above property). (f −1 ◦ g −1) ◦ (g ◦ f ) = f −1 ◦ (g −1 ◦ g) ◦ f = f −1 ◦ 1B ◦ f = f −1 ◦ f = 1A. (g ◦ f ) ◦ (f −1 ◦ g −1) = 1B. So, (f −1 ◦ g −1) is the inverse of (g ◦ f ).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-77
SLIDE 77

Properties of Invertible Functions

Properties

f : A → B is invertible if and only if it is bijective (one-to-one + onto). Proof: [ If ] f is invertible means inverse function f −1 : B → A exists. f −1 ◦ f = 1A and 1A is injective, so f is injective. f ◦ f −1 = 1B and 1B is surjective, so f is surjective. [Only-If] Since f is bijective, y ∈ B has one and only one pre-image x ∈ A. We define f −1 : B → A as f −1(y) = x (pre-image of y under f ), y ∈ B. So, f −1 ◦ f (x) = f −1(y) = x and f ◦ f −1(y) = f (x) = y, implying f −1 ◦ f = 1A and f ◦ f −1 = 1B ⇒ f is invertible. If f : A → B, g : B → C are invertible, then g ◦ f : A → C is invertible and (g ◦ f )−1 = f −1 ◦ g −1. Proof: f , g are invertible implies that f , g are bijective functions. So, (g ◦ f ) is also bijective and hence invertible (using above property). (f −1 ◦ g −1) ◦ (g ◦ f ) = f −1 ◦ (g −1 ◦ g) ◦ f = f −1 ◦ 1B ◦ f = f −1 ◦ f = 1A. (g ◦ f ) ◦ (f −1 ◦ g −1) = 1B. So, (f −1 ◦ g −1) is the inverse of (g ◦ f ).

Example

f : R → R is defined by f (x) = 3x + 1 (x ∈ R). Note that, f is bijective (Why?) and hence invertible. Now, f −1 : R → R defined by f −1(y) = y−1

3 , y ∈ R. Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 12 / 17

slide-78
SLIDE 78

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-79
SLIDE 79

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-80
SLIDE 80

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-81
SLIDE 81

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible. Properties:

(RECAP) Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊂ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊂ f (A1) ∩ f (A2).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-82
SLIDE 82

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible. Properties:

(RECAP) Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊂ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊂ f (A1) ∩ f (A2). Note: In general, f (A1 ∩ A2) = f (A1) ∩ f (A2). Consider, f : R → R as f (x) = x2 and A1 = {0, 1, 1

2 , 1 3, . . .}, A2 = {0, −1, − 1 2, − 1 3, . . .}. Here,

f (A1 ∩ A2) = {0} = {0, 1, 1

22 , 1 32 } = f (A1) ∩ f (A2). Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-83
SLIDE 83

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible. Properties:

(RECAP) Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊂ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊂ f (A1) ∩ f (A2). Note: In general, f (A1 ∩ A2) = f (A1) ∩ f (A2). Consider, f : R → R as f (x) = x2 and A1 = {0, 1, 1

2 , 1 3, . . .}, A2 = {0, −1, − 1 2, − 1 3, . . .}. Here,

f (A1 ∩ A2) = {0} = {0, 1, 1

22 , 1 32 } = f (A1) ∩ f (A2).

Let f : A → B be an onto mapping, with B1, B2 ⊆ B. Then, (i) If B1 ⊂ B2 ⇒ f −1(B1) ⊂ f −1(B2), (ii) f −1(B1) = f −1(B1), (iii) f −1(B1 ∪ B2) = f −1(B1) ∪ f −1(B2), and (iv) f −1(B1 ∩ B2) = f −1(B1) ∩ f −1(B2).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-84
SLIDE 84

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible. Properties:

(RECAP) Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊂ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊂ f (A1) ∩ f (A2). Note: In general, f (A1 ∩ A2) = f (A1) ∩ f (A2). Consider, f : R → R as f (x) = x2 and A1 = {0, 1, 1

2 , 1 3, . . .}, A2 = {0, −1, − 1 2, − 1 3, . . .}. Here,

f (A1 ∩ A2) = {0} = {0, 1, 1

22 , 1 32 } = f (A1) ∩ f (A2).

Let f : A → B be an onto mapping, with B1, B2 ⊆ B. Then, (i) If B1 ⊂ B2 ⇒ f −1(B1) ⊂ f −1(B2), (ii) f −1(B1) = f −1(B1), (iii) f −1(B1 ∪ B2) = f −1(B1) ∪ f −1(B2), and (iv) f −1(B1 ∩ B2) = f −1(B1) ∩ f −1(B2). Proof: (i) Let x ∈ f −1(B1) ⇒ f (x) ∈ B1. Since B1 ⊂ B2, therefore

f (x) ∈ B1 ⇒ f (x) ∈ B2. So, x ∈ f −1(B2) implying f −1(B1) ⊂ f −1(B2).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-85
SLIDE 85

Properties with Direct and Inverse Images

Direct Image: Let f : A → B and (non-empty) A′ ⊆ A. The direct image of A′ under f is f (A′) ⊆ B given by, f (A′) = {f (x) | x ∈ A′}. Inverse Image: Let f : A → B and (non-empty) B′ ⊆ B. The inverse image (pre-image)

  • f B′ under f is f −1(B′) ⊆ A given by, f −1(B′) = {x | f (x) ∈ B′}.

Example: f : R → R is defined by f (x) = x2 (x ∈ R). Let P = {x ∈ R | x ∈ [0, 2]}. The direct image f (P) = {y | y ∈ [0, 4]} (y ∈ R) and the inverse image of set f (P) is f −1(f (P)) = {x | x ∈ [−2, 2]}. So, f −1(f (P)) = P and f is not a bijection / invertible. Properties:

(RECAP) Let f : A → B, with A1, A2 ⊆ A. Then, (i) If A1 ⊂ A2 ⇒ f (A1) ⊂ f (A2), (ii) f (A1 ∪ A2) = f (A1) ∪ f (A2), and (iii) f (A1 ∩ A2) ⊂ f (A1) ∩ f (A2). Note: In general, f (A1 ∩ A2) = f (A1) ∩ f (A2). Consider, f : R → R as f (x) = x2 and A1 = {0, 1, 1

2 , 1 3, . . .}, A2 = {0, −1, − 1 2, − 1 3, . . .}. Here,

f (A1 ∩ A2) = {0} = {0, 1, 1

22 , 1 32 } = f (A1) ∩ f (A2).

Let f : A → B be an onto mapping, with B1, B2 ⊆ B. Then, (i) If B1 ⊂ B2 ⇒ f −1(B1) ⊂ f −1(B2), (ii) f −1(B1) = f −1(B1), (iii) f −1(B1 ∪ B2) = f −1(B1) ∪ f −1(B2), and (iv) f −1(B1 ∩ B2) = f −1(B1) ∩ f −1(B2). Proof: (i) Let x ∈ f −1(B1) ⇒ f (x) ∈ B1. Since B1 ⊂ B2, therefore

f (x) ∈ B1 ⇒ f (x) ∈ B2. So, x ∈ f −1(B2) implying f −1(B1) ⊂ f −1(B2).

(ii), (iii) and (iv) Left for You as an Exercise!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 13 / 17

slide-86
SLIDE 86

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-87
SLIDE 87

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-88
SLIDE 88

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-89
SLIDE 89

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23;

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-90
SLIDE 90

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-91
SLIDE 91

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-92
SLIDE 92

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34;

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-93
SLIDE 93

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-94
SLIDE 94

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-95
SLIDE 95

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}. So, the final onto functions count = 34 − 3.24 + 3 = 3

3

  • 34 −

3

2

  • 24 +

3

1

  • 14.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-96
SLIDE 96

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}. So, the final onto functions count = 34 − 3.24 + 3 = 3

3

  • 34 −

3

2

  • 24 +

3

1

  • 14.

If |A| = m ≥ n = |B|, how many Onto functions? = O(m, n)

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-97
SLIDE 97

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}. So, the final onto functions count = 34 − 3.24 + 3 = 3

3

  • 34 −

3

2

  • 24 +

3

1

  • 14.

If |A| = m ≥ n = |B|, how many Onto functions? = O(m, n) What do the above steps reveal?

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-98
SLIDE 98

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}. So, the final onto functions count = 34 − 3.24 + 3 = 3

3

  • 34 −

3

2

  • 24 +

3

1

  • 14.

If |A| = m ≥ n = |B|, how many Onto functions? = O(m, n) What do the above steps reveal? ⇒ Principle of Inclusion-Exclusion!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-99
SLIDE 99

The Leftover: Number of Onto Functions under f : A → B

If 0 < |A| = m < n = |B|, how many Onto functions? = 0 If |A| = m = 1 = n = |B|, how many Onto functions? = 1 If |A| = m ≥ n = 2 = |B|, how many Onto functions? = 2m − 2 If A = {x, y, z}, B = {1, 2}, then all possible functions = |B||A| = 23; but f1 = {(x, 1), (y, 1), (z, 1)} and f2 = {(x, 2), (y, 2), (z, 2)} are NOT

  • nto. Hence, number of onto functions = 23 − 2 = 6.

If |A| = m ≥ n = 3 = |B|, how many Onto functions? = 3

3

  • 3m −

3

2

  • 2m +

3

1

  • 1m

If A = {w, x, y, z}, B = {1, 2, 3}, then all possible functions = 34; this includes 24 non-onto functions each from A → {1, 2}, A → {1, 3} and A → {2, 3}. Now, the running count for onto functions = 34 − 3.24. But, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)} twice – both during function removal from A → {1, 2}, A → {2, 3}. So, the final onto functions count = 34 − 3.24 + 3 = 3

3

  • 34 −

3

2

  • 24 +

3

1

  • 14.

If |A| = m ≥ n = |B|, how many Onto functions? = O(m, n) What do the above steps reveal? ⇒ Principle of Inclusion-Exclusion! O(m, n) = n

n

  • nm −

n

n−1

  • (n − 1)m +

n

n−2

  • (n − 2)m − · · · + (−1)n−2n

2

  • 2m + (−1)n−1n

1

  • 1m

=

n−1

  • i=0

(−1)i n

n−i

  • (n − i)m

=

n

  • i=0

(−1)i n

n−i

  • (n − i)m

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 14 / 17

slide-100
SLIDE 100

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-101
SLIDE 101

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-102
SLIDE 102

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-103
SLIDE 103

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Combinatorial Derivation: A Primer to ‘Principle of Inclusion-Exclusion’

Let m, n ∈ Z+ with 1 < n ≤ m. Then, S(m + 1, n) = S(m, n − 1) + n.S(m, n).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-104
SLIDE 104

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Combinatorial Derivation: A Primer to ‘Principle of Inclusion-Exclusion’

Let m, n ∈ Z+ with 1 < n ≤ m. Then, S(m + 1, n) = S(m, n − 1) + n.S(m, n). Proof:

S(m, n − 1) ways to distribute m objects into (n − 1) identical containers with none left empty and putting the (m + 1)th object into nth container alone ⇒ contributing S(m, n − 1) ways to S(m + 1, n).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-105
SLIDE 105

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Combinatorial Derivation: A Primer to ‘Principle of Inclusion-Exclusion’

Let m, n ∈ Z+ with 1 < n ≤ m. Then, S(m + 1, n) = S(m, n − 1) + n.S(m, n). Proof:

S(m, n − 1) ways to distribute m objects into (n − 1) identical containers with none left empty and putting the (m + 1)th object into nth container alone ⇒ contributing S(m, n − 1) ways to S(m + 1, n). S(m, n) ways to distribute m objects into n identical containers with none left empty and then placing (m + 1)th object in any of the already filled n containers ⇒ contributing n.S(m, n) ways to S(m + 1, n).

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-106
SLIDE 106

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Combinatorial Derivation: A Primer to ‘Principle of Inclusion-Exclusion’

Let m, n ∈ Z+ with 1 < n ≤ m. Then, S(m + 1, n) = S(m, n − 1) + n.S(m, n). Proof:

S(m, n − 1) ways to distribute m objects into (n − 1) identical containers with none left empty and putting the (m + 1)th object into nth container alone ⇒ contributing S(m, n − 1) ways to S(m + 1, n). S(m, n) ways to distribute m objects into n identical containers with none left empty and then placing (m + 1)th object in any of the already filled n containers ⇒ contributing n.S(m, n) ways to S(m + 1, n).

Corollary:

1 n [n!.S(m + 1, n)] = [(n − 1)!.S(m, n − 1)] + [n!.S(m, n)] (multiply by (n − 1)!) Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-107
SLIDE 107

Stirling Number of the Second Kind

Combinatorial Definition

For m ≥ n, Number of ways to distribute m objects into n identical (but numbered) containers with no container empty = n

i=0(−1)i n n−i

  • (n − i)m.

Removing numbering in containers yields the number of ways to distribute m

  • bjects into n perfectly identical containers with no container empty

=

1 n!

n

i=0(−1)i n n−i

  • (n − i)m = S(m, n) = Stirling Number of Second Kind.

Therefore, in f : A → B, number of onto functions, O(m, n) = n!.S(m, n).

Combinatorial Derivation: A Primer to ‘Principle of Inclusion-Exclusion’

Let m, n ∈ Z+ with 1 < n ≤ m. Then, S(m + 1, n) = S(m, n − 1) + n.S(m, n). Proof:

S(m, n − 1) ways to distribute m objects into (n − 1) identical containers with none left empty and putting the (m + 1)th object into nth container alone ⇒ contributing S(m, n − 1) ways to S(m + 1, n). S(m, n) ways to distribute m objects into n identical containers with none left empty and then placing (m + 1)th object in any of the already filled n containers ⇒ contributing n.S(m, n) ways to S(m + 1, n).

Corollary:

1 n [n!.S(m + 1, n)] = [(n − 1)!.S(m, n − 1)] + [n!.S(m, n)] (multiply by (n − 1)!)

⇒ 1

n .O(m + 1, n) = O(m, n − 1) + O(m, n) Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 15 / 17

slide-108
SLIDE 108

Counting Problems: Are these problems well-recognized now?

1

Suppose you set your computer password of length m from a fixed chosen set of n different characters available in the keyboard (m ≥ n). How many different passwords can you set so that at least one occurrence of each symbol (from the n chosen set of keyboard symbols) will be present?

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 16 / 17

slide-109
SLIDE 109

Counting Problems: Are these problems well-recognized now?

1

Suppose you set your computer password of length m from a fixed chosen set of n different characters available in the keyboard (m ≥ n). How many different passwords can you set so that at least one occurrence of each symbol (from the n chosen set of keyboard symbols) will be present?

2

An m × n 2-dimensional (2-D) array, (aij)m×n having m rows and n columns, is filled up with only 0 and 1 values. How many different 2-D arrays you can construct so that exactly one 1 is present in each row and at least one 1 is present at each column?

(Such arrays / adjacency-matrices are used to represent graph data structures!)

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 16 / 17

slide-110
SLIDE 110

Counting Problems: Are these problems well-recognized now?

1

Suppose you set your computer password of length m from a fixed chosen set of n different characters available in the keyboard (m ≥ n). How many different passwords can you set so that at least one occurrence of each symbol (from the n chosen set of keyboard symbols) will be present?

2

An m × n 2-dimensional (2-D) array, (aij)m×n having m rows and n columns, is filled up with only 0 and 1 values. How many different 2-D arrays you can construct so that exactly one 1 is present in each row and at least one 1 is present at each column?

(Such arrays / adjacency-matrices are used to represent graph data structures!)

3

m different component manufacturing contracts of a high-security project is to be executed by n different companies so that every company works on some components of the project. How many possible ways these m contracts can get assigned to n companies?

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 16 / 17

slide-111
SLIDE 111

Counting Problems: Are these problems well-recognized now?

1

Suppose you set your computer password of length m from a fixed chosen set of n different characters available in the keyboard (m ≥ n). How many different passwords can you set so that at least one occurrence of each symbol (from the n chosen set of keyboard symbols) will be present?

2

An m × n 2-dimensional (2-D) array, (aij)m×n having m rows and n columns, is filled up with only 0 and 1 values. How many different 2-D arrays you can construct so that exactly one 1 is present in each row and at least one 1 is present at each column?

(Such arrays / adjacency-matrices are used to represent graph data structures!)

3

m different component manufacturing contracts of a high-security project is to be executed by n different companies so that every company works on some components of the project. How many possible ways these m contracts can get assigned to n companies?

4

For m, n ∈ Z+ with m < n, prove that,

n

  • k=0

(−1)k n

n−k

  • (n − k)m = 0.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 16 / 17

slide-112
SLIDE 112

Counting Problems: Are these problems well-recognized now?

1

Suppose you set your computer password of length m from a fixed chosen set of n different characters available in the keyboard (m ≥ n). How many different passwords can you set so that at least one occurrence of each symbol (from the n chosen set of keyboard symbols) will be present?

2

An m × n 2-dimensional (2-D) array, (aij)m×n having m rows and n columns, is filled up with only 0 and 1 values. How many different 2-D arrays you can construct so that exactly one 1 is present in each row and at least one 1 is present at each column?

(Such arrays / adjacency-matrices are used to represent graph data structures!)

3

m different component manufacturing contracts of a high-security project is to be executed by n different companies so that every company works on some components of the project. How many possible ways these m contracts can get assigned to n companies?

4

For m, n ∈ Z+ with m < n, prove that,

n

  • k=0

(−1)k n

n−k

  • (n − k)m = 0.

5

For n ∈ Z+, verify that,

n

  • k=0

(−1)n n

n−k

  • (n − k)n = n!.

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 16 / 17

slide-113
SLIDE 113

Thank You!

Aritra Hazra (CSE, IITKGP) CS21001 : Discrete Structures Autumn 2020 17 / 17