Course Material Website:http://www.cs.colostate.edu/~cs301 - - PDF document

course material
SMART_READER_LITE
LIVE PREVIEW

Course Material Website:http://www.cs.colostate.edu/~cs301 - - PDF document

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


slide-1
SLIDE 1
  • 1

CS 301 - Lecture 1 Deterministic Finite Automata

Fall 2008

Course Material

  • Website:http://www.cs.colostate.edu/~cs301

– Syllabus, Outline, Grading Policies – Homework and Slides

  • Instructor: Dan Massey

– Office hours: 2-3pm Tues and Wed – Email: massey@cs.colostate.edu

  • Teaching Assistant: William Springer

– Email: wmspring@cs.colostate.edu

Grading and Policies

  • Grading

– 10% Homework – 30% Quizes – 30% Midterm – 30% Final

  • Grading Policy

– No credit for late homework. No exceptions. – No credit for missed exams. No make-up exams.

Workload

  • Weekly Reading Assignments

– Course will cover most of both books

  • Weekly Homework Assignments

– Available from course website by Friday morning – Due in lecture the following Thursday

  • Exams

– Midterm + final (comprehensive) – In class, closed book, one double-sided cheat sheet allowed

slide-2
SLIDE 2
  • 2

Administrative

  • You are responsible for knowing course,

department, and university policies

– READ THE SYLLABUS – PROVIDES LINKS TO DEPT POLICIES

  • Plagiarism – see definition

– http://writing.colostate.edu/guides/teaching/ plagiarism/

  • Conflict Resolution web site

– http://www.conflictresolution.colostate.edu/

About These Slides

  • Slides Originally Developed by Prof. Costas

Busch (2004)

– Many thanks to Prof. Busch for developing the

  • riginal slide set.
  • Adapted with permission by Prof. Dan

Massey (Spring 2007)

– Subsequent modifications

  • A language is a set of strings
  • String: A sequence of letters

– Examples: “cat”, “dog”, “house”, … – Defined over an alphabet:

{ }

z c b a , , , , … = Σ

Languages

Alphabets and Strings

  • We will use small alphabets:
  • Strings

abba w bbbaaa v ab u = = =

{ }

b a, = Σ b aaabbbaaba baba abba ab a

slide-3
SLIDE 3
  • 3

m n

b b b v a a a w  

2 1 2 1

= = bbbaaa abba

m n

b b b a a a wv  

2 1 2 1

=

Concatenation => abbabbbaaa

String Concatenation

1 2a

a a w

n R

 =

n

a a a w 

2 1

= ababaaabbb

Reverse => bbbaaababa

String Reverse String Length

n

a a a w 

2 1

= n w = 1 2 4 = = = a aa abba

Length =

Length and Concatenation

v u uv + = 8 5 3 8 5 , 3 , = + = + = = = = = = = v u uv aababaab uv v abaab v u aab u

Does this prove the formula is true? Can you prove the formula is true?

slide-4
SLIDE 4
  • 4

Empty String

  • A string with no letters:
  • Observations:

λ abba abba abba w w w = = = = = λ λ λ λ λ

Substring

  • Subsequence of consecutive characters
  • String Substring

bbab b abba ab abbab abbab abbab abbab

Prefix and Suffix

abbab abbab abba abb ab a λ λ b ab bab bbab abbab uv w =

prefix suffix

More Concatenation

     

n n

w ww w =

( )

abbaabba abba =

2

λ = w

( )

λ = abba

slide-5
SLIDE 5
  • 5

* Σ Σ

{ } { }

… , , , , , , , , , * , aab aaa bb ba ab aa b a b a λ = Σ = Σ

The * Operation

Given an alphabet Is the set of all strings over the alphabet

Σ

The + Operation

Given an alphabet Is the set of all strings over the alphabet minus

+

Σ λ λ − Σ = Σ+ *

{ }

… , , , , , , , , aab aaa bb ba ab aa b a = Σ+

{ } { }

… , , , , , , , , , * , aab aaa bb ba ab aa b a b a λ = Σ = Σ

Languages

* Σ

{ } { }

… , , , , , , , , * , aaa bb ba ab aa b a b a λ = Σ = Σ

{ } { }

} , , , , , { , , aaaaaa ab aa baba abba aab aa a λ λ

A Language is any subset of Given an alphabet: Some Languages over this alphabet include:

} { } { λ ≠ = ∅ } { = ∅ = 1 } { = λ = λ

Sets Set size Set size String length

Languages, Sets, and Notations

slide-6
SLIDE 6
  • 6

An Infinite Language } : { ≥ = n b a L

n n

aaaaabbbbb aabb ab λ L ∈ L abb∉

What is the alphabet associated with this language?

Languages and Operations

{ } { } { } { } { } { } { }

aaaa a ab bb aaaa ab a ab ab bb aaaa ab a aaaa bb ab a ab bb aaaa ab a , , , , } { , , , } , , , { , , , = − = =  

A language is a set and set operations apply

The Complement of a Language

L L − Σ = *

{ } { }

… , , , , , , , aaa bb ab aa b ba a λ =

Intuitively, all strings not in the language. More precisely: Is ccc in the complement of this language?

Reverse

} : { L w w L

R R

∈ =

{ } { }

abab baa ba baba aab ab

R

, , , , = } : { } : { ≥ = ≥ = n a b L n b a L

n n R n n

slide-7
SLIDE 7
  • 7

Concatenation

{ }

2 1 2 1

, : L y L x xy L L ∈ ∈ =

{ } { } { }

baaa bab abaa abb aaa ab aa b ba ab a , , , , , , , , =

More Concatenation

   

n n

L LL L =

{ } { } { } { } { }

bbb bba bab baa abb aba aab aaa b a b a b a b a , , , , , , , , , , ,

3

= =

{ }

{ }

{ }

λ λ = = , , aaa bba a L

Star-Closure (Kleene *)

  

2 1

* L L L L =

{ }

              = … , , , , , , , , , , , * , abbbb abba aabb aaa bbbb bba abb aa bb a bb a λ

Is Our Notation Sufficient?

} : { ≥ = n b a L

n n

} , : {

2

≥ = m n b a b a L

m m n n 2

L aabbaaabbb∈

Describe a language by listing all the strings in the language But this only works for finite languages Describe a language by listing some pattern such as: But this has limits as well…. Consider the language of all valid English sentences

slide-8
SLIDE 8
  • 8

Automata Finite Automaton

Input String Output String Finite Automaton

Finite Accepter

Input “Accept”

  • r

“Reject” String Finite Automaton Output

Transition Graph

initial state final state “accept” state transition Abba -Finite Accepter q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a,

slide-9
SLIDE 9
  • 9

Initial Configuration

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, Input String a b b a b a, q

Reading the Input

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b b a b a, q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b b a b a, q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b b a b a,

slide-10
SLIDE 10
  • 10

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b b a b a, q

1

q

2

q

3

q

4

q a b b a Output: “accept”

5

q a a b b b a, a b b a b a, Input finished

String Rejection

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b a b a, q q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b a b a,

slide-11
SLIDE 11
  • 11

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b a b a, q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, a b a b a, q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, Output: “reject” a b a b a, Input finished

The Empty String

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q λ

slide-12
SLIDE 12
  • 12

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q Output: “reject” λ

Would it be possible to accept the empty string?

Another Example

a b b a, b a, q

1

q

2

q a b a a b b a, b a, q

1

q

2

q a b a a b b a, b a, q

1

q

2

q a b a

slide-13
SLIDE 13
  • 13

a b b a, b a, q

1

q

2

q a b a a b b a, b a, q

1

q

2

q a b a Output: “accept” Input finished

Rejection

a b b a, b a, q

1

q

2

q a b b a b b a, b a, q

1

q

2

q a b b

slide-14
SLIDE 14
  • 14

a b b a, b a, q

1

q

2

q a b b a b b a, b a, q

1

q

2

q a b b a b b a, b a, q

1

q

2

q a b b Output: “reject” Input finished

Which strings are accepted?

Formalities

  • Deterministic Finite Accepter (DFA)

( )

F q Q M , , , , δ Σ = Q Σ δ q F

: set of states : input alphabet : transition function : initial state : set of final states

slide-15
SLIDE 15
  • 15

Input Alphabet Σ

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a,

{ }

b a, = Σ

b a,

Set of States Q

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a,

{ }

5 4 3 2 1

, , , , , q q q q q q Q =

b a,

Initial State 0

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q

Set of Final States F

q

1

q

2

q

3

q a b b a

5

q a a b b b a,

{ }

4

q F =

b a,

4

q

slide-16
SLIDE 16
  • 16

Transition Function

δ

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a,

Q Q → Σ × : δ

b a,

( )

1 0,

q a q = δ

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q

1

q

( )

5 0,

q b q = δ

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a,

( )

3 2,

q b q = δ

slide-17
SLIDE 17
  • 17

Transition Function δ

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, δ a b q

1

q

2

q

3

q

4

q

5

q

1

q

5

q

5

q

2

q

5

q

3

q

4

q

5

q b a,

5

q

5

q

5

q

5

q

Extended Transition Function *

δ Q Q → Σ × * : * δ

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a,

( )

2 0,

* q ab q = δ

3

q

4

q a b b a

5

q a a b b b a, b a, q

1

q

2

q

( )

4 0,

* q abba q = δ

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a,

slide-18
SLIDE 18
  • 18

( )

5 0,

* q abbbaa q = δ

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q

( )

q w q ′ = , * δ

Observation: There is a walk from to with label

q

q′

w q q′

w

q q′

k

w σ σ σ 

2 1

=

1

σ

2

σ

k

σ

( )

5 0,

* q abbbaa q = δ

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a, q Example: There is a walk from to with label

q abbbaa

5

q

Recursive Definition

( ) ( )

) ), , ( * ( , * , * σ δ δ σ δ λ δ w q w q q q = = q q′ σ

w

1

q

( )

q q q w q ′ = ′ = ) , ( , *

1 σ

δ σ δ

( ) ( )

1 1

, * ) , ( , * q w q q w q = = δ σ δ σ δ

( )

) ), , ( * ( , * σ δ δ σ δ w q w q =

slide-19
SLIDE 19
  • 19

q

1

q

2

q

3

q

4

q a b b a

5

q a a b b b a, b a,

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

2 1

, , , , , , * ), , ( * , * q b q b a q b a q b a q ab q = = = = = δ δ δ λ δ δ δ δ δ δ

Languages Accepted by DFAs

  • Take DFA
  • Definition:

– The language contains all input strings accepted by

– = { strings that drive to a final state}

M

( )

M L M

( )

M L M

What’s Next

  • Read

– Linz Chapter 1, Chapter 2.1 - 2.3 – JFLAP Startup, Chapter 1, 2.1

  • Next Lecture Topics from Chapter 2.1 and 2.2

– Regular Languages – NonDeterministic Finite Automata

  • Homework 1

– Due Thursday