Course Material • Website:http://www.cs.colostate.edu/~cs301 – Syllabus, Outline, Grading Policies CS 301 - Lecture 1 – Homework and Slides Deterministic Finite Automata • Instructor: Dan Massey – Office hours: 2-3pm Tues and Wed Fall 2008 – Email: massey@cs.colostate.edu • Teaching Assistant: William Springer – Email: wmspring@cs.colostate.edu Grading and Policies Workload • Grading • Weekly Reading Assignments – 10% Homework – Course will cover most of both books – 30% Quizes • Weekly Homework Assignments – 30% Midterm – Available from course website by Friday morning – 30% Final – Due in lecture the following Thursday • Grading Policy • Exams – Midterm + final (comprehensive) – No credit for late homework. No exceptions. – In class, closed book, one double-sided cheat sheet – No credit for missed exams. No make-up exams. allowed • 1
Administrative About These Slides • You are responsible for knowing course, • Slides Originally Developed by Prof. Costas department, and university policies Busch (2004) – READ THE SYLLABUS – Many thanks to Prof. Busch for developing the original slide set. – PROVIDES LINKS TO DEPT POLICIES • Adapted with permission by Prof. Dan • Plagiarism – see definition Massey (Spring 2007) – http://writing.colostate.edu/guides/teaching/ plagiarism/ – Subsequent modifications • Conflict Resolution web site – http://www.conflictresolution.colostate.edu/ Languages Alphabets and Strings • We will use small alphabets: { a , b } • A language is a set of strings Σ = • Strings • String: A sequence of letters a ab – Examples: “cat”, “dog”, “house”, … u ab = abba v bbbaaa = – Defined over an alphabet: baba w abba = a , b , c , … , z { } Σ = aaabbbaaba b • 2
String Concatenation String Reverse w a a a = 1 2 n w a a a = 1 2 n v b b b = 1 2 m R w a a 2 a = n 1 wv a a a b b b = 1 2 n 1 2 m abba Concatenation => abbabbbaaa Reverse => bbbaaababa ababaaabbb bbbaaa String Length Length and Concatenation uv u v w a a a = + = 1 2 n u aab , u 3 w = n = = Length = v abaab , v 5 = = abba 4 = uv aababaab 8 aa 2 = = = uv u v 3 5 8 a 1 = + = + = = Does this prove the formula is true? Can you prove the formula is true? • 3
Substring Empty String • S ubsequence of consecutive characters • A string with no letters: λ • String Substring 0 λ = abbab ab • Observations: abbab abba w w w λ = λ = abbab b abbab bbab abba abba abba λ = λ = More Concatenation Prefix and Suffix w = uv n w = ww w prefix suffix n abbab λ 0 abbab w = λ a bbab ab bab 2 abba abbaabba ( ) = abb ab 0 ( abba ) = λ abba b abbab λ • 4
The * Operation The + Operation Σ Σ Given an alphabet Given an alphabet + * Σ λ Is the set of all strings over the alphabet Σ Is the set of all strings over the alphabet minus Σ + * = Σ − λ { a , b } Σ = a , b { } Σ = * , a , b , aa , ab , ba , bb , aaa , aab , … { } Σ = λ * { , a , b , aa , ab , ba , bb , aaa , aab , … } Σ = λ Σ + a , b , aa , ab , ba , bb , aaa , aab , … { } = Languages Languages, Sets, and Notations * Σ A Language is any subset of { } { } ∅ = ≠ λ Sets Given an alphabet: a , b { } Σ = { } 0 = ∅ = Set size * , a , b , aa , ab , ba , bb , aaa , … { } Σ = λ Some Languages over this alphabet include: { } 1 λ = Set size { } λ { a , aa , aab } 0 String length λ = { , abba , baba , aa , ab , aaaaaa } λ • 5
An Infinite Language Languages and Operations n n L { a b : n 0 } = ≥ A language is a set and set operations apply a , ab , aaaa bb , ab { a , ab , bb , aaaa } { } { } = { a , ab , aaaa } { bb , ab } { ab } λ = ab a , ab , aaaa bb , ab a , aaaa { } { } { } − = L abb ∉ L ∈ aabb What is the alphabet aaaaabbbbb associated with this language? Reverse The Complement of a Language R R L { w : w L } = ∈ Intuitively, all strings not in the language. More precisely: L * L = Σ − R { ab , aab , baba } { ba , baa , abab } = a , ba , b , aa , ab , bb , aaa , … { } { } = λ n n L { a b : n 0 } = ≥ Is ccc in the complement of this language? R n n L { b a : n 0 } = ≥ • 6
Concatenation More Concatenation n L = LL L L L { xy : x L , y L } = ∈ ∈ 1 2 1 2 n 0 L { } = λ a , ab , ba b , aa 0 { } { } a , bba , aaa { } = { } λ 3 { a , b } { a , b } { a , b } { a , b } = = ab , aaa , abb , abaa , bab , baaa { } = aaa , aab , aba , abb , baa , bab , bba , bbb { } Star-Closure (Kleene *) Is Our Notation Sufficient? 0 1 2 Describe a language by listing all the strings in the language L = * L L L But this only works for finite languages Describe a language by listing some pattern such as: , λ n n L { a b : n 0 } = ≥ a , bb , a , bb * 2 n n m m { } = L { a b a b : n , m 0 } = ≥ aa , abb , bba , bbbb , 2 aabbaaabbb ∈ L aaa , aabb , abba , abbbb , … But this has limits as well…. Consider the language of all valid English sentences • 7
Automata Finite Automaton Input String Output Finite String Automaton Transition Graph Finite Accepter a , b Abba -Finite Accepter Input String q 5 a , b Output b a a b a b b a “Accept” q q q q q 0 1 2 3 4 Finite or initial final Automaton “Reject” state state transition “accept” state • 8
Initial Configuration Reading the Input Input String a b b a a b b a a , b a , b q q 5 5 a , b a , b b a b a a b a b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 a b b a a b b a a , b a , b q q 5 5 a , b a , b a a b b a a b b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 • 9
Input finished a b b a a b b a a , b a , b q q 5 5 a , b a , b b a b a a b a b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 Output: “accept” String Rejection a b a a b a a , b a , b q q 5 5 a , b a , b a a b b a a b b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 • 10
a b a a b a a , b a , b q q 5 5 a , b a , b b a b a a b a b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 Input finished The Empty String a b a λ a , b a , b Output: q “reject” q 5 5 a , b a , b a a b b a a b b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 • 11
Another Example a a b λ a , b a , b a q 5 a , b a , b b a b a b q q q 0 1 2 a a b b q q q q q 0 1 2 3 4 Output: Would it be possible to accept the empty string? “reject” a a b a a b a , b a , b a a a , b a , b b b q q q q q q 0 1 2 0 1 2 • 12
Input finished a a b a a b a , b a , b a a Output: “accept” a , b a , b b b q q q q q q 0 1 2 0 1 2 Rejection b a b b a b a , b a , b a a a , b a , b b b q q q q q q 0 1 2 0 1 2 • 13
b a b b a b a , b a , b a a a , b a , b b b q q q q q q 0 1 2 0 1 2 Input finished Formalities M ( Q , , , q , F ) b a b = Σ δ 0 • Deterministic Finite Accepter (DFA) Which strings are accepted? Q : set of states a , b a : input alphabet Σ a , b : transition function b δ q q q 0 1 2 q : initial state 0 Output: “reject” : set of final states F • 14
Set of States Q Input Alphabet Σ a , b { } Σ = Q = { q , q , q , q , q , q } 0 1 2 3 4 5 a , b a , b q q 5 5 a , b a , b a b a a b b a b a a b b q q q q q a a b b q q q q q 0 1 2 3 4 0 1 2 3 4 Set of Final States F q Initial State 0 F = { } q 4 a , b a , b q q 5 5 a , b a , b a a b b a a b b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 • 15
Transition Function δ q 0 , a q ( ) δ = : Q Q 1 δ × Σ → a , b a , b q q 5 5 a , b a , b a a b b a b a b a a a a b b b b q q q q q q q q q q 0 1 2 3 0 1 2 3 4 4 ( q 0 , b ) q ( q 2 , b ) q δ = δ = 5 3 a , b a , b q q 5 5 a , b a , b a a b b a a b b a a a a b b b b q q q q q q q q q q 0 1 2 3 4 0 1 2 3 4 • 16
Recommend
More recommend