Download presentation
Presentation is loading. Please wait.
Published byNeal Sullivan Modified over 9 years ago
1
Strings and Languages Denning, Section 2.7
2
Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object used in the construction of sentences. Examples V 1 = { a, b, c, d, e, …, z } V 2 = { 0, 1 }
3
Strings A string w of length k on an alphabet V is a sequence of k symbols w = a 1 a 2 a 3 … a k where each symbol a j comes from alphabet V. Examples aabakkejaa is a string of length 10 from V 1 00011001 is a string of length 8 from V 2
4
Length of String The string w = a 1 a 2 a 3 … a k has length k and we write: |w| = k The unique string containing no symbols is called the empty string, denoted by or . Thus | | = 0. Examples: |bababaako| = 9 | | = 0 |01101001| = 8
5
Set of All Strings on V If V is an alphabet, we denote by W k the set of all strings of length k on V: W k = {w ; |w| = k }. We denote by W 0 the set containing just the empty string W 0 = { }. The set of all strings on V is W, and is defined by W = W k where k = 0 to . Thus W = W 0 W 1 W 2 … W k …
6
Concatenation on W Concatenation is a binary operation on W which takes two strings w 1 and w 2 and produces a third string w 1 w 2 by juxtaposing w 2 after w 1. Example: If V = {0, 1}, and W is the set of all strings from V, and if w 1 = 00011, w 2 = 100000, then w 1 w 2 = 00011100000.
7
Prefixes and suffixes If and are two strings from W, and if = , then we say that is a prefix of , and is a suffix of . If is not empty, then is a proper prefix of . Similarly, if is not empty, then is a proper suffix of .
8
Properties of Concatenation W is closed under concatenation. If W, and W, then W. Concatenation is associative. If , , W, then ( ) = ( ) . The empty string is the identity element. For each string in W, = = .
9
More Properties Concatenation is not commutative. If , W, then , in general. For all , W, the lengths are related as follows: | | = | | + | |.
10
Some Notation w k is the concatenation of k copies of w, that is w k = www … w, k times. If w = a 1 a 2 a 3 … a k, then w R = a k a k-1 … a 3 a 2 a 1. w R is called the reverse of w.
11
Denumerability of W Proposition 2.9: Let V be an alphabet (finite nonempty set of atomic symbols), and let W be the set of all strings from V. Then W is denumerable, that is W is countably infinite.
12
Outline of Proof Let |V| = n, and let h(v) be a function that associates the numbers 1, 2, 3, …, n to the symbols v in V. Define a function f(w) on W such that f( ) = 0 f(wv) = nf(w) + h(v), where w W, v V Prove that f( ) is one-to-one and onto.
13
Languages A language L on an alphabet V is any set L of strings on V. That is L W, where W is the set of all strings on V. The set of all languages on V is the set of all subsets of W, that is P (W) the powerset of W. Since W is countably infinite, then P (W) is uncountably infinite.
14
Examples of languages V = {0, 1} L = {00, 01, 10, 11} V = {a} L = {, a, a 2, a 3, a 4,... } = { a k | k 0 } V = {0, 1} L = {1, 01, 001, 0001,... }
15
Operations on Languages Set operations on languages A and B union A B intersection A B complement A c = W – A Concatenation of languages A and B AB = { | Kleene closure A*
16
Concatenation of Languages Example: A = {a, ab} B = {c, bc} AB = {ac, abc, abbc} BA = {ca, cab, bca, bcab} Thus AB BA
17
Kleene Closure A* If V is an alphabet, W the set of all strings on V, A W, A a language on V, then the Kleene closure of A, denoted by A*, is defined as follows: A 0 = { } = A 1 = A, A 2 = AA A 3 = A 2 A,..., A k+1 = A k A,... A* = A 0 A 1 A 2 A 3 ...
18
Special Languages = { set containing empty string = { } = the empty set For any language A, A = A = A For any language A, A = A =
19
Properties of Concatenation Concatenation of sets is associative A(BC) = (AB)C Concatenation is not commutative AB BA Concatenation distributes over union A(B C) = AB AC Concat does NOT distribute over intersection A(B C) AB AC
20
Exercises Denning, p48, No. 2.27 – 2.31 No. 2.27 Let A, B, C be arbitrary languages on an alphabet V. If true, then prove. Else give a counterexample: A(BA)* = (AB)*A (AB)* = A*B* A(B* C*) = AB* AC*
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.