0% found this document useful (0 votes)
21 views71 pages

CHP 6 A

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)
21 views71 pages

CHP 6 A

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/ 71

 Original model and its reasonable varaints all

have the same power in recognize the same


language.

Definition of equivalence of Two automata:


Two automata is equivalent if they accept
same language.
Consider 2 classes of automata C1 and C2. if
every automaton M1 in c1 , there is M2 in C2
such thar L(M2)=L(M1) and vice versa.
 A standard technique for showing the equivance of
machine classes.
 Let M1 be an automaton. We can say another
automata M2 can stimulate the computation of M1 if
M2 can mimic the computation in following manner:
a) There are configurations in M2 that are uniquely
associated with configurations in M1.
b) If we know the computation carried out by M2 we
can determine what computation M1 would have
done, given the corresponding starting
configuration
 (c) The simulation of a single move of M1 may
involve several moves of M2.
 (d) M2 can simulate every computation of M1; and this
implies m1 and m2 accept same language .hence, two
classes are equivalent.
Simulate the machine of one class
with a machine of the other class
First Class Second Class
Original Machine Simulation Machine
M2
M1 M1

simulates M1 4
Configurations in the Original Machine M1
have corresponding configurations
in the Simulation Machine
M2

M1
Original Machine: d0  d1    d n

  
Simulation Machine: d 0  d1    d n
M2 5
Accepting Configuration

Original Machine: df

Simulation Machine: d f

the Simulation Machine


and the Original Machine
accept the same strings

L( M1 )  L( M 2 )
6
Turing machines with: • Stay-Option
• Semi-Infinite Tape
•Multidimensional
•Multitape
• Nondeterministic

 The various models of Turing machines are


considered equivalent with respect to their
ability to do things.

7
 This TM provide a extra option that read-
write head stay in place after rewriting ther
cell content .this will not exgend the power of
automata.
The head can stay in the same position
 aababbcac a

Left, Right, Stay


 S denotes no movement of read write head.
L,R,S: possible head moves
8
Example: Time 1
 aababbcac a
q1
Time 2
 b ab abb c ac a
q2

q1 a  b, S q2
9
Theorem: Stay-Option machines
have the same power with
Standard Turing machines

Proof: 1. Stay-Option Machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Stay-Option machines

10
1. Stay-Option Machines
simulate Standard Turing machines
 Since a TM with satay option is clearly an
extension of standard model, so any standard
TM can be stimulated by one with Stay
option.

Trivial: any standard Turing machine


is also a Stay-Option machine

11
2. Standard Turing machines
simulate Stay-Option machines
 Consider let M1be a TM with stay option to
be stimulated by standard TM M2.
 For each move of M1,the simulating machine
M2 does the following.
 If the move of M1 does not involve the stay
option, the simulating machine M2 performs
one move, essentially identical to the move to
be simulated.

12
 If S is involved in the move M1, then M2 will
make two moves:
 The first rewrite the symbol and moves the
read- write head right.t
 The second moves the read –write head left,
leaving the tape content unaltered.

 It is reasonably obvious that every


computation of M1 has corresponding
simulation of M2. so that M2 simulates M1.
Stay-Option Machine

a  b, S
q1 q2

Simulation in Standard Machine

a  b, L x  x, R
q1 q2

For every possible tape symbol x


14
For other transitions nothing changes
Stay-Option Machine

a  b, L
q1 q2

Simulation in Standard Machine

a  b, L
q1 q2

Similar for Right moves


15
example of simulation

Stay-Option Machine:
q1 a  b, S q2 aaba  baba 
1 2
q1 q2

Simulation in Standard Machine:


aaba  baba  baba 
1 2 3
q1 q2 q2

END OF PROOF
16
 Multiple tracks
 Sometimes TM wants to mark the symbol without
destroying them. In such cases, it is advisable to have
multiple tracks on the tape.
 There is only one tape head, here the single input tape
is divided into multiple tracks then the input tape as
follows

The input tape has multiple tracks on the first tracks


.the input which is surrounded by # and $

prepared by :M.Jenifer 17
Multiple Track Tape
A useful trick to perform more
complicated simulations

One Tape
  a b a b  track 1
  b a c d  track 2

One head
One symbol ( a, b)
18
  a b a b  track 1
  b a c d  track 2

q1

  a c a b  track 1
  b d c d  track 2

q2

(b, a)  (c, d ), L
q1 q2
19
Multi-tape Turing Machine
A multi-tape Turing Machine is like an ordinary
TM
There are k tapes
 Each tape has its own independent
read/write head.
The only fundamental difference from the
ordinary TM is δ– the state transition function.

 : Q   k  Q   k  {L, R}k , k : the number of tapes.


 (qi , a1 ,..., ak )  (q j , b1 ,..., bk , L, R, L,..., L).

20
 Read as:
 If the TM is in state qi and

 the heads are reading symbols a1 through ak,

 Then the machine goes to state qj, and

 the heads write symbols b1 through bk, and


 Move in the specified directions
.
Example:if k=2 then
δ (q0, a, e) := (q1,x,y, L, R)
This rule is applicable only if the machine is in state q0
and the first read-write head sees an a and the second an
e. The symbol on the first tape will then be replaced with
an x and its read write head will move to the left. At the
same time, the symbol on the second tape is rewritten as
y and the read write head moves right.the control unit
then changes its stae to q1.
21
Control unit
(state machine)

Tape 1 Tape 2
 a b c   e f g 
Input string

22
Tape 1 Time 1 Tape 2
 a b c   e f g 
q1 q1

Tape 1 Time 2 Tape 2


 a g c   e d g 
q2 q2

(b, f )  ( g , d ), L, R
q1 q2
23
Theorem: Multi-tape machines
have the same power with
Standard Turing machines

Proof: 1. Multi-tape machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Multi-tape machines

24
1. Multi-tape machines simulate
Standard Turing Machines:
 For proof the above, we can always elect to
run a multi tape TM with only one of its tape
.so it will prove Multi tape TM can stimulate
the standard TM.

Trivial: Use just one tape

25
2. Standard Turing machines simulate
Multi-tape machines:

Standard machine:
• Uses a multi-track tape to simulate
the multiple tapes

• A tape of the Multi-tape machine


corresponds to a pair of tracks

26
Multi-tape Machine-M
Tape 1 Tape 2
 a b c   e f g h 

Standard machine with four track tape-M1


a b c Tape 1
0 1 0 head position
e f g h Tape 2
0 0 1 0 head position
27
Reference point
a b c Tape 1
#
# 0 1 0 head position
# e f g h Tape 2
# 0 0 1 0 head position

Repeat for each state transition:


1. Return to reference point
2. Find current symbol in Tape 1
3. Find current symbol in Tape 2
4. Make transition.
END OF PROOF 28
Nondeterministic Turing Machines

…are just like standard TMs, except:

1. The machine may proceed according to several


possibilities.
 : Q  Γ → Pow(Q  Γ  {L,R})

2. The machine accepts a string if there exists a path


from start configuration to an accepting configuration.

2
9
q2 Choice 1
a  b, L

q1

a  c, R q3 Choice 2

Allows Non Deterministic Choices


30
Time 0

 a b c 
Time 1
q1
Choice 1
q2  b b c 
a  b, L
q2
q1
Choice 2
a  c, R q3  c b c 
q3 31
A computation of a Nondeterministic TM
is a tree, where each branch of the tree
looks like a computation of an ordinary
TM.

If a single branch reaches the accepting state,


the Nondeterministic TM accepts, even if other
branches reach the rejecting state.

32
Deterministic Non-Deterministic
Computation Computation

reject

accept or reject accept


The machine accepts a string if there exists a
path from start configuration to an accepting
configuration.
Input string w is accepted if
there is a computation:

q0 w  x q f y

Initial configuration Final Configuration

Any accept state

There is a computation:

34
Theorem: Nondeterministic machines
have the same power with
Standard Turing machines

Proof: 1. Nondeterministic machines


simulate Standard Turing machines

2. Standard Turing machines


simulate Nondeterministic machines

35
1. Nondeterministic Machines simulate
Standard (deterministic) Turing Machines

Trivial: every deterministic machine


is also nondeterministic

36
2. Standard (deterministic) Turing machines
simulate Nondeterministic machines:
Proof Idea:
• Show that we can simulate an NTM N with DTM D.

Note: in this simulation D tries all possible branches of N’s


computation. If D ever finds the accept state on one of these
branches then it accepts. Otherwise D simulation will not
terminate.
 N’s computation on an input w is a tree, N(w).
 Each branch of N(w) represents one of the branches of the non
determinism.
 Each node of N(w) is a configuration of N.
 The root of N(w) is the start configuration.

Note: D searches N(w) for an accepting configuration.

37
Design D to explore the tree by using a breadth-first search.

This strategy explores all branches at the same depth before going to
explore any branch at the next depth. Hence, this method guarantees
that D will visit every node of N(w) until it encounters an accepting
configuration.
D has three tapes,

1. Tape 1 (called input tape) always contains the input (and the code
of N) and is never altered.
2. Tape 2 (called simulation tape) maintains a copy of the N’s tape
on some branch of its nondeterministic Computation
3. Tape 3 (called address tape) keeps track of D’s location in N’s
nondeterministic computation tree.

38
input tape
(never altered )
01 ............
D
xx#01x B ...... simulation tape
121 ...... address tape
0
number of states

......
01 bq

10
... q bb 11 ... b
1

non-deterministic
1 computation
2 3
111

1 1 2 1

1312
1 2 1 1 2

1 1 1 2

40
Address Tape
 Every node in N(w) can have at most b
children, where b is the size of the largest set
of possible choices given by N’s transition
function.

 Hence, to every node we assign an address


that is a string in the alphabet ∑ b = {1,2,...,b}.

 Example: we assign the address 231 to the


node reached by starting at the root, going to
its second child and then going to that node’s
third child and then going to that node’s first
child. 41
 Each symbol in a node address tells us which
choice to make next when simulating a step in
one branch in N’s nondeterministic
computation.
 Sometimes a symbol may not correspond to
any choice if too few choices are available for a
configuration. In that case the address is
invalid and doesn’t correspond to any node.
 Tape 3 contains a string over ∑b which
represents a branch of N’s computation from
the root to the node addressed by that string,
unless the address is invalid.
 The empty string Ɛ is the address of the root.

42
The Description of D
1. Initially tape 1 contains w and tape 2 and 3 are
empty.
2. Copy tape 1 over tape 2
3. Use tape 2 to simulate N with input w on one
branch of its nondeterministic computation.
 Before each step of N, consult the next symbol on tape 3
determine which choice to make among those allowed by
N’s transition function.
 If no more symbols remain on tape 3 or if this
nondeterministic choice is invalid, abort this branch by
going to stage 4.
 If a rejecting configuration is reached go to stage 4; if an
accepting configuration is encountered, accept the input.
4. Replace the string on tape 3 with the next string as
if it is a counter and go to stage 2.

43
 A TM is a special purpose computer. Once δ
is defined, the machine is restricted to
carrying out one particular type of
computation.
 Digital computers are general purposes
computer that can be programmed to do
different jobs at different times.
 Consequently, TM cannot be considered
equivalent to general purpose computer.
 This objective can overcome by designing a
reprogrammable TM –Universal TM.

44
 A Universal TM Mu is an automaton that given as
input the description of any TM M and a string w,
can simulate the computation of M on w.

 From this the concepts of universal Turing


machine came up. The universal language can be
represented by 𝐿𝑢 = L(U) where U is the universal
Turing machine. In fact U is a binary string. This
binary string represents various codes of many
Turing machines. Thus the universal Turing
machine is a Turing machine which accepts many
Turing machines.
A limitation of Turing Machines:
Turing Machines are “hardwired”

they execute
only one program
Question: Can we build a programmable TM that accepts
as input a (M: Turing machine, w: input string) pair and
outputs whatever M would output when started up on w?

Answer: Yes, it’s called the Universal Turing Machine.

Attributes:
• Reprogrammable machine
• Simulates any other Turing Machine
46
Universal Turing Machine
simulates any Turing Machine M

Input of Universal Turing Machine:

Description of transitions of M
Input string of M

47
Tape 1 contents of Universal Turing Machine:

binary encoding
of the simulated machine
M

Tape 1
1 0 1 0 11 0 11 0 10011 0 1 10 111 0 111 0 1100 

48
 To construct Mu, we first chose a standard
way of describing TM.
 Assume Q={q1,q2,q3….q n}
 With q1 the initial state, q2 is the single final
state and Γ = {a1,a2,..an} Where a1
represents blank.
 Then select an encoding q1 is represented by
1, q2 is represented by 11 and so on. The
symbol 0 is used as separator.
 With these, we can define completely
transition of input TM.
 This represent any TM with a finite encoding
as a string(0+1)* and that given any encoding
of M . We can decode it uniquely
 Some string will not represent any TM such as ( string
00011), from this we easily spot they are no concern.
 Universal Language:
 The universal language 𝐿𝑢 is set of binary strings
which can be modeled by a Turing machine. The
universal language can be represented by a pair (M,
w) where M is a TM that accepts this languages and w
is a binary string in (0 + 1)* such that w belongs to
L(M). thus we can say that any binary string belongs
to a universal language.
 It has a structure of multi tape machine


Tape 1
Three tapes

Description of M

Universal
Tape 2
Turing
Machine
Tape Contents of M

Tape 3

State of M 51
 The universal Turing machine U accepts the
TM M
 The transitions of M are stored initially on
first tape along with the string w
 On the second tape the simulated tape of M is
placed. Here the tape symbol 𝑋𝑖 of M will be
represented by 0𝑖 and tape symbols are
separated by single 1’s
 On the third tape various states of machine M
are stored. the state 𝑞𝑖 is represented by i 0’s
 Mu looks the content of tapes 2 and 3 to
determine the configuration of M.it then
consults tape 1 to see what M would do in
this configuration.Finally tapes 2 and 3 will
be modified to reflect the result of move.
 This implementation of UTM will be done by a
programming language that describe
transistion of TM. So UTM is a general
purpose computer.
Tape 1

Description of M

We describe Turing machine M


as a string of symbols:

We encode M as a string of symbols

54
Alphabet Encoding

Symbols: a b c d 

Encoding: 1 11 111 1111

55
State Encoding

States: q1 q2 q3 q4 

Encoding: 1 11 111 1111

Head Move Encoding

Move: L R

Encoding: 1 11
56
Transition Encoding

Transition:  (q1, a)  (q2 , b, L)

Encoding: 1 0 1 0 11 0 11 0 1

separator

57
Machine Encoding

Transitions:
 (q1, a)  (q2 , b, L)  (q2 , b)  (q3 , c, R)

Encoding:
1 0 1 0 11 0 11 0 1 00 11 0 110 111 0 111 0 11
separator
58
A Turing Machine is described
with a binary string of 0’s and 1’s

Therefore:

The set of Turing machines forms a language:

each string of the language is


the binary encoding of a Turing Machine

59
Language of Turing Machines

L = { 010100101, (Turing Machine 1)

00100100101111, (Turing Machine 2)

111010011110010101,
……
…… }

60
Countable set:

Any finite set


or
Any Countably infinite set:
There is a one to one correspondence
between
elements of the set
and
Natural numbers

61
Example: The set of even integers
is countable

Even integers: 0, 2, 4, 6, 

Correspondence:

Positive integers: 1, 2, 3, 4, 

2n corresponds to n 1
62
Definition

Let S be a set of strings

An enumeration procedure for S is a


Turing Machine that generates
all strings of S one by one

and

Each string is generated in finite time


63
strings s1, s2 , s3 ,  S

Enumeration output
Machine for S
s1, s2 , s3 , 
(on tape)

Finite time: t1, t2 , t3 ,

64
Example:

The set of all strings {a, b, c}
is countable

Proof:
We will describe an enumeration procedure

65
 Consider the order in which the symbols will
appear in a dictionary. However this order will
not suite without modification.
 In a dictionary,all words beginning with a are
listed before the string b. but when there
areinfinite words of a, we will never reach b..
 Instead we use a different order in which we
take the length of the string as the first criteria
followed by an alphabet ordering of all equal
length strings.
Naive procedure:
Produce the strings in lexicographic order:
a
aa
aaa
aaaa
......
Doesn’t work:
strings starting with b
will never be produced
67
Better procedure: Proper Order

1. Produce all strings of length 1

2. Produce all strings of length 2

3. Produce all strings of length 3

4. Produce all strings of length 4

..........

68
a
b length 1
c
aa
ab
ac
Produce strings in ba
Proper Order: bb length 2
bc
ca
cb
cc
aaa
aab length 3
aac
...... 69
Theorem: The set of all Turing Machines
is countable

Proof: Any Turing Machine can be encoded


with a binary string of 0’s and 1’s

Find an enumeration procedure


for the set of Turing Machine strings

70
Enumeration Procedure:

Repeat
1. Generate the next binary string
of 0’s and 1’s in proper order

2. Check if the string describes a


Turing Machine
if YES: print string on output tape
if NO: ignore string

71

You might also like