Download presentation
Presentation is loading. Please wait.
Published byMargery Underwood Modified over 9 years ago
1
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 2 School of Innovation, Design and Engineering Mälardalen University 2012
2
2 Content Languages, Alphabets and Strings Strings & String Operations Languages & Language Operations Regular Languages and their Representations Regular Expressions
3
3 Languages, Alphabets and Strings Based on C Busch, RPI, Models of Computation
4
4 defined over an alphabet: Languages A language is a set of strings A string is a sequence of symbols An alphabet is a set of symbols.
5
5 Alphabets and Strings We will use small alphabets: Strings
6
6 Operations on Strings
7
7 String Operations m n bbbv aaaw 21 21 y bbbaaa x abba Concatenation (sammanfogning) xy abbabbbaaa
8
8 Reverse (reversering) Example: Longest odd length palindrome in a natural language: saippuakauppias (Finnish: soap sailsman)
9
9 String Length Length: Examples:
10
10 Recursive Definition of Length For any letter: For any string : Example:
11
11 Length of Concatenation 853 8 vuuv aababaabuv 5, 3, vabaabv uaabu Example:
12
12 Proof of Concatenation Length Claim: Proof: By induction on the length Induction basis: From definition of length:
13
13 Inductive hypothesis: Inductive step: we will prove for
14
14 Inductive Step Write, where From definition of length: From inductive hypothesis: Thus: END OF PROOF
15
15 Empty String A string with no letters: (Also denoted as ) Observations:
16
16 Substring (delsträng) Substring of a string: a subsequence of consecutive characters String Substring
17
17 Prefix and Suffix Suffixes prefix suffix Prefixes
18
18 Repetition Example: Definition: n n www...w } (String repeated n times)
19
19 The (Kleene* star) Operation the set of all possible strings from alphabet [* Kleene is pronounced "clay-knee“] http://en.wikipedia.org/wiki/Kleene_star
20
20 The + (Kleene plus) Operation : the set of all possible strings from the alphabet except ,ba ,,,,,,,,,*aabaaabbbaabaaba
21
21 Example *, oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch * ,fyoj , usch oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch
22
22 Operations on Languages
23
23 Language A language is any subset of Example: Languages: ,,,,,,,,*, aaabbbaabaaba ba },,,,,{,, aaaaaaabaababaabba aabaaa
24
24 Example An infinite language
25
25 Operations on Languages The usual set operations ,,,,,,,,,*aabaaabbbaabaaba Complement:
26
26 Reverse Examples: Definition:
27
27 Concatenation Definition: Example
28
28 Repeat Definition: Special case:
29
29 Example
30
30 Star-Closure (Kleene *) Definition: Example:
31
31 Positive Closure Definition *L 2 1 L LL
32
32 Regular Languages
33
Definition of Set of Regular Languages Basis Clause: where are regular languages. Inductive Clause: If L r and L s are regular languages, then L r L s, L r L s and L r * are regular languages. Nothing is a regular language unless it is obtained from the above two clauses. 33
34
34 Standard Representations of Regular Languages
35
35 Regular Language Representations DFA NFA Regular Expression Regular Grammar Regular Language
36
36 Regular Expressions
37
37 Regular Expressions: Recursive Definition are Regular Expressions Primitive regular expressions: Given regular expressions and
38
38 Examples A regular expression: Not a regular expression:
39
39 Zero or more. a* means "zero or more a's." To say "zero or more ab's," that is, {, ab, abab, ababab,...}, you need to say (ab)*. ab* denotes {a, ab, abb, abbb, abbbb,...}. Building Regular Expressions
40
40 One or more. Since a* means "zero or more a's", you can use aa* (or equivalently, a*a) to mean "one or more a's.“ Similarly, to describe "one or more ab's," that is, {ab, abab, ababab,...}, you can use ab(ab)*. Building Regular Expressions
41
41 Any string at all. To describe any string at all (with = {a, b, c}), you can use (a+b+c)*. Any nonempty string. This can be written as any character from followed by any string at all: (a+b+c)(a+b+c)*. Building Regular Expressions
42
42 Any string not containing.... To describe any string at all that doesn't contain an a (with = {a, b, c}), you can use (b+c)*. Any string containing exactly one... To describe any string that contains exactly one a, put "any string not containing an a," on either side of the a, like this: (b+c)*a(b+c)*. Building Regular Expressions
43
43 Languages of Regular Expressions Example language of regular expression
44
44 Definition For primitive regular expressions:
45
45 Definition (continued) For regular expressions and
46
46 Example Regular expression:
47
47 Example Regular expression
48
48 Example Regular expression
49
49 Example Regular expression { all strings with at least two consecutive 0 }
50
50 Example Regular expression (consists of repeating 1’s and 01’s). = { all strings without two consecutive 0 }
51
51 Example = { all strings without two consecutive 0 } (In order not to get 00 in a string, after each 0 there must be an 1, which means that strings of the form 1....101....1 are repeated. That is the first parenthesis. To take into account strings that end with 0, and those consisting of 1’s solely, the rest of the expression is added.) Equivalent solution:
52
52 Equivalent Regular Expressions Regular expressions and are equivalent if Definition:
53
53 Example = { all strings without two consecutive 0 } and are equivalent regular expressions.
54
Lennart Salling’s Video Resources http://www.math.uu.se/~salling/http://www.math.uu.se/~salling/ Lennart Salling http://www.math.uu.se/~salling/AUTOMATA_DV/index.html Introduktion: http://www2.math.uu.se/~salling/Movies/Intro%20to%20Automata.movhttp://www2.math.uu.se/~salling/Movies/Intro%20to%20Automata.mov Program, strings, integers and integer functions http://www2.math.uu.se/~salling/Movies/StringsNumbersAndFunctions.mov http://www.youtube.com/embed/EuhbL0MPryUhttp://www.youtube.com/embed/EuhbL0MPryU Vad handlar kursen om? http://www.youtube.com/embed/VM5SUcyY4sI?hl=en&fs=1http://www.youtube.com/embed/VM5SUcyY4sI?hl=en&fs=1 Kan alla problem lösas av program? http://www.youtube.com/embed/acsUNSkzUgg?hl=en&fs=1http://www.youtube.com/embed/acsUNSkzUgg?hl=en&fs=1 Vad har stora och små oändligheter med saken att göra? http://www.youtube.com/embed/eQoP_kuNgXU?hl=sv&fs=1http://www.youtube.com/embed/eQoP_kuNgXU?hl=sv&fs=1 Vad har språk och beräkningar med varandra att göra? http://www.youtube.com/embed/-4K72wsQmPI?hl=sv&fs=1http://www.youtube.com/embed/-4K72wsQmPI?hl=sv&fs=1 Reguljära språk, vad är det? http://www.youtube.com/embed/R2bHYnBXWFs?hl=sv&fs=1http://www.youtube.com/embed/R2bHYnBXWFs?hl=sv&fs=1 Vilka automater är specialiserade på reguljära språk? http://www.youtube.com/embed/2PNyEWl1AI0?hl=sv&fs=1http://www.youtube.com/embed/2PNyEWl1AI0?hl=sv&fs=1 Varför icke-determinism? http://www.youtube.com/embed/2abHjjS8Tqc?hl=sv&fs=1http://www.youtube.com/embed/2abHjjS8Tqc?hl=sv&fs=1 Hur ser problem ut som inte kan lösas av program? http://www.youtube.com/embed/WMN_wz-b3K0?hl=sv&fs=1 http://www.youtube.com/embed/y-zMnV3G9pg?hl=sv&fs=1 http://www.youtube.com/embed/y-zMnV3G9pg?hl=sv&fs=1 Hur kan man visa att ett problem inte kan lösas av program? 54
55
Lennart Salling’s Video Video Resources http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Closure_properties/Closure_properties.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/FA_to_RegExpression/FA_to_RegExpression.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Famous_undecidable_and_decidable_problems/Famous_und ecidable_and_decidable_problems.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Universal_Turing_machines/Universal_Turing_machines.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Turing_machines/Turing_machines.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Unrestricted_grammar/Unrestricted_grammar.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Pumping%20CFL/Pumping%20CFL.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/PDA/PDA.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/CFG/CFG.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Nonregularity/Nonregularity.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Reduction_of_number_of_states/Reduction_of_number_of_st ates.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Closure_properties/Closure_properties.mov http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/FA_to_RegExpression/FA_to_RegExpression.mov 55
56
More Video’s 1 www.youtube.com/watch?v=MzDG34w0LLA&feature=player_embeddedwww.youtube.com/watch?v=MzDG34w0LLA&feature=player_embedded SubsetConstruction http://www.youtube.com/watch?v=acsUNSkzUgg&feature=relatedhttp://www.youtube.com/watch?v=acsUNSkzUgg&feature=related Infinities http://www.youtube.com/watch?v=y-zMnV3G9pg&feature=relatedhttp://www.youtube.com/watch?v=y-zMnV3G9pg&feature=related Rice'sTheorem http://www.youtube.com/watch?v=R2bHYnBXWFs&feature=relatedhttp://www.youtube.com/watch?v=R2bHYnBXWFs&feature=related Finite Automata http://www.youtube.com/watch?v=eQoP_kuNgXU&feature=relatedhttp://www.youtube.com/watch?v=eQoP_kuNgXU&feature=related Strings and Languages http://www.youtube.com/watch?v=-4K72wsQmPI&feature=relatedhttp://www.youtube.com/watch?v=-4K72wsQmPI&feature=related Regular Languages http://www.youtube.com/watch?v=WMN_wz-b3K0&feature=relatedhttp://www.youtube.com/watch?v=WMN_wz-b3K0&feature=related Accept and decide (TM) 56
57
More Video’s 2 http://www.youtube.com/watch?v=RYNN-tb9WxI&feature=related Regular Expression to NFA http://www.youtube.com/watch?v=shN_kHBFOUE&feature=relatedhttp://www.youtube.com/watch?v=shN_kHBFOUE&feature=related 2 - Convert Regular Expression to Finite-State Automaton http://www.youtube.com/watch?v=dlH2pIndNrU&feature=relatedhttp://www.youtube.com/watch?v=dlH2pIndNrU&feature=related Convert Regular Expression to DFA http://www.youtube.com/watch?v=5a_pO3NYJl0http://www.youtube.com/watch?v=5a_pO3NYJl0 Great Principles of Computing - Peter J. Denning http://www.youtube.com/watch?v=60P7717-XOQ&feature=relatedhttp://www.youtube.com/watch?v=60P7717-XOQ&feature=related Stephen Wolfram: Computing a theory of everything http://www.youtube.com/watch?v=cCdbZqI1r7I&feature=relatedhttp://www.youtube.com/watch?v=cCdbZqI1r7I&feature=related Computing Beyond Turing - Jeff Hawkins 57
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.