Notions & Notations (3) - 1ICOM 4075 (Spring, 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Summer.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
YES-NO machines Finite State Automata as language recognizers.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Section 1.6: Sets Sets are the most basic of discrete structures and also the most general. Several of the discrete structures we will study are built.
2.1 Sets. DEFINITION 1 A set is an unordered collection of objects. DEFINITION 2 The objects in a set are called the elements, or members, of the set.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
EE1J2 – Discrete Maths Lecture 7
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CSE115/ENGR160 Discrete Mathematics 02/10/11 Ming-Hsuan Yang UC Merced 1.
Sets.
Basic Concepts of Algebra
Theory of computing, part 1. Von Neumann Turing machine Finite state machines NP complete problems -maximum clique -travelling salesman problem -colour.
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
1 Chapter Elementary Notions and Notations.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
1 Chapter 1 Introduction to the Theory of Computation.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Construction Techniques (1) - 1ICOM 4075 (Fall, 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez 2005.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 2 The Language of Mathematics.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Discrete Structures Li Tak Sing( 李德成 ) Lecture note 2 1.
Introduction to Theory of Automata By: Wasim Ahmad Khan.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
Mathematical Proofs. Chapter 1 Sets 1.1 Describing a Set 1.2 Subsets 1.3 Set Operations 1.4 Indexed Collections of Sets 1.5 Partitions of Sets.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
1 Section 1.6 Sets. 2 Set Fundamental discrete structure on which all other discrete structures are built Can be loosely defined as a collection of elements.
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
Chapter 2 With Question/Answer Animations. Section 2.1.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Module #10: Proof Strategies Rosen 5 th ed., §3.1 (already covered)
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
Discrete Structures Li Tak Sing( 李德成 ) mt263f ppt 1.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Notions & Notations (2) - 1ICOM 4075 (Spring 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Spring.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 1 The Foundations: Logic, Sets,
Functions (2) - 1ICOM 4075 (Spring, 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez ICOM 4075: Foundations.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of Automata.
Notions & Notations - 1ICOM 4075 (Fall 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Fall 2010 ICOM.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Lecture 1 Theory of Automata
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
COMPS263F Unit 1 Discrete Structures Li Tak Sing( 李德成 ) Room A
ICOM 5016 – Introduction to Database Systems
Chapter 1 Introduction to the Theory of Computation
Lecture Sets 2.2 Set Operations.
ICOM 5016 – Introduction to Database Systems
Introduction and Chapter One: Fundamentals
Presentation transcript:

Notions & Notations (3) - 1ICOM 4075 (Spring, 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Summer 2005 ICOM 4075: Foundations of Computing Lecture 3: Elementary Notions and Notations (3) Lecture Notes Originally Written By Prof. Yi Qian

Notions & Notations (3) - 2ICOM 4075 (Spring, 2010) UPRM Homework 2 (due Tuesday, Feb 16, 2010 ) Section 1.2: (pp.31-35) b., d b., d., f., h. 11. b., d b., c b., d. 23. b. d b. d. 29. b. d. f.

Notions & Notations (3) - 3ICOM 4075 (Spring, 2010) UPRM Reading Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 2 nd edition, Chapter 1. Section 1.3

Notions & Notations (3) - 4ICOM 4075 (Spring, 2010) UPRM Ordered Structures Sets and bags are used to represent un-ordered information. Notions and notations for structures that have some kind of ordering: –Tuples –Lists –Strings and Languages –Relations –Counting Tuples

Notions & Notations (3) - 5ICOM 4075 (Spring, 2010) UPRM Tuples A tuple is a collection of things, called its elements, where there is a first element, a second element, and so on. The elements of a tuple are also called members, objects, or components. Denote a tuple by writing down its elements, separated by commas, and surrounding everything with the two symbols “(“ and “)”. –e.g., the tuple (2, ka, 6) has three elements, the first element is 2, the second element is ka, and the third element is 6. –e.g. (I, am, a, student) is also a tuple with 4 elements.

Notions & Notations (3) - 6ICOM 4075 (Spring, 2010) UPRM Tuples If a tuple has n elements, we say that its length is n, and we call it n-tuple. The 0-tuple is denoted by ( ), and we call it the empty tuple. A 2-tuple is often called an ordered pair, and a 3-tuple might be called an ordered triple. Other words used in place of the word tuple are vector and sequence, possibly modified by the word ordered. Two n-tuples (x 1, …, x n ) and (y 1, …, y n ) are said to be equal if x i = y i for 1 ≤ i ≤ n, and we denote this by (x 1, …, x n ) = (y 1, …, y n ). –e.g., (1, 3) = (1, 3), but (1, 3) ≠ (3, 1)

Notions & Notations (3) - 7ICOM 4075 (Spring, 2010) UPRM Tuples Differences between sets, bags, and tuples: –Sets: {b, a, t} = {t, a, b} –Bags: [t, o, o, t] = [o, t, t, o] –Tuples: (t, o, o, t) ≠ (o, t, t, o) and (b, a, t) ≠ (t, a, b) Two characteristics of Tuples 1.There may be repeated occurrences of elements 2.There is an order or arrangement of the elements

Notions & Notations (3) - 8ICOM 4075 (Spring, 2010) UPRM Cartesian Products of Sets Definition of Cartesian Product If A and B are sets, then the Cartesian product of A and B, which is denoted by AxB, is the set of all ordered pairs (a, b) such that a A and b B. In other words, we have AxB = {(a, b) | a A and b B}. –e.g., if A = {u, v} and B = {x, y}, then AxB = {(u, x), (u, y), (v, x), (v, y)} –e.g., if A = Φ and B = {1, 3}, what is AxB?

Notions & Notations (3) - 9ICOM 4075 (Spring, 2010) UPRM Cartesian Products of Sets Cartesian product of n sets A 1, …, A n A 1 x … xA n = {(x 1, …, x n ) | x i A i } If all the sets A i in a Cartesian product are the same set A, then we use the abbreviated notation A n = Ax … xA. With this notation we have the following definitions for the set A 1 and A 0 : A 1 = {(a) | a A} and A 0 = {( )}. so we know that A 1 ≠ A and A 0 ≠ Φ Example: Let A = {x, y, z}. Then we have the following Cartesian products: A 0 = ? A 1 = ? A 2 = ?

Notions & Notations (3) - 10ICOM 4075 (Spring, 2010) UPRM Arrays, Metrics, and Records A 1-dimensional array of size n with elements in the set A is an n-tuple in the Cartesian product A n. So we can think of the Cartesian products A n as the set of all 1-dimensional arrays of size n over A. If x = (x 1, …, x n ), then the component x i is usually denoted – in computer programming languages – by x[i]. A 2-dimensional array – also called a matrix – can be thought of as a table of objects that are indexed by rows and columns. If x is a matrix with m rows and n columns, we say that x is an m by n matrix. –e.g., if x is a 3 by 5 matrix, then x can be represented by the following diagram: x 11 x 12 x 13 x 14 x 15 x = x 21 x 22 x 23 x 24 x 25 x 31 x 32 x 33 x 34 x 35 We can also represent x as a 3-tuple whose components are 5-tuples as: x = ((x 11, x 12, x 13, x 14, x 15 ), (x 21, x 22, x 23, x 24, x 25 ), (x 31, x 32, x 33, x 34, x 35 )) –In programming, the component x ij is usually denoted by x[i, j]. We can think of AxB as the set of all records, or structures, with two fields A and B. For a record r = (a, b) AxB the components a and b are normally denoted by r.A and r.B.

Notions & Notations (3) - 11ICOM 4075 (Spring, 2010) UPRM Lists A list is a finite ordered sequence of zero or more elements that can be repeated. What is the differences between a tuple and a list? –Tuples: we can randomly access any component in a constant amount of time –Lists: we can randomly access only two things in a constant amount of time: head – the first component of a list tail – and the list made up of everything except the first component, which is called its tail. We denote a list by writing down its elements, separated by commas, and surrounding everything with the two symbols “ ”. The empty list is denoted by. The number of elements is a list is called its length. –e.g., the list has length 3, its head is a, and its tail is the list. If L is a list, we use the notation head(L) and tail(L) to denote the head of L and the tail of L. –e.g., head( ) = a, tail( ) =. –The empty list does not have a head or tail.

Notions & Notations (3) - 12ICOM 4075 (Spring, 2010) UPRM List Construct a new list by adding a new element at the head of an existing list The name cons will be used to denote this construction operation. –If h is an element of some kind and L is a list, then cons(h, L) is the new list whose head is h and whose tail is L. e.g., con(w, ) = cons(a, ) = cons(this, ) = If all the elements of a list L are from a particular set A, then L is said to be a list over A. –e.g., each of the following lists is a list over {a, b, c},,,, Denote the collection of all lists over A by lists(A).

Notions & Notations (3) - 13ICOM 4075 (Spring, 2010) UPRM Computer Representation of Lists A simple way to represent a list in a computer: –to allocate a block of memory for each element of the list –the block of memory contains the element together with an address (called a pointer or link) to the next block of memory for the next element of the list e.g., for the list L =, the memory representation of the list is: bcde a L cons(a, L) head(L) = b tail(L)

Notions & Notations (3) - 14ICOM 4075 (Spring, 2010) UPRM Strings A string is a finite ordered sequence of zero or more elements that are placed next to each other in juxtaposition. The individual elements that make up a string are taken from a finite set called an alphabet. If A is an alphabet, then a string of elements from A is said to be a string over A. –e.g., a few strings over {a, b, c}: a, bb, ca, ababcca The string with no elements is called the empty string, and we denote it by the Greek capital letter lambda: Λ. – The number of elements that occur in a string s is called the length of s, which we sometimes denote by |s|. –e.g., | Λ | = 0, |ababcca| = 7

Notions & Notations (3) - 15ICOM 4075 (Spring, 2010) UPRM Concatenation of Strings The operation of placing two strings s and t next to each other to form a new string st is called concatenation. –e.g., if abbc and ca are two strings over the alphabet {a, b, c}, then the concatenation of abbc and ca is the string abbcca. –e.g., sΛ = Λs = s

Notions & Notations (3) - 16ICOM 4075 (Spring, 2010) UPRM Languages (Sets of Strings) A language is a set of strings. If A is an alphabet, then a language over A is a set of strings over A. The set of all strings over A is denoted by A*. So any language over A is a subset of A*. –Four simple examples of languages over an alphabet A are the sets Φ, {Λ}, A, and A*. –e.g., if A = {a}, then these four simple languages over A become Φ, {Λ}, {a}, and {Λ, a, aa, aaa, …}. Language Representations –{a n | n N} = {Λ, a, aa, aaa, …} –{ab n | n N} = {a, ab, abb, abbb, …} –{a n b n | n N} = {Λ, ab aabb, aaabbb, …} –{(ab) n | n N} = {Λ, ab, abab, ababab, …}

Notions & Notations (3) - 17ICOM 4075 (Spring, 2010) UPRM Numerals A numeral is a written number. In terms of strings, we can say that a numeral is a nonempty string of symbols that represents a number. –The Roman numerals represents the set of nonnegative integers by using the alphabet {I, V, X, L, C, D, M} –The decimal numerals represent the set of natural numbers by using the alphabet {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} –The binary numeral represent the natural numbers by using the alphabet {0, 1} –Example: the Roman numeral XV, the decimal numeral 15, and the binary numeral 1111 all represent the same number.

Notions & Notations (3) - 18ICOM 4075 (Spring, 2010) UPRM Products of Languages The product of languages L and M is the language LM = {st | s L and t M} –e.g., if L = {ab, ac} and M = {a, bc, abc}, then the product LM is the language LM = {aba, abbc, ababc, aca, acbc, acabc} –L{Λ} = {Λ}L = L –LΦ = ΦL = Φ –The product is associative: L(MN) = (LM)N –The product is not commutative LM ≠ ML –L n = {s 1 s 2 …s n | s k L for each k}, L 0 = {Λ} e.g., L = {a, bb}, then L 0 = {Λ}, L 1 = L = {a, bb} L 2 = LL = {aa, abb, bba, bbbb} L 3 = LL 2 = aaa, aabb, abba, abbbb, bbaa, bbabb, bbbba, bbbbbb}

Notions & Notations (3) - 19ICOM 4075 (Spring, 2010) UPRM Closure of a Language If L is a language, then the closure of L, denoted by L*, is the set of all possible concatenations of strings from L. In other words, we have L* = L 0 L 1 L 2 … L n …. So x L* if and only if x L n for some n. Therefore, we have x L* if and only if either x = Λ or x = l 1 l 2 …l n for some n >= 1, where l k L for 1 ≤ k ≤ n. If L is a language, then the positive closure of L, which is denoted by L +, is defined by L + = L 1 L 2 L 3 … It follows from the definition that L* = L + {Λ}

Notions & Notations (3) - 20ICOM 4075 (Spring, 2010) UPRM Properties of Closure a.{Λ} * = Φ * = {Λ} b.Λ L if and only if L + = L * c.L* = L*L* = (L*)* d.(L * M * ) * = (L * M * ) * = (L M) * e.L(ML) * = (LM) * L Proof: (p45)

Notions & Notations (3) - 21ICOM 4075 (Spring, 2010) UPRM Relations A relation is a set of n-tuples, where the elements in each tuple are related in some way. –e.g., the parent-child relation can be described as the following set of ordered pairs: isParentOf = {(x, y) | x is a parent of y} –e.g., PT = {(x, y, z) | x 2 + y 2 = z 2 } is the relation for the sides of a right triangle x, y, z. Definition of Relation If R is a subset of A 1 x…xA n, then R is said to be an n-ary relation on (or over) A 1 x…xA n. If R is a subset of A n, then we say R is an n-ary relation on A. Instead of 1-ary, 2-ary, and 3-ary, we say unary, binary, and ternary. –e.g. isParentOf is a binary relation on the set of people; PT is a ternary operation on the set of positive real numbers. In formal terms, if P is the set of all people, then isParentOf PxP. If R + is the set of positive real numbers, then PT R + xR + xR +

Notions & Notations (3) - 22ICOM 4075 (Spring, 2010) UPRM Relations The smallest relation is the empty set Φ, which is called the empty relation. The largest relation is A 1 x…xA n itself, which is called universal relation. If R is a relation and (x 1, …, x n ) R, this fact is often denoted by the prefix expression R(x 1,…,x n ). –e.g., PT(1,, 2) means (1,, 2) PT –If R is a binary relation, then the statement (x, y) R can be denoted by R(x, y), but it is often denoted by the infix expression xRy –e.g., “John isParentOf Mary” means (John, Mary) isParentOf

Notions & Notations (3) - 23ICOM 4075 (Spring, 2010) UPRM Relational Databases A relational database is a collection of facts that are represented by tuples in such a way that the tuple can be accessed in various ways to answer queries about the facts. To accomplish these tasks each component of a tuple must have an associated name, called an attribute. Example: If we have a database called Borders that describes the foreign countries and large bodies of water that border each state of the United States. The following table represents a sample of the information in the database with attribute names State, Foreign, and Water. There is no special order to the rows of a relational database. So the table can be represented as a set of tuples. Borders = {(Washington, Canada, Pacific Ocean), (Minnesota, Canada, Lake Superior), (Wisconsin, None, Lake Michigan),…} Question: What states border Mexico? Answer: the set {x | (x, Mexico, z) Borders, for some z} Borders StateForeignWater WashingtonCanadaPacific Ocean MinnesotaCanadaLake Superior WisconsinNoneLake Michigan OregonNonePacific Ocean MaineCanadaAtlantic Ocean MichiganCanadaLake Superior MichiganCanadaLake Huron MichiganCanadaLake Michigan CaliforniaMexicoPacific Ocean ArizonaMexicoNone

Notions & Notations (3) - 24ICOM 4075 (Spring, 2010) UPRM Counting Tuples The cardinality of a set tuples, lists, or strings (S) is the number of elements in the set, denote it as |S| Product Rule |A x B| = |A| |B| |A x B x C| = |A| |B| |C| |A n | = |A| n

Notions & Notations (3) - 25ICOM 4075 (Spring, 2010) UPRM Counting Strings as Tuples Since a string can be represented as a tuple, we can use product rules to count strings as well as tuples E.g., Suppose we need to count the number of strings of length 5 over the alphabet A = {a, b, c}. Any string of length 5 can be considered as a 5-tuple. For example, the string ababc can be represented by the tuple (a, b, a, b, c). So the number of strings of length 5 over A equals the number of 5-tuples over A, which by product rule is |A 5 | = |A| 5 = 3 5 = 243

Notions & Notations (3) - 26ICOM 4075 (Spring, 2010) UPRM Strings with Restrictions Suppose we need to count the number of strings of length 6 over the alphabet A = {a, b, c, d} that begin with either a or c and contain at least one occurrence of b. Since strings can be represented by tuples, we’ll count the number of 6- tuples over A that begin with either a or c and contain at least one occurrence of b. We can break up the problem into two simpler problems. First, let U be the set of 6-tuples over A that begin with a or c. In other words, U = {a, c}xA 5. Next, let S be the subset of U consisting of those 6-tuples that do not contain any occurrences of b. In other words, S = {a, c}x{a, c, d} 5. Then the set U – S is the desired set of 6-tuples over A that begin with either a or c and contain at least one occurrence of b. so we have |U – S| = |U| - |S| = |{a, c}xA 5 | - |{a, c}x{a, c, d} 5 | = |{a, c}| |A 5 | - |{a, c}| |{a, c, d} 5 | = 2 (4 5 ) – 2 (3 5 ) = 1562

Notions & Notations (3) - 27ICOM 4075 (Spring, 2010) UPRM String with More Restrictions We’ll count the number of strings of length 6 over A = {a, b, c, d} that start with a or c and contain at least one occurrence of either b or d. As in the previous example, let U be the set of 6-tuples over A that start with a or c. Then U = {a, c}xA 5 and |U| = 2(4 5 ). Now let S be the subset of U whose 6-tuples do not contain any occurrences of b and do not contain any occurrences of d. So S = {a, c} 6 and |S| = 2 6. Then the set U – S is the desired set of 6-tuples over A that begin with either a or c and contain at least one occurrence of either b or d. So we have |U – S| = |U| - |S| = 2(4 5 ) – 2 6 = 1984

Notions & Notations (3) - 28ICOM 4075 (Spring, 2010) UPRM Strings with More Restrictions Suppose we need to count the number of strings of length 6 over A = {a, b, c, d} that start with a or c and contain at least one occurrence of b and at least one occurrence of d. In this case we break up the problem into three simpler problems. First, let U be the set of 6-tuples that start with a or c. So U = {a, c}xA 5 and |U| = 2(4 5 ). Next, let S be the subset of U whose 6-tuples don’t contain b. So S = {a, c}x{a, c, d} 5 and |S| = 2(3 5 ). Similarly, let T be the subset of U whose 6-tuples don’t contain d. So T = {a, c}x{a, b, c} 5 and |T| = 2(3 5 ). Then the set U – (S T) is the desired set of 6- tuples that start with a or c and contain at least one occurrence of b and at least one occurrence of d. The cardinality of this set has the form |U – (S T)| = |U| - |S T| = |U| - (|S| + |T| - |S T|) We’ll be done if we can calculate the cardinality of S T. Notice that S T = {a, c}x{a, c, d} 5 {a, c}x{a, b, c} 5 = {a, c}x{a, c} 5 = {a, c} 6 So |S T| = 2 6. Now we can complete the calculation of |U – (S T)|. |U – (S T)| = |U| - (|S| + |T| - |S T|) = 2(4 5 ) – [2(3 5 ) + 2(3 5 ) – 2 6 ] = 1140