Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.

Similar presentations


Presentation on theme: "CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries."— Presentation transcript:

1 CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries

2 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Set theory A set is a collection of objects. These objects are referred to as its elements. The order of these elements is not important. The size of a set is its cardinality - | | Natural number when the set is finite  when the set is infinite Empty set has cardinality of zero - |ø| = zero.

3 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Membership Set membership is denoted using and non membership by – a {a, b} and c {a, b} –apple {apple, pear, banana} –apple {apples, pears, bananas}

4 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Subsets A set A whose elements are also elements of a set B is called a subset of B A B A = {0,1,2} and B = {0,2,3,4,1} then A B If |B| > |A| then A is known as a proper subset of B, denoted by A B. Note, A A and ø A for all sets A. If A = B then A B and B A.

5 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Some Elementary Logic and or implies/only if not universal qualifier (for all) existential qualifier (there exists)

6 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth More Set Theory union - all the elements of both sets but no duplicates intersection - all the elements that are in both sets - difference (A – B) - the set of elements that are in A but not in B symmetric difference - the set of elements belonging to one but not both of two given sets. It is therefore the union of the complement of A with respect to B and B with respect to A, and corresponds to the XOR operation in Boolean logic.

7 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Power Set The power set 2 n is the set of all possible subsets of A including ø and A itself. If A is finite and consists of n elements, then the power set has 2 n elements. e.g. if A = {a,b} then 2 A = {ø, {a}, {b}, {a,b}} e.g. if A = {a,b,c} then 2 A = {ø, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}

8 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Relations an ordered pair of elements It differs from {a,b} in that: The order of the elements if important The same element may occur twice

9 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cartesian Product The Cartesian product (A×B) is the set of all ordered pairs with x A and y B Therefore if A = {0,1,2} and B = {c,d} then A×B = {,,,,, } B×A = {,,,,, }

10 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Binary Relation Any subset (call it R) of A×B is called a binary relation between A and B –R = {, } is a binary relation between A and B (A = {0, 1, 2} and B = {c, d}) –Note that the singular ‘binary relation’ relates to a set of ordered pairs

11 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Predicate The predicate R(a,b) is true if R In future when we talk about a relation R we mean the combination of the set R and its implicit predicate R() a ^ b where the predicate R(a,b) = true The domain = {a:a} and The codomain (range) = {b:b} If we have more than one ordered pair we call it an ordered n-tuple.

12 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Functions A function f: A → B is a binary relation between A and B where only one tuple exists for each a A f may be written f(a) = b

13 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Functions Given a function f(a) = b we can say: –The value of f is a in b –a is the argument and b is the value –f is injective if there is a unique b B for every a A –f is surjective if every b B has an a A –f is bijective if it is both injective and surjective

14 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Recap: Number Sequences Natural numbers (N): the whole positive numbers including zero: 0, 1, 2, 3,.... Integers numbers (Z): the natural numbers plus their negative counterparts: …,-2,-1,0,1,2,… Rational numbers (Q): the integers plus the rational fractions - those that can be expressed as the ratio of two integers: ⅓,⅜,… Real numbers (R): the rational numbers plus the irrational numbers: 0.000123, 1.24,…

15 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets The Cardinality is the number of elements of a finite set - |A| What about infinite sets? An infinite set contains infinitely many elements – can’t write a list of all the elements of such sets –Use “…” to mean “continue sequence forever” –Set of Natural Numbers: {1,2,3,…}

16 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets Two infinite sets, A and B are equinumerous/equivalent (A≡B) if a bijection exists between them. –Note, we don’t have to be able to compute it in every instance, just be certain one exists. Therefore |A| = |B| A≡B Putting two infinite sets into one-to-one correspondence is an infinite task, and we don't pretend that we can do it (that is, finish it) in finite time.

17 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets To show that an infinite set, like the even numbers, can be put into one-to-one correspondence with another, like the odd numbers, we need only produce a rule-governed sequence for each set which runs through the members without omission or repetition: –for example, 2, 4, 6... and 1, 3, 5.... If we can do so, then we know that the nth term of one sequence will have a counterpart in the nth term of the other, and vice versa, guaranteeing one-to-one correspondence for each element.

18 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets However there are some infinite sets which are not equinumerous. We use this to prove that uncomputable numbers exist. A set is countable iff (if and only if) its cardinality is either finite or equal to N (the Natural numbers) – i.e. if a bijection exists with a subset of the natural numbers - A≡N.

19 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets Other ways to identify a countable set: –May one order the set such that between any two elements a, b there is a finite number of elements?, or –Could one write out the first two elements of the set? This is possible with N and Z, but not with R.

20 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Cardinality and Infinite Sets Finite sets are countable: –Example: Real numbers with two decimal places of accuracy between 0 and 1 is a countable set. If a set is not countable it is uncountable.

21 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Graphs A graph is a set of points with lines connecting some of the points. The points are known as nodes or vertices. The connecting lines are known as edges – the number of edges = degree (each node has degree 2 and degree 3, respectively below) 1 4 2 5 3

22 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Graphs A path in a graph is a sequence of nodes connected by edges. A graph is connected if, for every two distinct nodes a and b, there is a path from a to b. A cycle is a path within a graph that starts and ends at the same node. A graph is a tree if it is connected and has no simple cycles – may contain a specially designated node called the root. Nodes of degree 1 in a tree, apart from the root, are called the leaves of the tree.

23 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Graphs Leaves of tree pathcycle

24 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Directed Graph If a graph has arrows instead of lines it is a directed graph. The number of arrows leaving a node is the outdegree of that node and the number of arrows entering a node is its indegree. 12 54 6 3

25 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Directed Graph In a directed graph an edge from node i to node j is represented as a pair (i, j) The formal description of a directed graph G is (V, E) where V is the set of nodes and E the set of edges. ({1,2,3,4,5,6}, {(1,2), (1,5), (2,1), (2,4), (5,4), (5,6), (6,1), (6,3)}) 12 54 6 3

26 Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Graphs In a binary tree each node which is not a leaf has at most two children. If we distinguish between left and right children then the tree is ordered. In a complete tree each node which is not a leaf has exactly two children. A complete tree is perfect if all leaves have the same height.


Download ppt "CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries."

Similar presentations


Ads by Google