150 likes | 163 Views
Lecture 3 Strings and Things (Section 1.1). Theory of Information. Congruency Modulo n. Remember that Z n ={0,1,…,n-1} If and are integers, the following three conditions are equivalent: 1. and have the same remainder when divided by n 2. - is divisible by n
E N D
Lecture 3Strings and Things(Section 1.1) Theory of Information
Congruency Modulo n Remember that Zn={0,1,…,n-1} If and are integers, the following three conditions are equivalent: 1. and have the same remainder when divided by n 2. - is divisible by n 3. there is an integer k for which =+kn When any (and hence all) of these conditions hold, we say that • and are congruent modulo n, and write (mod n)
Examples of Congruency 53(mod 2)? 14143(mod 2)? 14410(mod 5)? 1934124(mod 10)? -515(mod 5)? -78(mod 2)? -5 -2 147101316(mod 3)?
Residue Given an integer , there is exactly one element in Zn congruent to (modulo n). Such an integer is called the residue of modulo n. The residue of 25 modulo 7 is The residue of 32 modulo 7 is The residue of 9925 modulo 2 is The residue of 8764 modulo 2 is Give me a number whose residue modulo 7 is 7
Modular Arithmetic Let a,bZn. It, together with the following operations, is called integers modulo n: a+nb= the residue of a+b modulo n anb= the residue of ab modulo n Z5={0,1,2,3,4}. Let us just write + and instead of +5 and 5 . 1+3= 1+4= 2+3= 4+4= 23= 44= 04= 14= 0+3=
Arithmetic Tables for Z2 Multiplication modulo 2: 0 1 0 1 Addition modulo 2: 0 1 0 1
With ordinary addition and multiplication, are the following sets fields? {0,1,…} {…-2,-1,0,1,2,…} The set of rational numbers • DEFINITION A field is a nonempty set F, together with two binary • operations on F, called addition (+) and multiplication (, often omitted), • satisfying the following properties: • Associativity: +(+)=(+)+; ()=(). • Commutativity: +=+; =. • Distributivity: (+)= +. • Properties of 0 and 1: There are two distinct () elements: 0 (zero) • and 1 (one) such that, for all F, we have 0+= and 1=. • Inverse properties: • a) For every F, there is another element of F denoted by - and • called the negative of , such that +(-)=0; • b) For every nonzero F, there is another element of F denoted by • -1 and called the inverse of , such that (-1)=1. Fields
Integers Modulo 2 Is a Field For Z2={0,1} (as well as all other Zn), associativity, commutativity and distributivity hold because they hold for the ordinary + and . What is the negative of: 0? 1? What is the inverse of: 1? Subtraction - means +(-). In our case, 0-0= 0-1= 1-0= 1-1=
Integers Modulo 3 Is a Field What is the negative of: 0? 1? 2? What is the inverse of: 1? 2?
Integers Modulo 4 Is not a Field Z2={0,1,2,3} What would be the inverse of 2? 20= 21= 22= 23=
When is Zn a field? An integer n is said to be prime iff n has no divisors other than 1 and n. Prime numbers: 2,3,7,11,13,17,19,23,29,31,41,… THEOREM 1.1.2 The set Zn of integers modulo n is a field if and only if n is a prime number.
Strings An alphabet is a finite, nonempty set S={s1,…,sn} of symbols. A string, or word over S is a finite sequence of elements of S. E.g., when S={a,b,…,z}, then school, bbb, a, xyz are strings/words over S. So is the empty string (theta). Stings over the alphabet {0,1} are called binary strings, and the symbols 0 and 1 are called bits. The complement of a binary string x is the result of replacing in x every 0 by 1 and every 1 by 0. Denoted by xc. Strings over {0,1,2} are called ternary strings.
Strings The juxtaposition (concatenation) of strings x and y is xy. len(x) denotes the length of string x. len(0010)=4, len(0)=1, len()=0. When S is an alphabet: S* stands for the set of all strings over S Sn stands for the set of all strings over S whose length is n Sn stands for the set of all strings over S whose length is n • THEOREM 1.1.3 Let S be an alphabet of size k. • |Sn|=kn • |Sn|= 1+k+k2+…+kn
Strings • THEOREM 1.1.4 • In (Z2)n, the number of strings with exactly k 0s is ( ) • In (Zr)n, the number of strings with exactly k 0s is ( )(r-1)n-k n k n k • Proof. Part 1: There is one string with exactly k 0s for every way of • choosing k of the n positions in which to place 0s. Part 2: For each • choice of where to place 0s, there are (r-1)n-k ways to arrange the • remaining (r-1) symbols in the remaining (n-k) positions.
Homework Example 1.1.4 of the textbook. Exercises 1,3,4,5,7,8 of Section 1.1 of the textbook.