Discrete Mathematics -- Chapter 6: Languages: Finite Ch t 6 L Fi it State Machine Hung-Yu Kao ( 高宏宇 ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U
Outline � 6.1 Language: The Set Theory of Strings � 6 2 Finite State Machines: A First Encounter � 6.2 Finite State Machines: A First Encounter � 6.3 Finite State Machines: A Second Encounter 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 2
Language: The Set Theory of Strings A finite state machine (FSM), which is an abstract model, has a � finite number of internal states where the machine remembers certain information when it is in a particular state. t i i f ti h it i i ti l t t Strings: Sequence of symbols (characters) play a key role in the � processing of information by a computer. processing of information by a computer. ∑ denote a nonempty finite set of symbols, collectively called an � alphabet. E.g., ∑ = {0, 1}, ∑ = {a, b, c, d, e}. + Definition 6.1: If ∑ is an alphabet and , we define the powers ∈ Z n � of ∑ recursively as follows: 1 ∑ = ∑ 1) + ∑ 1 = ∈ ∑ ∈ ∑ n n 2) ) { { | | , , }, }, where denotes the j juxtaposit p ion of and xy y x y y xy y x y y 2009 Spring 2009 Spring Discrete Mathematics – Discrete Mathematics – CH6 CH6 3
Language: The Set Theory of Strings � Ex 6.1 : Let ∑ an alphabet. E 6 1 L t ∑ l h b t 2 2 = ∑ = ∈ ∑ ∈ ∑ ∑ = ∑ = If 2, { | , }, e.g., { 0 , 1 }, { 00 , 01 , 10 , 11 } n xy x y ∑ ∑ = ∑ ∑ 3 3 3 3 { { , , , , }, } would ld contain i 5 three h - symbol b l strings, i e.g., , , , etc . a b b c d d e aaa acb b cdd dd λ λ λ λ � Definition 6.2: For an alphabet ∑ we define ∑ � Definition 6 2: For an alphabet ∑ we define ∑ 0 ={ } where { }, where denotes the empty string, i.e., the string consisting of no symbols taken from ∑ . λ λ ⊄ ⊄ ∑ ∑ λ λ ∉ ∉ ∑ ∑ ( ( 1 1 ) ) { { } } since since λ ≠ φ λ = ≠ = φ ( 2 ) { } because | { } | 1 0 | | � Definition 6.3: If ∑ is an alphabet, then + ∞ ∑ = ∑ = ∑ ( 1 ) n n U U + = ∈ 1 n n Z ∗ ∗ U ∞ ∑ ∑ = ∑ ∑ n n ( 2 ) = 0 n 2009 Spring 2009 Spring Discrete Mathematics – Discrete Mathematics – CH6 CH6 4
Language: The Set Theory of Strings � Ex 6.2 : Let ∑ = {0,1} the set ∑ * consists of all finite strings of 0’s and 1’s together with the empty string. (how about ∑ + ?) � If ∑ = {ß 0 1 � If ∑ = {ß,0,1,…,9,+,-,/,}, where ß denotes the blank (space). Here in 9 + / } where ß denotes the blank (space) Here in ∑ * we find familiar arithmetic expression such as (7+5)/(2-3). � Definition 6.4: + ∈ ∑ = ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ If , , , w w w x x x w y y y 1 2 1 1 2 2 1 2 m n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ∈ ∑ and , , , , , , , , x x x y y y 1 2 1 2 m n = = = then we say and are equal ( ) if and for all . w w w w m n x y i 1 2 1 2 i i 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 5
Language: The Set Theory of Strings � Definition 6.5: + = ⋅ ⋅ ⋅ ∈ ∑ ∈ ∑ ≤ ≤ Let , where for 1 . w x x x x i n 1 2 n i λ = The length of is , donated by || ||, and || || 0. w n w � Definition 6.6: + ∈ ∑ = ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ Let , , , , x y x x x x y y y y 1 2 1 2 m n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ∈ ∑ and , , , , , , , . x x x y y y 1 2 1 2 m n = ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ The concatenat ion of and : . x y xy x x x y y y 1 2 1 2 m n λ λ = λ = The concatenat ion of and : , . x x x x x λ λ λλ = λ The concatenat ion of and : . 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 6
Language: The Set Theory of Strings � Definition 6.7: ∗ ∈ ∑ 0 = λ 1 = 2 = , we define the powers of by , , , x x x x x x xx + 3 = 2 ⋅ ⋅ ⋅ 1 = ⋅ ⋅ ⋅ ∈ , , n n , , where . x xx x xx n N � Definition 6.8: ∈ ∑ ∗ = If , and , x y w xy ≠ λ then is called a prefix of , and if , then is to be a proper prefix. x w y x ≠ λ λ Si il l Similarly, i i called ll d a suffix ffi of f , it i is i a proper suffix whe ffi h n . y s w x � Definition 6.9: ∑ ∗ ∗ ∈ ∑ = If If , , and d , then h i is called ll d a substring b i of f . x y z w xyz y w λ When at least one of and is different from , we call a proper substring . x z y 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 7
Language: The Set Theory of Strings � Definition 6.10: ∗ ∑ ∑ ∑ For a given alphabet , any subset of is called a language over . φ φ This Thi includes i l d the th subset b t , which we hi h call ll th the empty t l language . Ex 6.9 : � With ∑ the alphabet of 26 letters, 10 digits, and the special symbols used in a i h ∑ h l h b f 26 l 10 di i d h i l b l d i � given implementation of C++, the collection of executable programs for that implementation constitutes a language. In the same situation, each executable program could be considered a � language, as could a particular set of such programs. � Since languages are sets , we can form the union, intersection, and symmetric difference of two languages. 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 8
Language: The Set Theory of Strings � Definition 6.11: ∗ ∑ ⊆ ∑ For an alphabet any languages , , the concatenat ion of and , A B A B ∈ ∈ denoted , is { | , } . AB ab a A b B � Ex 6.10 : ∑ = = = λ Let { , , }, and let , be the finite languages { , , }, { , }. x y z A B A x xy z B y = = Then { , , , , } and { , , , , , } AB x xy z xyy zy BA x xy z yx yxy yz = ≠ = 1) | | 5 6 | | AB BA = ≠ ≠ = ⋅ = 2) 2) | | | | 5 5 6 6 3 3 2 2 | | || || | | AB AB A A B B 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 9
Language: The Set Theory of Strings � Theorem 6.1: ∑ ⊆ ∑ * For an alphabet , let , , . A B C λ λ = λ λ = = a) ) { { } } { { } } b) b) ( ( ) ) ( ( ) ) A A A AB C A BC ∪ = ∪ ∪ = ∪ c) ( ) d) ( ) A B C AB AC B C A BA CA ∩ ∩ ⊆ ⊆ ∩ ∩ ∩ ∩ ⊆ ⊆ ∩ ∩ e) e) ( ( ) ) f) f) ( ( ) ) A A B B C C AB AB AC AC B B C C A A BA BA CA CA Proof : ∈ ∑ * (f) For , x ∈ ∩ ⇒ = ∈ ∩ ∈ ( ) where and x B C A x yz y B C z A ⇒ = ∈ ∈ = ∈ ∈ ( for and ) and ( for and ) x yz y B z A x yz y C z A ⇒ ∈ ∈ and d x BA BA x CA CA ⇒ ∈ ∩ x BA CA = = = { , , }, { , }, { , } B x xx y C y xy A y yy ∴ ∴ ∩ ∩ ⊆ ⊆ ∩ ∩ ( ( ) ) B B C C A A BA BA CA CA ∈ ∩ ∉ ∉ ∩ , ( ( ) ) xyy BA BA CA CA xyy B B C C A A 2009 Spring 2009 Spring Discrete Mathematics – Discrete Mathematics – CH6 CH6 10
Language: The Set Theory of Strings � Definition 6.12: * ⊆ ∑ For a given language we can construct other languages as follows : A + + 0 = λ 1 = ∈ 1 = ∈ ∈ a) { }, , and , n { , n } A A A n A ab|a A b A Z + = n b) , the positive closure of . A U A A + ∈ n Z + * = ∪ λ c) { }. The language A * is called the Kleene closure of A. A A (in honor of the American logician Stephen Cole Kleene, 1909 - 1994) � Ex 6.11 : ∑ ∑ = = = = = = λ λ = = ∈ ∈ 0 If If { { , , } }, and and { { }, } then then (1) (1) { { }; }; (2) (2) n { { n } }, ; ; x x y y z z A A x x A A A A x x n n N N + = ≥ = ≥ * (3) { | 1 }; and (4) { | 0 }. n n A x n A x n 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 11
Language: The Set Theory of Strings � Lemma 6.1: ∑ ⊆ ∑ ⊆ ⊆ * Let be an alphabet, with languages , . If , then n n A B A B A B = = ⊆ = 1 1 (i) 1, n A A B B Proof : = ⊆ ⇒ ⊆ ( ii ) Assuming the truth for , k k n k A B A B + = ∈ 1 ∈ ∈ ( iii ) If k , i.e. , , k . x x x A x A x A 1 1 k k ⊆ ⇒ ⊆ ∴ ∈ ∈ k k ( induction hypothesis ), , k Q A B A B x B x B 1 k + ⇒ = ∈ = 1 k k x x x BB B 1 k + + ⇒ ⊆ 1 1 k k A B 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH6 CH6 12
Recommend
More recommend