0% found this document useful (0 votes)
32 views17 pages

TM Daami

This document discusses the following topics: 1) Regular languages and their properties including regular expressions, finite automata, and regular grammars. 2) Context-free languages and their properties including context-free grammars, pushdown automata, and the pumping lemma for context-free languages. 3) Turing machines as the most powerful computational model that can recognize any computably enumerable language. Turing machines have an infinite tape, read/write head, and set of states.

Uploaded by

basantadc12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views17 pages

TM Daami

This document discusses the following topics: 1) Regular languages and their properties including regular expressions, finite automata, and regular grammars. 2) Context-free languages and their properties including context-free grammars, pushdown automata, and the pumping lemma for context-free languages. 3) Turing machines as the most powerful computational model that can recognize any computably enumerable language. Turing machines have an infinite tape, read/write head, and set of states.

Uploaded by

basantadc12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Review

• Languages and Grammars


– Alphabets, strings, languages
• Regular Languages
– Deterministic Finite and Nondeterministic Automata
– Equivalence of NFA and DFA and Minimizing a DFA
CS 301 - Lecture 19 –

Regular Expressions
Regular Grammars

Turing Machines –

Properties of Regular Languages
Languages that are not regular and the pumping lemma
• Context Free Languages
– Context Free Grammars
Fall 2008 –

Derivations: leftmost, rightmost and derivation trees
Parsing and ambiguity
– Simplifications and Normal Forms
– Nondeterministic Pushdown Automata
– Pushdown Automata and Context Free Grammars
– Deterministic Pushdown Automata
– Pumping Lemma for context free grammars
– Properties of Context Free Grammars
• Turing Machines

The Language Hierarchy


a nb n c n ? ww ?
Turing Machines Context-Free Languages
n n R
a b ww
Regular Languages
a* a *b *

1
Languages accepted by
Tape A Turing Machine
Turing Machines ...... ......
n n n
a b c ww
Read-Write head
Context-Free Languages
n n Control Unit
a b R
ww
Regular Languages
a* a *b *

...... ......
The Tape
No boundaries -- infinite length
...... ...... Read-Write head

Read-Write head The head at each time step:

1. Reads a symbol
2. Writes a symbol
The head moves Left or Right 3. Moves Left or Right

2
Example:
Time 1
Time 0
...... a b k c ......
...... a b a c ......

Time 1 Time 2
...... ...... ...... a f k c ......
a b k c

1. Reads a 1. Reads b
2. Writes k 2. Writes f
3. Moves Left 3. Moves Right

The Input String


Input string Blank symbol Input string Blank symbol

...... ◊ ◊ a b a c ◊ ◊ ◊ ...... ...... ◊ ◊ a b a c ◊ ◊ ◊ ......

head head

Head starts at the leftmost position


Remark: the input string is never empty
of the input string

3
Example:
Time 1
States & Transitions
Read Write ...... ◊ ◊ a b a c ......
Move Left ◊ ◊ ◊

q1
q1 a → b, L q2 current state

Move Right

q1 a → b, R q2
q1 a → b, R q2

Example:
Time 1 Time 1
...... ◊ ◊ a b a c ◊ ◊ ◊ ...... ...... ◊ ◊ a b a c ◊ ◊ ◊ ......

q1 q1

Time 2 Time 2
...... ◊ ◊ a b b c ◊ ◊ ◊ ...... ...... ◊ ◊ a b b c ◊ ◊ ◊ ......

q2 q2

q1 a → b, R q2 q1 a → b, L q2

4
Example:
Time 1 Determinism
...... ◊ ◊ a b a c ◊ ◊ ◊ ...... Turing Machines are deterministic

q1 Allowed Not Allowed


a → b, R q2 a → b, R q2
Time 2
...... ◊ ◊ a b b c g ◊ ◊ ...... q1
q1
q3 a → d, L q3
q2 b → d, L

q1 ◊ → g, R q2 No lambda transitions allowed

Partial Transition Function


Example: Halting
...... ◊ ◊ a b a c ◊ ◊ ◊ ......
The machine halts if there are
q1 no possible transitions to follow

a → b, R q2 Allowed:

q1 No transition
for input symbol c
b → d, L q3

5
Example:
Final States
q1 q2 Allowed
...... ◊ ◊ a b a c ◊ ◊ ◊ ......

q1
q1 q2 Not Allowed
a → b, R q2
No possible transition
q1 • Final states have no outgoing transitions
HALT!!!
b → d, L q3
• In a final state the machine halts

Acceptance Turing Machine Example


If machine halts A Turing machine that accepts the language:
Accept Input
in a final state aa *

If machine halts a → a, R
in a non-final state
Reject Input or
◊ → ◊, L
If machine enters q0 q1
an infinite loop

6
Time 0 ◊ ◊ a a a ◊ ◊ Time 1 ◊ ◊ a a a ◊ ◊

q0 q0

a → a, R a → a, R

◊ → ◊, L ◊ → ◊, L
q0 q1 q0 q1

Time 2 ◊ ◊ a a a ◊ ◊ Time 3 ◊ ◊ a a a ◊ ◊

q0 q0

a → a, R a → a, R

◊ → ◊, L ◊ → ◊, L
q0 q1 q0 q1

7
Rejection Example
Time 4 ◊ ◊ a a a ◊ ◊

q1 Time 0 ◊ ◊ a b a ◊ ◊

q0

a → a, R Halt & Accept


a → a, R
◊ → ◊, L
q0 q1
◊ → ◊, L
q0 q1

Infinite Loop Example


Time 1 ◊ ◊ a b a ◊ ◊

q0
b → b, L
No possible Transition a → a, R
a → a, R Halt & Reject

◊ → ◊, L
q0 q1
◊ → ◊, L
q0 q1

8
Time 0 ◊ ◊ a b a ◊ ◊ Time 1 ◊ ◊ a b a ◊ ◊

q0 q0

b → b, L b → b, L
a → a, R a → a, R

◊ → ◊, L ◊ → ◊, L
q0 q1 q0 q1

Time 2 ◊ ◊ a b a ◊ ◊ Time 2 ◊ ◊ a b a ◊ ◊
q0
q0
Time 3 ◊ ◊ a b a ◊ ◊
Infinite loop

q0
b → b, L
a → a, R Time 4 ◊ ◊ a b a ◊ ◊
q0
◊ → ◊, L
q0 q1 ◊ ◊ a b a ◊ ◊
Time 5
q0

9
Because of the infinite loop:
Turing Machine Example
Turing machine for the language {a nb n }
•The final state cannot be reached

•The machine never halts q4 y → y, R y → y, L


y → y, R a → a, R a → a, L
•The input is not accepted
◊ → ◊, L

y → y, R a → x, R b → y, L
q3 q0 q1 q2
x → x, R

Time 0 ◊ a a b b ◊ ◊ Time 1 ◊ x a b b ◊ ◊

q0 q1

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

10
Time 2 ◊ x a b b ◊ ◊ Time 3 ◊ x a y b ◊ ◊

q1 q2

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

Time 4 ◊ x a y b ◊ ◊ Time 5 ◊ x a y b ◊ ◊

q2 q0

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

11
Time 6 ◊ x x y b ◊ ◊ Time 7 ◊ x x y b ◊ ◊

q1 q1

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

Time 8 ◊ x x y y ◊ ◊ Time 9 ◊ x x y y ◊ ◊

q2 q2

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

12
Time 10 ◊ x x y y ◊ ◊ Time 11 ◊ x x y y ◊ ◊

q0 q3

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

Time 12 ◊ x x y y ◊ ◊ Time 13 ◊ x x y y ◊ ◊

q3 q4
Halt & Accept

q4 y → y, R y → y, L q4 y → y, R y → y, L
y → y, R a → a, R a → a, L y → y, R a → a, R a → a, L
◊ → ◊, L ◊ → ◊, L

y → y, R a → x, R b → y, L y → y, R a → x, R b → y, L
q3 q0 q1 q2 q3 q0 q1 q2
x → x, R x → x, R

13
Observation:

If we modify the Formal Definitions


machine for the language {a nb n } for
Turing Machines
we can easily construct
a machine for the language {a nb n c n }

Transition Function Transition Function

q1 a → b, R q2 q1 c → d, L q2

δ (q1, a ) = (q2 , b, R ) δ (q1, c) = (q2 , d , L)

14
Turing Machine:

Input Tape Configuration


alphabet alphabet ◊ ◊ c a b a ◊ ◊
States
q1
M = (Q, Σ, Γ, δ , q0 , ◊, F )

Transition Final Instantaneous description: ca q1 ba


function states
Initial blank
state

Time 4 Time 5 Time 4 Time 5


◊ x a y b ◊ ◊ ◊ x a y b ◊ ◊ ◊ x a y b ◊ ◊ ◊ x a y b ◊ ◊

q2 q0 q2 q0

Time 6 Time 7
◊ x x y b ◊ ◊ ◊ x x y b ◊ ◊
A Move: q2 xayb  x q0 ayb
q1 q1

q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b

15
Initial configuration: q0 w
q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b

Input string

w
Equivalent notation: q2 xayb  xxy q1 b
◊ a a b b ◊ ◊

q0

The Accepted Language Standard Turing Machine


For any Turing Machine M The machine we described is the standard:


• Deterministic
L( M ) = {w : q0 w  x1 q f x2 }
• Infinite tape in both directions

Initial state Final state •Tape is the input/output file

16
What’s Next
• Read
– Linz Chapter 1,2.1, 2.2, 2.3, (skip 2.4), 3, 4, 5, 6.1, 6.2, (skip 6.3), 7.1, 7.2, 7.3, (skip
7.4), 8, 9
– JFLAP Chapter 1, 2.1, (skip 2.2), 3, 4, 5, 6, 7, (skip 8), 9
• Next Lecture Topics From 9.2 and 9.3
– Complex Tasks and Turing’s Thesis
• Quiz 3 in Recitation on Wednesday 11/12
– Covers Linz 7.1, 7.2, 7.3, (skip 7.4), 8, and JFLAP 5,6,7
– Closed book, but you may bring one sheet of 8.5 x 11 inch paper with any notes you
like.
– Quiz will take the full hour
• Homework
– Homework Due Thursday

17

You might also like