Regular Languages and NFAs, Lecture notes of Theory of Computation

Regular languages and Nondeterministic Finite Automata (NFAs). It covers topics such as the difference between NFAs and DFAs, the power of regular expressions, and Kleene's Theorem. The document also includes practice problems and information about the final exam.

Typology: Lecture notes

2019/2020

Uploaded on 05/11/2023

shekhar_hin
shekhar_hin 🇺🇸

4.9

(9)

226 documents

1 / 60

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Regular Languages CSE 311 Autumn 20
Lecture 26
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c

Partial preview of the text

Download Regular Languages and NFAs and more Lecture notes Theory of Computation in PDF only on Docsity!

Regular Languages

CSE 311 Autumn 20 Lecture 26

Announcements

TAs will run a final review next week – poll on Ed to choose the day/time. HW8 is a mix of relations, DFAs/NFAs, and some review-y questions. Due next Friday Final review materials going up tonight. What’s fair game for the final? Everything through the end of this slide deck can show up in any way. (cumulative) Monday you’ll learn how to show a language is “not regular.” Wednesday you’ll learn how to show a set is “uncountable.” There will be a problem on the final “choose one of these two: show a language is irregular; show a set is uncountable” Last day of class will wrap those topics/talk about the Halting Problem (won’t be tested directly)

Let’s try to make our more powerful automata

We’re going to get rid of some of the restrictions on DFAs, to see if we can get more powerful machines (i.e. can recognize more languages). From a given state, we’ll allow any number of outgoing edges labeled with a given character. The machine can follow any of them. We’ll have edges labeled with “𝜀” – the machine (optionally) can follow one of those without reading another character from the input. If we “get stuck” i.e. the next character is 𝑎 and there’s no transition leaving our state labeled 𝑎, the computation dies.

Nondeterministic Finite Automata

An NFA: Still has exactly one start state and any number of final states. The NFA accepts 𝑥 if there is some path from a start state to a final state labeled with 𝑥. s 0 s 1 s 2 s 3 1 1 1 0, 0,

Three ways to think about NFAs

“Outside Observer”: is there a path labeled by 𝑥 from the start state, to the final state (if we know the input in advance can we tell the NFA which decisions to make) “Perfect Guesser”: The NFA has input 𝑥, and whenever there is a choice of what to do, it magically guesses a transition that will eventually lead to acceptance (if one exists) “Parallel exploration”: The NFA computation runs all possible computations on 𝑥 in parallel (updating each possible one at every step)

So…magic guessing doesn’t exist

I know. The parallel computation view is realistic. Lets us give simpler descriptions of complicated objects. This notion of “nondeterminism” is also really useful in more advanced CS theory (you’ll see it again in 421 or 431 if not sooner). Source of the P vs. NP problem.

NFA practice

What is the language of this NFA? 111 0 ∪ 1 ∗ 10 10 ∗ s 0 s 1 s 5 s 4 1 1 1 0 s 2 s 3 1 0, 1 Overall 111 0 ∪ 1 ∗ ∪ [ 10 10 ∗ ]

What about those 𝜀-transitions?

s 0 s 1 t 0 t 2 t 1 2 0,1 0, 2 0 0 0 (^1 ) 1 2 2 2 q ε ε

NFA that recognizes “binary strings with a 1 in

the third position from the end”

“Perfect Guesser”: The NFA has input 𝑥, and whenever there is a choice of what to do, it magically guesses a transition that will eventually lead to acceptance (if one exists) Perfect guesser view makes this easier. Design an NFA for the language in the title. Fill out the poll everywhere for Activity Credit! Go to pollev.com/cse311 and login with your UW identity Or text cse311 to 22333

NFA that recognizes “binary strings with a 1 in

the third position from the end”

That’s WAY easier than the DFA… 0, s 3 s 2 s 1 s 0 1 0,1^ 0,

More NFA practice

Write an NFA for: Strings over { 0 , 1 , 2 } that contain at least three 0’s. Strings over 0 , 1 , 2 where the number of 2’s is even and the sum of the digits %3=0.

Regular Languages

Regularity

So NFAs/DFAs what can and can’t they do? Can NFAs do more than DFAs? How do they relate to context-free-grammars? Regular expressions? Fill out the poll everywhere for Activity Credit! Go to pollev.com/cse311 and login with your UW identity Or text cse311 to 22333

Regularity

So NFAs/DFAs what can and can’t they do? Can NFAs do more than DFAs? How do they relate to context-free-grammars? Regular expressions? For every language 𝑳: 𝑳 is the language of a regular expression if and only if 𝑳 is the language of a DFA if and only if 𝑳 is the language of an NFA

Kleene’s Theorem