sets, sequences, matrix

54
Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures Discrete Structures Part 1: Sets, Sequences, Matrices. Dr. Jorge A. Pérez j.a.perez[at]rug.nl University of Groningen November 12, 2014 Jorge A. Pérez Discrete Structures (2014-2015) – Part 1 1/61

Upload: ana-roman

Post on 18-Jul-2016

13 views

Category:

Documents


0 download

DESCRIPTION

asd

TRANSCRIPT

Page 1: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Discrete StructuresPart 1 Sets Sequences Matrices

Dr Jorge A Peacuterezjaperez[at]rugnl

University of Groningen

November 12 2014

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Overview of Part 1

1 Sets and Subsets

2 Operations on Sets

3 Sequences

4 Strings

5 Integers

6 Matrices

7 Mathematical Structures

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (1)

bull V = horse cylinder teapot mars formulabull p isin V p is an element of the set Vbull p q isin V is shorthand notation for p isin V q isin Vbull p 6isin V p is not an element of the set V so p 6isin V lArrrArr not(p isin V )1

bull Example horse isin V but rabbit 6isin V

1 lArrrArr if and only ifJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (2)

bull A set has no ordering1 2 3 is the same set as 3 1 2bull Each member of a set occurs only oncea a b is the same set as a bbull A structure in which elements may occur more than once is called a bag

or multisetbull Two sets A and B are equal if they contain the same elements

Formally A = B holds whenever x isin A lArrrArr x isin Bbull The empty set contains no members by definition Notation

or empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Defining Sets Using Predicates

bull Let P (x) be a predicate about the object xFor instance ldquox is an integer between 10 and 20 rdquobull The set of all x that satisfy the predicate P (x) is written as

x | P (x) or x P (x)

bull We may explicitly specify the domain from which x is takenFor instance given the integers Z we could have

x isin Z | P (x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 2: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Overview of Part 1

1 Sets and Subsets

2 Operations on Sets

3 Sequences

4 Strings

5 Integers

6 Matrices

7 Mathematical Structures

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (1)

bull V = horse cylinder teapot mars formulabull p isin V p is an element of the set Vbull p q isin V is shorthand notation for p isin V q isin Vbull p 6isin V p is not an element of the set V so p 6isin V lArrrArr not(p isin V )1

bull Example horse isin V but rabbit 6isin V

1 lArrrArr if and only ifJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (2)

bull A set has no ordering1 2 3 is the same set as 3 1 2bull Each member of a set occurs only oncea a b is the same set as a bbull A structure in which elements may occur more than once is called a bag

or multisetbull Two sets A and B are equal if they contain the same elements

Formally A = B holds whenever x isin A lArrrArr x isin Bbull The empty set contains no members by definition Notation

or empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Defining Sets Using Predicates

bull Let P (x) be a predicate about the object xFor instance ldquox is an integer between 10 and 20 rdquobull The set of all x that satisfy the predicate P (x) is written as

x | P (x) or x P (x)

bull We may explicitly specify the domain from which x is takenFor instance given the integers Z we could have

x isin Z | P (x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 3: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (1)

bull V = horse cylinder teapot mars formulabull p isin V p is an element of the set Vbull p q isin V is shorthand notation for p isin V q isin Vbull p 6isin V p is not an element of the set V so p 6isin V lArrrArr not(p isin V )1

bull Example horse isin V but rabbit 6isin V

1 lArrrArr if and only ifJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (2)

bull A set has no ordering1 2 3 is the same set as 3 1 2bull Each member of a set occurs only oncea a b is the same set as a bbull A structure in which elements may occur more than once is called a bag

or multisetbull Two sets A and B are equal if they contain the same elements

Formally A = B holds whenever x isin A lArrrArr x isin Bbull The empty set contains no members by definition Notation

or empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Defining Sets Using Predicates

bull Let P (x) be a predicate about the object xFor instance ldquox is an integer between 10 and 20 rdquobull The set of all x that satisfy the predicate P (x) is written as

x | P (x) or x P (x)

bull We may explicitly specify the domain from which x is takenFor instance given the integers Z we could have

x isin Z | P (x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 4: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets Collections of Distinct Objects (2)

bull A set has no ordering1 2 3 is the same set as 3 1 2bull Each member of a set occurs only oncea a b is the same set as a bbull A structure in which elements may occur more than once is called a bag

or multisetbull Two sets A and B are equal if they contain the same elements

Formally A = B holds whenever x isin A lArrrArr x isin Bbull The empty set contains no members by definition Notation

or empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Defining Sets Using Predicates

bull Let P (x) be a predicate about the object xFor instance ldquox is an integer between 10 and 20 rdquobull The set of all x that satisfy the predicate P (x) is written as

x | P (x) or x P (x)

bull We may explicitly specify the domain from which x is takenFor instance given the integers Z we could have

x isin Z | P (x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 5: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Defining Sets Using Predicates

bull Let P (x) be a predicate about the object xFor instance ldquox is an integer between 10 and 20 rdquobull The set of all x that satisfy the predicate P (x) is written as

x | P (x) or x P (x)

bull We may explicitly specify the domain from which x is takenFor instance given the integers Z we could have

x isin Z | P (x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 6: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Numbers

Z = x | x is an integer= minus3minus2minus1 0 1 2 3

N = x | x is a positive integer or zero= 0 1 2 3

Z+ = N+ = x | x is a positive integer= 1 2 3

Q = x | x is a rational number

=pq| p q isin Z q 6= 0

=pq| p isin Z q isin N+

R = x | x is a real numberC = x | x is a complex number

= x+ iy | x y isin RJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 7: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Subsets

bull Given two sets S and T we say that S is a subset of T (notationS sube T ) iff each element of S is also an element of T bull More precisely

S sube T lArrrArr forallx (x isin S =rArr x isin T )

Above forall denotes the universal quantifier read ldquofor allrdquobull For every set S we have S sube S and empty sube Sbull We say that S is a proper subset of T (notation S sub T ) if bothS sube T and S 6= T bull Example Z+ sub N sub Z sub Q sub R sub C

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 8: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Equality of Sets

bull A = B holds whenever x isin A lArrrArr x isin B

bull In other words

A = B lArrrArr A sube B and B sube A

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 9: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sets of Sets

bull Elements of a set may be sets themselves For instance

a b a a b

bull Therefore the set a is not the same as abull Important Set membership (isin) concerns an element and a set subset

inclusion (sube) concerns two setsFor instance if S = a b c then a isin S and a sube Sbull Question Is the set empty

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 10: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Russellrsquos paradox2

bull Consider the set R of all sets that are not members of themselves

R = V | V isin V

bull Question R isin R Answer yes and nobull To avoid this type of problems we consider a context which is given by a

well-defined universal set U of objectsAny set within this context is a subset of U

2Discovered by Bertrand Russell in 1901Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 11: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Intervals of R

50 3minus4 minus3 minus2 minus1 1 2 4

A subset of R defined by two real numbers a and b with the property thatany real between a and b is included in the setbull [a b] = x isin R | a 6 x 6 bbull (a b) = x isin R | a lt x lt bbull [a b) = x isin R | a 6 x lt bbull (a b] = x isin R | a lt x 6 bbull (minusinfin a] = x isin R | x 6 abull (a a] = [a a) = (a a) = emptybull a le b rArr [a b) = (a b] = (a b) = emptybull Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 12: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power Set

bull The power set P(S) of S is

P(S) = T | T sube S

bull Example If S = a b c then

P(S) =empty a b c a b b c a c a b c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 13: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Size Cardinality

bull A finite set is a set that has a finite number of elementsbull A set that is not finite is called infinitebull Example the set 123 is finite the interval [1 3] is infinitebull The cardinality (or size) of a finite set S is denoted as |S|bull Let S be a finite set The cardinality of P(S) is 2|S|

For instance if |S| = 3 then |P(S)| = 23 = 8

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 14: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Power set Binary images

All possible 2times 2 arrangements with 0123 or 4 foreground pixels|P(S)| = 2|S| = 24 = 16

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 15: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (1)

Let us write U to denote the universebull Union A cupB = x | x isin A or x isin B (or ldquoorrdquo)3

bull Intersection A capB = x | x isin A and x isin B (and ldquoandrdquo)bull Difference AminusB = x | x isin A and x isin B

Alternative notation A B

3Inclusive or x isin A or x isin B or bothJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 16: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Set Operations (2)

bull Symmetric difference

AB =x | (x isin A and x isin B) or (x isin B and x isin A)

= (A B) cup (B A)

Alternative notation A∆Bbull Complement A = U A Alternative notation Ac

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 17: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (1)

Commutativity A cupB = B cupAA capB = B capA

Associativity (A cupB) cup C = A cup (B cup C)(A capB) cap C = A cap (B cap C)

Distributivity (cup over cap) A cup (B cap C) = (A cupB) cap (A cup C)(cap over cup) A cap (B cup C) = (A capB) cup (A cap C)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 1961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 18: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Algebraic Laws of Set Operations (2)

Idempotence A cupA = AA capA = A

Identity A cup empty = AA cap U = A

Complement A cupA = U

A capA = empty

Double Complement (A) = A

Relation universe - Empty set U = emptyempty = U

De Morgan Laws (A cupB) = A capB(A capB) = A cupB

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 19: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Annotated Linear Proof (ALP)

Proposition A cup (B cup C) = (A cupB) cup CProof 4

x isin A cup (B cup C)

equiv definition cup (x isin A) or (x isin B cup C)

equiv definition cup x isin A or (x isin B or x isin C)

equiv logic (x isin A or x isin B) or x isin C

equiv definition cupx isin A cupB or x isin C

equiv definition cupx isin (A cupB) cup C4Kolman et al write equiv instead of lArrrArr

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 20: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Sequences

bull A sequence is a list (or array) of objectsbull Unlike sets elements of a list are ordered there is a first element the

second element etcbull More formally a sequence is an indexed array sn n = 1 2 3

We call n the indexbull Example s = a b c d e is a sequence with s1 = a s2 = b etcbull Example an infinite sequence defined by sn = 2 middot snminus1 + 7 with s0=3

and n isin NWe have that s1 = 13 s2 = 33 s3 = 73

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 21: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Strings

bull A string is a sequence of letters (or symbols)bull Example William (finite sequence)bull Example b l a b l a b l a b l a (infinite sequence)bull We also write blablablabla bull The alphabet of a string is the set of all letters of the string

For example the alphabet of the above string is b l a

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 22: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Characteristic Function

bull Let A be a subset of the universe U We say that fA U rarr 0 1 is the characteristic function (orindicator function) of A It is defined (for all x isin U) as

fA(x) =

1 if x isin A0 if x isin A

bull Alternative notation χA(x)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2561

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 23: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Computer Representation of Sets

bull Each finite universe U can be represented by a finite sequencebull For example the set U = a c s q t corresponds to the sequenceα = a c s q tbull Every subset A sube U can be represented by its characteristic function fAbull We can make an array A of length n = |U | where A[k] = 1 iffA(α(k)) = 1 and A[k] = 0 if fA(α(k)) = 0

Representation of U 1 1 1 1 1

Representation of A = c q 0 1 0 1 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 24: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Countable and Uncountable Sets

bull A set V is called countable (or denumerable) if V can be represented bya sequencebull Each finite set is countablebull Infinite sets that are not countable are called uncountablebull Examples sets N Z an Q are countable

The set R is not countable - the proof uses Cantorrsquos diagonal-argument5

5A proof method devised in 1891 by Georg CantorJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 25: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Languages

bull Alphabet non-empty finite set of letters (symbols) Σbull WordString a finite string of letters from alphabet Σ

Example a1 a2 a3 an where ak isin Σ is a word of length nWe usually write it as a1a2a3 anbull Σlowast denotes the set of all words that can be produced with Σ

bull Every subset of Σlowast is a languagebull The empty string written Λ isin Σlowast has length 06

Examples

bull Let Σ = abull Some words in Σlowast a aa aaabull The set of all possible words is Σlowast = Λ a aa aaa aaaa

6In most books the empty string is denoted by the symbol εJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 2961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 26: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

String Concatenation

bull Consider the two strings

w1 = itisrainingcatsw2 = anddogs

bull We can append w2 to w1 so as to obtain

w1 middot w2 = itisrainingcatsanddogs

bull This operation is called the concatenation of w1 and w2We may sometimes write w1w2 instead of w1 middot w2

bull Note wΛ = Λw = w

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 27: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

The DNA Alphabet

Σ = A TCG

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 28: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Words in the DNA alphabet

Let Σ = A TCG Let us have a look at some words from Σlowastbull Λ AAAAAAAAAA We denote this set as Alowast

Similarly for T lowast Clowast and Glowastbull ATAG This set is denoted by A(T orG)

Alternative notation A(T |G)bull ATATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)lowastbull ATCGATCGCGATCGCGCGATCGCGCGCG

This set is denoted by AT (CG)+7

bull ATCTATGCTGATGGCTGGATGGGCTGGG This set is denoted by (A or C)TGlowast

7For completeness sake This notation is not used in Kolman et alJorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 29: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Expressions

Let Σ be an alphabet A regular expression (regexp) over Σ is definedrecursively in terms of members of the alphabet and the symbols

( ) or lowast Λ

according to the following definitionRE1 The symbol Λ is a regular expressionRE2 Each x isin Σ is a regular expressionRE3 If α and β are regular expressions then the expression α middot β is also

regularRE4 If α and β are regular expressions then the expression α or β is also

regularRE5 If α is a regular expression then (α)lowast is also a regular expression

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 30: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Regular Sets

Associated to each regexp over A there is a subset of Alowastbull Λ corresponds to the set Λbull x isin Σ corresponds to the set xbull If α and β are regexps that correspond to sets MN sube Σlowast thenbull α middot β corresponds to the set M middotN = s middot t | s isinM and t isin Nbull (α or β) corresponds to the set M cupN

bull If α is a regexp that corresponds to set M sube Σlowastthen (α)lowast corresponds to set Mlowast

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 31: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

DivisionRemainder Property of Natural Numbers

TheoremLet mn be integers with n gt 0There are unique integers q and r such that

n = m middot q + r and 0 6 r lt m

While q is called quotient is r called remainderWe can find them using the operators div and modbull q = n div qbull r = n mod q

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 32: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (1)

We consider the set of integers Zbull We write a | b if b = k middot a for some integer k

We say that a is a divisor of b or that b is a multiple of abull Example 7|98 for 98 = 7 middot 14bull ldquo|rdquo is transitive (a | b) and (b | c) =rArr a | c

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 33: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (2)

DefinitionA positive natural number n is a prime number if it has exactly twounique divisors 1 and n

Thus by definition 1 is not a prime Still 2 3 5 and 7 are prime

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 34: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Factors and Products (3)

Theorem (prime factorization)

Any positive integer n gt 1 can be uniquely written as a product of primenumbers

Consider the Hasse diagram of 60

60 = 2 middot 2 middot 3 middot 5 = 22 middot 3 middot 5168 = 2 middot 2 middot 2 middot 3 middot 7 = 23 middot 3 middot 7192 = 2 middot 2 middot 2 middot 2 middot 2 middot 2 middot 3 = 26 middot 3

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 3961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 35: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

There are infinitely many prime numbers

A Proof by Contradiction1 Suppose there are only finitely many primes say p1 p2 pk in

increasing order2 Let n be defined as (p1 times p2 times times pk) + 13 By assumption n not a prime n is greater than the greatest prime pk

So n must be divisible by at least two primes4 The number nminus 1 is divisible by p1 p2 pk

Two numbers that differ by 1 can not have the same prime divisorSo n is not divisible by any of the primes p1 p2 pk

5 Therefore the prime factors of n are not in the list p1 p2 pkThis contradicts the assumption that p1 p2 pk is the completelist of prime numbers

6 We conclude that there are infinitely many primes

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 36: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD

bull If a b and k are positive integers and k | a and k | b then k is acommon divisor of a and b If d is the largest such k then d is thegreatest common divisor (or GCD) We write gcd(a b) = dbull Example 3 and 2 are common divisors of 18 and 24

But gcd(18 24) = 6bull m and n are called relatively prime (or coprime) if gcd(mn) = 1

Example 17 and 24 are coprimebull A procedure for computing the CGD of two integers is the Euclideanalgorithm Given a = k middot b+ r1 it exploits the property

gcd(a b) = gcd(b r1) = gcd(r1 r2) = middot middot middot = gcd(rnminus1 rn)

In the example above (a = 24 b = 18) gcd(24 18) = gcd(18 6) = 6

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 37: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

LCM

If a | k and b | k then k is a common multiple of a and bThe smallest such k is the least common multiple (or LCM)We write lcm(a b) = k Example lcm(18 24) = 72

For any two positive natural numbers m and n we havebull gcd(mn) middot lcm(mn) = m middot nbull any common divisor of m and n is a divisor of gcd(mn)

bull any common multiple of m and n is a multiple of lcm(mn)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 38: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

GCD and LCM

bull Greatest common divisor (GCD)

gcd(168 192) = gcd(23 middot 3 middot 7 26 middot 3)

= 2min(36) middot 3min(11) middot 7min(10) = 23 middot 31 middot 70 = 24

bull Least common multiple (LCM)

lcm(168 192) = lcm(23 middot 3 middot 7 26 middot 3)

= 2max(36) middot 3max(11) middot 7max(10) = 26 middot 31 middot 71 = 1344

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 39: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Representation of Integers

bull Let b gt 1 be some integer which we call the baseEvery positive integer n can be written in the unique form

n = dk bk + dkminus1 b

kminus1 + d1 b1 + d0

where 0 le di lt b i = 0 1 k and dk 6= 0bull The sequence dkdkminus1 d1d0 is called the base b expansion of nbull b = 10 decimal expansionbull b = 2 binary expansionbull b = 8 octal expansionbull b = 16 hexadecimal expansion

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 40: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Definition of a Matrix

bull A matrix is a rectangular array of numbers arranged in (horizontal) rowsand (vertical) columns For instance

A = [aij ] =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

bull M and N are called the dimensions of the matrix

We say that the matrix is M by N written as M timesN bull If M = N we say that the matrix is a square matrix of order N

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 41: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Transpose of a Matrix

bull The transpose of a matrix A is the matrix obtained by interchangingthe rows and columns of A Example Let

A =

a11 a12 middot middot middot a1Na21 a22 middot middot middot a2N

aM1 aM2 middot middot middot aMN

The transpose of A denoted AT is defined as

AT =

a11 a21 middot middot middot aM1

a12 a22 middot middot middot aM2

a1N a2N middot middot middot aMN

bull A matrix is called symmetric if A = AT Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 42: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Special Matrices

Square matrices (n rows n columns)

Diagonal matrix

Dn =

a11 0 middot middot middot 00 a22 middot middot middot 0

0 0 middot middot middot ann

Identity matrix

In =

1 0 middot middot middot 00 1 middot middot middot 0

0 0 middot middot middot 1

Zero matrix

Zn =

0 0 middot middot middot 00 0 middot middot middot 0

0 0 middot middot middot 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 43: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Addition of Matrices

bull Consider two matrices A and B with the same dimensionbull The sum of A and B is computed by adding the corresponding

elements For instance when A and B have dimensions 3times 2

A+B =

a11 a12a21 a22a31 a32

+

b11 b12b21 b22b31 b32

=

a11 + b11 a12 + b12a21 + b21 a22 + b22a31 + b31 a32 + b32

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 4961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 44: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (1)

bull The product of an M times P matrix A and a P timesN matrix B is theM timesN matrix C = [cij ] denoted ABbull To compute cij take row i of A and column j of B multiply the

corresponding elements and sum all these productsbull Example Consider M = 2 P = 3 and N = 2 We have

A =

(a11 a12 a13a21 a22 a23

)B =

b11 b12b21 b22b31 b32

The product AB is the 2times 2 matrix defined as follows(

c11 = a11b11 + a12b21 + a13b31 c12 = a11b12 + a12b22 + a13b32c21 = a21b11 + a22b21 + a23b31 c22 = a21b12 + a22b22 + a23b32

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 45: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Product of Matrices (2)

bull A concrete example

A =

(2 3 minus41 2 5

)B =

7 1minus6 69 0

AB = [cij ] =

(minus40 2040 13

)In fact it is easy to verify that

c11 = (2 middot 7) + (3 middot minus6) + (minus4 middot 9) = minus40

c12 = (2 middot 1) + (3 middot 6) + (minus4 middot 0) = 20

c21 = (1 middot 7) + (2 middot minus6) + (5 middot 9) = 40

c22 = (1 middot 1) + (2 middot 6) + (5 middot 0) = 13

bull The matrix product is associative ie A(BC) = (AB)C

bull In general the matrix product is not commutative ie AB 6= BA

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5161

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 46: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Matrices

Figure Mathematician George Boole (1815-1864)

bull In a Boolean matrix elements are either 1 (ldquotruerdquo) or 0 (ldquofalserdquo)bull Let A = [aij ] and B = [bij ] be Boolean matrices We define

bull Join A orB = C = [cij ] where cij =

1 if aij = 1 or bij = 1

0 if aij = bij = 0

bull Meet A andB = C = [cij ] where cij =

1 if aij = bij = 1

0 if aij = 0 or bij = 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5261

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 47: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (1)

bull The product of Boolean matrices is similar to that of ordinary matricesbull Given A and B we denote their product as AB = C = [cij ]bull To compute element cij we take row i of A and column j of B multiply

the corresponding elements and take the maximum of all these productsmdash which can be either zero or onebull A particular case

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(max(a11b11 a12b21 a13b31) max(a11b12 a12b22 a13b32)max(a21b11 a22b21 a23b31) max(a21b12 a22b22 a23b32)

)Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5361

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 48: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Boolean Product of Matrices (2)

bull Another view

AB =

(a11 a12 a13a21 a22 a23

)

b11 b12b21 b22b31 b32

=

(M(a11b11 a12b21 a13b31) M(a11b12 a12b22 a13b32)M(a21b11 a22b21 a23b31) M(a21b12 a22b22 a23b32)

)

where M(n) =

0 if n = 0

1 if n gt 0

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5461

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 49: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Mathematical Structures

Definition (Mathematical Structure (MS))

A mathematical structure is a collection of objects with operations definedon them (and their associated properties)

bull Notation(collection operation1 operation2 operationn)

bull Examples

(R+times) the real numbers with the operationsaddition and multiplication

(P (U)cupcap middot) the power set of U with the operationsunion intersection and complement

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5661

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 50: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Closures

bull A MS (VO1 On) is closed with respect to an operation Oi if theresult of applying Oi yields again an element of V bull Example Strings are closed with respect to concatenationbull Type of operations Obull Unary O has one argument

Example Complement of a set O(A) = Abull Binary O has two arguments

Example Sum of two integers O(x y) = x+ ybull Ternary O has 3 argumentsbull

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5761

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 51: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Prefix Infix Postfix Notation

bull The postfix notation is typical of unary operationsFor instance we write AT for matrix transposition mdashas opposed to theprefix notation T (A)bull The infix notation is commonly used to denote binary operations

For instance we A cupB for set union mdashas opposed to the prefixnotation cup(AB)

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5861

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 52: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (1)

bull A unary operation in a MS (V ) is called idempotent if

(x) = x forallx isin V

bull A binary operation in a MS (V ) is calledbull associative if for all x y z isin V

(x y) z = x (y z)

bull commutative if for all x y isin V

x y = yx

bull An element e is called an identity element of if for all x isin V

x e = ex = x

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 5961

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 53: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

Properties of Operations (2)

bull Let (V O ) be a MS with binary operations and OWe say that distributes over O if for all x y z isin V

x (yO z) = (x y)O (x z)

bull Let (V O ) be a MS with a unary operation and binary operations and O The operations satisfy De Morganrsquos laws if for x y isin V

(x y) = xO y

(xO y) = x y

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6061

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures
Page 54: Sets, Sequences, Matrix

Sets and Subsets Operations on Sets Sequences Strings Integers Matrices Mathematical Structures

End of Part 1

Jorge A Peacuterez Discrete Structures (2014-2015) ndash Part 1 6161

  • Sets and Subsets
  • Operations on Sets
  • Sequences
  • Strings
  • Integers
  • Matrices
  • Mathematical Structures