180 likes | 410 Views
Predicates. Predicate: A Boolean (yes-no) function. Example: . Computable Predicates. A predicate P : X → {0,1} is called computable (or recursive ) if there is a Turing Machine M that decides P : M on input x (in X) accepts if P (x)=1 M on input x (in X) rejects if P (x)=0.
E N D
Predicates • Predicate: A Boolean (yes-no) function. Example:
Computable Predicates • A predicate P : X → {0,1} is called computable (or recursive) if there is a Turing Machine M that decides P: • M on input x (in X) accepts if P(x)=1 • M on input x (in X) rejects if P(x)=0.
P(n) is computable On input any natural number given in unary describe a TM that decides whether this number is zero (i.e the empty string) or not. • High level program: • If the tape is empty accept else reject • Turing Machine: □ → □, R q0 qf
Decidable Languages: Characteristic function • The characteristic function χΑof a set Aisa predicate defined as follows: • A language (set of strings) is decidable (or recursive) if its characteristic function is decidable. Example: The language 1+ over the alphabet Σ={1} is decidable since predicate P is computable.
Recursive (Decidable) Languages • The fact that a language is decidable means that we can use a Turing Machine to decide membership in the language. Example: L = {anbn , n≥0} is a decidable language because there is a Turing Machine that, given any string in Σ* it decides whether the string belongs in L or not.
Yes-No Problems as predicates • Ideally we would like to use Turing Machines (a computer in general) for problem solving. • A yes-no problem is really a predicate: for a given input decide whether the answer is yes or no (1 or 0). • If we are able to create a Turing Machine to solve a problem then this problem can be worked out in a mechanical way (by the use of a computer).
Structures as TM input • In order to be able to construct a TM for a specific predicate (a yes-no problem) we should be first able to express the given structure as a proper input in the TM tape. • Example: If we are given a number then we can simply have as input the number (if efficiency is not an issue we prefer the number in unary, since this format is more convenient for Turing Machines).
Structures as TM input • Example: For input the number 6 … … 1 1 1 1 1 1 In unary … … In binary 1 1 0 … … In decimal 6
Structures as TM input • Example 2: If we are given more than one numbers we might want to express the input as a k-tuple: • Example: (2, 4) x1 x2 xk … … 1 1 … 1 0 1 … 1 0 … 1 … 1 head … … 1 1 0 1 1 1 1
Structures as TM input • Reminder: A graph G(V,E) is a structure containing a set of vertices V and a relation between vertices which is represented by the existence of an edge between them (set E). • Example: A graph with 4 vertices numbered 1,2,3,4 and with the edges (1,2), (1,3), (2,4) 1 2 3 4
Structures as TM input • We can represent a graph in a TM tape as a tuple of the vertices followed by a tuple of the edges: Example: For the graph of the figure we can have as input … … ( 1 2 3 4 ) ( 1 2 1 3 $ ) $ 2 4 head 1 2 3 4
From low level to high level description • As we move on to more complicated problems and structures we might want to avoid presenting all the dirty details for the actual creation of the Turing Machine. • Imagine for example that you want to examine whether a polynomial has integer roots!!! • A high-level description of a Turing Machine is a list of instructions which we are confident enough that a Turing Machine can actually perform with some effort.
Combining Turing Machines • We first create Turing Machines which perform several prespecified tasks (the previously mentioned “instructions”). • We then combine many machines to build larger ones capable of doing more complicated things. • We might also find fruitful to consider some of the equivalent variants of TM (like multitape TM) instead of the one we presented.
Combining Turing Machines • For example, in the creation process of the TM deciding whether a polynomial has integer roots we might want to use the predicate We already argued that this is a computable predicate, thus this task can be performed by a Turing Machine.
Things you can’t instruct a Turing Machine to do • When creating high-level instructions we have to be extra careful about the fact that a Turing Machine can loop for ever, making it not capable of deciding a problem. • For instance, a tempting solution for the previous example would be to try all possible integers n and check whether p(n) = 0. However this procedure will never stop if the answer is no for every n, resulting in a Turing Machine running forever.
High level description of a TM Proper high-level instructions include: • Move the head to the end of the input • Replace every 1 with a 0 which are easily implemented in the low level but also: • If x = y do … • If vertices u, v are connected do … which might need a whole new Turing Machine to take care of them.