cs411 - theory of computation

¡Supera tus tareas y exámenes ahora con Quizwiz!

how does the TM tape work?

-A TM can both write on the tape and read from it. -The read-write head can move both to the left and to the right. -The tape is (right) infinite. -The special states for rejecting and accepting take effect immediately.

what is a 2-ary function more commonly know as?

A 2-ary function is more commonly called a binary function.

what is a Turing Machine (TM)?

A Turing Machine (TM) is a model of computation that was proposed by Alan Turing in 1936. It can do everything that a real (conventional) computer can do. However, a Turing Machine cannot solve all problems, and these unsolvable problems are beyond the theoretical limits of computation

TM - formal defintion

A Turing Machine is a 7-tuple (Q, Σ, Γ, δ, q0, qaccept, qreject) where Q, Σ, Γ are all finite sets and (1) Q is the set of states (2) Σ is the input alphabet not containing the blank symbol (3) Γ is the tape alphabet, where ∈ Γ and Σ ⊆ Γ (4) δ : Q × Γ → Q × Γ × {L, R} is the transition function (5) q0 ∈ Q is the start state (6) qaccept ∈ Q is the accept state (7) qreject ∈ Q is the reject state where qreject ≠ qaccept.

when is a graph a subgraph of a graph?

A graph G is a subgraph of a graph H if the nodes of G are a subset of the nodes of H and the edges of G are the edges of H on the corresponding nodes

what is a tree?

A graph is a tree if it is connected and it contains no simple cycles.

what is a connected graph?

A graph is connected if every two nodes have a path between them.

what is a language?

A language is a set of strings.

what is a path?

A path in a graph is a sequence of nodes connected by edges

what is a cycle?

A path is a cycle if it starts and ends with the same node

what is a predicate?

A predicate is a function whose range is {True, False}.

what is a sequence?

A sequence is a collection of objects written in a certain order.

how are tuples named?

A sequence with k elements is a k-tuple. A 2-tuple is called a pair.

what is a simple cycle?

A simple cycle is one that contains at least 3 nodes and repeats only the first and last nodes.

what is a string?

A string over an alphabet is a finite sequence of symbols from the alphabet. E.g. if Σ = {0, 1} then 010011 is a string over Σ. If w is a string over Γ, the length of w, written |w| is the number of symbols it contains. E.g. |010011| = 6. The string of length zero is written as ε and is called the empty string. If w = w1w2 · · ·wn is a string over Γ, then wrev = wnwn−1 · · ·w2w1 is the string reversed.

how to denote A is a subset of B and what does this mean?

A ⊆ B means A is a subset of B, i.e. every element in A is also in B.

what is a graph?

An (undirected) graph G is a set of points (vertices/nodes) and a set of edges which summarize which points are connected.G is written as a pair (V, E) where V is the set of vertices and E is the set of edges e.g example graph V = {1, 2, 3, 4} and E = {(1, 2),(1, 3),(1, 4),(2, 4),(3, 4)}

what is an alphabet?

An alphabet is non-empty finite set. The members of the alphabet are the symbols. An alphabet is usually written as an upper-case Greek letter. E.g. Γ = {0, 1, 2}.

TM configurations

As the Turing machine runs, it 'computes' and changes occur in its state, tape content, and current head location. A setting of these 3 items is called a configuration. Configurations are often represented in the following way: For a state q and two strings u and v over the tape alphabet Γ we write u q v for the configuration where the current state is q, the current tape contents is uv and the current location of the head is over the first (i.e. leftmost) symbol of v. For example 001q20100 represents the configuration where the tape contents is 0010100, the current state is q2, and the head is located above the third zero of the tape contents

how are the set of possible states of a TM written?

At any given moment in time the Turing machine will be in one of several possible states. The set of possibly states is usually written as Q.

TM M3 part 2

C = {a^i b^j c^k | i × j = k and i, j, k ≥ 1}. M3 = " On input string w: - Scan the input from left to right to determine whether it is a member of a+b+c+ and reject if not. - Return the head to the left-hand end of the tape. - Cross off an a and scan to the right until a b occurs. Shuttle between the b's and c's, crossing off one of each until all b's are gone. If all c's have been crossed off and some b's remain, reject. - Restore the crossed off b's and repeat stage 3 if there is another a to cross off. If all a's have been crossed off, determine whether all the c's have been crossed off. If Yes, accept. Otherwise, reject."

when is a language turing-decidable?

Call a language Turing-decidable or simply decidable if some Turing machine decides it.

when is a language turing recognizable?

Call a language Turing-recognizable if some Turing machine recognizes it.

The ordinary TM that can stay put

Consider a Turing Machine that is equipped with the ability for the head to stay put (S). The transition function of such a variant will have the form δ : Q × Γ → Q × Γ × {L, R, S}. Question: Will this new feature allow the machine to recognize additional languages? Answer: No! We could model this with a Turing machine that moves to the left and then back to the right in two steps. Important point: This example contains the prototype of proofs of equivalence of Turing machine variants, i.e. that we can simulate one by another.

what are directed graphs?

Directed graphs are graphs in which every edge has an orientation/direction e.g Here V = {A, B, C, D} and E = {(A, B),(B, A),(C, B),(B, D)}.

what are finite sequences called?

Finite sequences are often called tuples

what are functions?

Functions can be defined is several (equivalent) ways. A function from a set A to a set B is usually written as f : A → B

what is the cartesian product?

Given sets A and B, the Cartesian product (or cross product of A and B) is the set of all pairs (a, b) where a ∈ A and b ∈ B. This is written as A × B = {(a, b)|a ∈ A, b ∈ B}. e.g. If A = {3,t} and B = {f , 5, x} then A × B = {(3, f ),(3, 5),(3, x),(t, f ),(t, 5),(t, x)}. The Cartesian product of the k sets A1, A2, . . . , An is A1 × A2 × · · · × Ak = {(a1, a2, . . . , ak )|a1 ∈ A1, ..., ak ∈ Ak }. The Cartesian product of a set with itself k times is k ^ A × A × · · · × A= A^k

if A is an alphabet, what does A* mean?

If A is an alphabet, then A∗ is the set of all strings (including the empty one) over A. For example, {0, 1}∗ = {ε, 0, 1, 00, 01, 10, 11, 000, 001, . . .}. note: A+ is the set of all strings w/out the empty string

where does the TM store information?

If the machine needs to store information then it writes this information on the tape.

what is a concatenation of strings?

If x = x1 · · · xn is a string of length n and y = y1 · · · ym is a string of length m then the concatenation of x and y is the string xy = x1x2 · · · xny1y2 · · · ym. The concatenation of a string x with itself several times is written k ^ xx · · · x= x^k

what is the degree of a vertex?

In this graph, the degree of vertex A is 3 because it has 3 edges which are incident with it.

TM M2

Let M2 be the Turing machine that decides A = {0^2^n|n ∈ {0, 1, 2, . . .}}.A is the language which consists of all strings of zeros whose length is a power of 2. A = { 0, 00, 0000, 00000000, . . . }. Description of M2: Given input string w, - Sweep left to right across the tape, crossing off every other 0 (i.e. the 2nd, the 4th, ...). - If in Stage 1 the tape contained a single 0, then accept. - If in Stage 1 the tape contained more than a single 0 and the number of 0s was odd, reject. - Return the head to the left-hand end of the tape. - Go to Stage 1. Check this for the following three cases; (i) w = 0, (ii) w = 000, (iii) w = 0000.

TM M3

Let M3 be the Turing Machine that decides the language C = {a^i b^j c^k | i × j = k and i, j, k ≥ 1}. This is set of all strings of a's followed by b's which are followed by c's such that the number of a's times the number of b's equals the number of c's. For example, aaabbcccccc ∈ C, but abbc ∉ C. If we have a string of a's followed by a string of b's, which is in turn followed by a string of c's, and there is at least one of each symbol, then we say that the string is a member of a^+b^+c^+. Equivalently, this set can be written aa∗bb∗cc∗.

TM1 Part 2

Let's try to describe this behaviour in more detail: The head will zig zag over the tape which contains the input string to be tested for membership in B. On each pass it will match one of the characters on each side of the # symbol. To keep track of which characters have been checked so far, M1 will cross off each symbol as it is examined. If all symbols are crossed off then both sides match and M1 goes into an accept state. If it discovers a mismatch then it enters a reject state.

informal description of m4

M4 = "On input w: - Place a mark on top of the leftmost tape symbol. If that symbol was then accept. If it was # then continue to next stage. Otherwise reject. - Scan right to the next # and place a second mark on top of it. If no # is encountered before only x1 was present so accept. - By zig-zagging, compare the two strings to the right of the marked #'s. If they are equal reject. - Move the rightmost of the two marks to the next # symbol to the right. If no # symbol is encountered before a then move the leftmost mark to the next # to its right and the rightmost mark to the # after that. This time, if no # is available for the rightmost mark, all the strings have been compared, so accept. - Go to stage 3.

M4 notes

M4 illustrates the technique of marking tape symbols, i.e. # becomes ˚#. In actuality, marking # means adding ˚# to its tape alphabet, and then marking # corresponds to writing ˚#. Unmarking ˚# corresponds to writing #. We may want to mark all symbols on a tape, and in this case we simply include marked versions of all symbols in the tape alphabet. The four examples considered show that languages A, B, C and E are decidable. All decidable languages are Turing recognizable, so these languages are Turing-recognizable.

Turing Decidable

Machines which halt on all inputs are called deciders because they always make a decision to accept or reject. A decider that recognizes some language is also said to decide that language. Some examples of decidable languages to follow in the next lecture. Every decidable language is Turing-recognizable. We present examples of languages that are Turing-recognizable but not decidable later in the course

TM1 part3

More succinctly: Zig-zag across tape to corresponding positions on either side of # symbol to check whether these positions contain same symbol. If they do not, or if no # found, then reject. Cross off symbols as they are checked to keep track of which symbols correspond. When all symbols to the left of # have been crossed off, check for any remaining symbols to the right of #. If any symbols remain, then reject, otherwise accept. For example, consider the following inputs on the tape: (Input 1) 0 1 1 0 0 # 0 1 1 0 0 (Input 2) 1 0 1 0 1 # 1 0 0 0

what are two examples of common sets

N = {1, 2, 3, 4, . . .} the set of natural numbers Z = {. . . , −2, −1, 0, 1, 2, . . .} the set of integers.

other ways to think of functions

One way to think of a function is as something that assigns an element of B to every element of A. If f acts on a and 'outputs' b then we write f (a) = b. Another way to think of a function is as a subset of the Cartesian product A × B. If (a, b) ∈ f then this means that f (a) = b. Given f : A → B, the set A is called the domain of f , and B is called the co-domain of f .

Formal description of M2

Q = {q1, q2, q3, q4, q5, qaccept, qreject}. Σ = {0}. Γ = {0, x, }. δ is given in the diagram on the next slide. The start, accept and reject states are q1, qaccept, qreject.

formal description of TM M1

Recall that M1 is the Turing machine for deciding the language B = {w#w | w ∈ {0, 1}∗}. Here M1 = (Q, Σ, Γ, δ, q1, qaccept, qreject) where Q = {q1, . . . , q8, qaccept, qreject}. Σ = {0, 1, #} and Γ = {0, 1, #, x, }. δ is given as a state diagram on the next slide. Note that missing arrows imply going to qreject. The start, accept and reject states are q1, qaccept and qreject, resp

how to write a sequence?

Sequences are usually written as a list within parentheses. e.g. (5, 2, E, W ), (u, d, l,r).

can sets and sequences appear as elements of other sets and sequences?

Sets and sequences may appear as elements of other sets and sequences

TM -Dynamics

Supposing we have a Turing machine M = (Q, Σ, Γ, δ, q0, qaccept, qreject), what exactly happens? Initially M receives as input w = w1w2 . . .wn ∈ Σ∗ on the leftmost n squares of the tape, and the rest of the tape is filled with blank symbols The head starts on the leftmost square and the computation proceeds according to the transition function δ applied to the initial state and current positions, δ(q0,w1). If M ever tries to move its head left off the left-hand end of the tape, then the head stays in the same place for that move. (This overrides the instruction from the transition function to go left.) The computation continues until it enters the accept or reject states,at which point it halts. (If neither occurs then M goes on forever.)

how does a TM work?

The Turing Machine uses an infinite tape as its unlimited memory. It has a tape head that can read and write symbols and move around on the tape. Initially the tape contains only an input string and is otherwise blank ( ).

Turing recognizable

The collection of strings that M accepts is the language recognized by M, and is denoted L(M). When a Turing machine is started on an input there are 3 possible outcomes: accept, reject, or loop. Looping means the machine will not halt. A Turing machine can fail to accept an input by entering the qreject state, or by looping. Sometimes distinguishing a machine that is looping from one that is merely taking a long time is difficult. For this reason we prefer TMs that halt on all inputs, and therefore never loop.

how to denote the empty set?

The empty set is denoted ∅

how to represent the transition function?

The heart of the definition of a TM is the transition function δ:

what is the input alphabet symbol?

The input to the machine is written at the beginning of the tape and its symbols come from an 'input' alphabet Σ that does not contain the blank symbol

what is a power set?

The power set of a set A is the set of all subsets of A. For example, if A = {x, y} then power set(A) = {∅, {x}, {y}, {x, y}}.

TM1 part4

The previous description of the Turing Machine M1 is only a sketch. We can describe TMs in complete detail by giving formal descriptions of the operations in terms of states and head location values. These formal descriptions specify each of the parts of the formal definition of the TM model (introduced next). In actuality we almost never give formal descriptions of TMs because they tend to be very big.

how to write the set of all symbols that may appear on the infinite tape?

The set of symbols that may appear on the infinite tape is Γ, and this must include all symbols from Σ along with the blank symbol

TM configs III

The start configuration of M on input w is the configuration C1 = q0w. In an accepting configuration the state of the configuration is qaccept. In a rejecting configuration the state of the configuration is qreject. Accepting and rejecting configurations are halting configurations and do not yield further configurations. A Turing Machine accepts input w if a sequence of configurations C1, C2, . . . , Ck exists where (1) C1 is the start configuration of M on input w (2) each Ci yields Ci+1 (3) Ck is an accepting configuration

how to denote set membership and non membership?

The symbols ∈ and ∉ denote set membership and non-membership, e.g. 4 ∈ {3, 4, 6} but D ∉ {3, L}.

what is the transition function?

The transition function tells us what to do next based on both the current system 'state' q and the current symbol a beneath the tape-head. If δ(q, a) = (r, b, L) then this means write the symbol b to replace a and change the system state to r, and move the head to the left (L).

Variants of TMs and Robustness

There are many alternative definitions of Turing Machines. These variants include versions with multiple tapes and 1-head, or those with non-determinism. The original model and its (reasonable) variants all have the same power in that they recognize the same class of languages. We now describe some of these variants and the proofs that they are equivalent. This invariance to certain changes in the definition is called robustness.

TM m4

This Turing Machine will solve the element distinctness problem. It is given a list of strings over {0, 1} separated by #'s and its job is to accept if all the strings are different. The language is E = {#x1#x2# · · · #x`| each xi ∈ {0, 1}∗ and xi 6= xj for each i ≠ j}. The machine works by comparing x1 with x2 through x`, then by comparing x2 with x3 through x`, and so on.

TM1 for testing the membership of a language

This first Turing machine is for testing membership of the language: B = {w#w | w ∈ {0, 1}∗}. This is the language of all binary strings where the first part is the same as the second part, but is separated by the # symbol. e.g. 010#010 ∈ B but 010#01 ∉ B. Testing membership is trivial (for a human) for short sequences, but what about long sequences? Strategy: Traverse the sequence in some way so that corresponding positions are compared and mark those which have corresponding values. (This can be done in a multitude of ways.)

how does a TM read the information it has written?

To read the information it has written, the machine can move its head back over it. The machine continues computing until it decides to produce an output. The outputs accept and reject are obtained by entering designated accepting and rejecting states. If it doesn't enter an accepting or a rejecting state, then it will go on forever, never halting

TM configurations II

We will say that a configuration C1 yields a configuration C2 if the Turing machine can legally go from C1 to C2 in a single step. This notion of configuration provides another platform on which to see that behaviour of the system in terms of moving between configurations. Suppose that a, b, c ∈ Γ and u, v ∈ Γ∗. Let qi , qj ∈ Q. Then ua qi bv yields u qj acv ⇐⇒ δ(qi, b) = (qj, c, L) ua qi bv yields uac qj v ⇐⇒ δ(qi, b) = (qj, c, R). Special cases occur when the head is at one of the ends of a configuration. Exercise: Describe what happens in these cases.

what do we call a function where the domain of the function is a cross product is a cross product of k sets

When the domain of a function is a cross product of k sets, then we say the function is a k-ary function. An example of a 2-ary function is addition: + : Z × Z → Z.

what is a set?

a set is a collection of objects. the objects in a set are called its elements/members

how are sets written?

sets are written with braces e.g {5,10,15} is a set containing 3 elements e.g {apple,banana,mango,1} is a set containing 4 elements


Conjuntos de estudio relacionados

med surg prepU ch 44 Assessment and Management of Patients with Biliary Disorders

View Set

MRU 8.4: Price Ceilings: Deadweight Loss

View Set

Chapter 13 Spinal Cord, Spinal Cord, Neuron, Spinal Cord, Spinal Nerves & Reflex Physiology, Chapter 12 Spinal cord and spinal nerves

View Set

Chapter 8 Neurons: Cellular and Network Properties

View Set