1 / 78

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13 Mälardalen University 2005. Rices sats.

mary-beard
Download Presentation

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13 Mälardalen University 2005

  2. Rices sats Om är en mängd av Turing-accepterbara språk som innehåller något men inte alla sådana språk, så kan ingen TM avgöra för ett godtyckligt Turing-accepterbart språk L om L tillhör  eller ej. (Varje icke-trivial egenskap avTuring-accepterbara språk äroavgörbar.)

  3. Exempel Avgörbart? Motivera! a) ”Är L(M) oändlig?” Givet att M är en godtycklig DFA. b) ”Är L(M) oändlig?” Givet att M är en godtycklig TM. Svar a) AVGÖRBART! Man behöver bara kontrollera om M innehåkker någon slinga på väg till acceptans, vilket kan göras i ändligt många steg. Formellt: Se kursboken uppgift 7.2. b) OAVGÖRBART! Följer av Rices sats, om man väljer  som mängden av alla oändliga Turingaccepterbara språk, eftersom denna mängd är icketrivial.

  4. ContentRecursionPrimitivt rekursiva funktionerRekursiva funktionerFör varje TM finns det en rekursiv funktionFör varje rekursiv funktion finns det en TM

  5. Recursion In computer programming, recursion is related to performing computations in a loop.

  6. Recursion in Problem Modelling Reducing the complexity by • breaking up computational sequences into its simplest forms. • synthesizing components into more complex objects by replicating simple component sequences over and over again.

  7. "A reduction is a way of converting one problem into another problem in such a way that a solution to the second problem can be used to solve the first problem." Michael Sipser, Introduction to the Theory of Computation

  8. Recursion can be seen as concept of well-defined self-reference. We use recursion frequently. Consider, for example, the following hypothetical “definition of a Jew”. I found it on web, as a joke. “Somebody is a Jew if she is Abraham's wife Sarah, or if his or her mother is a Jew.” (My digression: I wonder what about Abraham?)

  9. So if I want to know if I am a Jew, I look at this definition. I'm not Sarah, so I need to know whether my mother is a Jew. How do I know about my mother? I look at the definition again. She isn't Sarah either, so I ask about her mother. I keep going back through the generations - recursively.

  10. Self-referential definitions can be dangerous if we're not careful to avoid circularity. The definition ''A rose is a rose'‘* just doesn't cut it. This is why our definition of recursion includes the word well-defined. *Know Gertrude Stein? '' A rose is a rose is a rose''

  11. Yet another recursive definition: an immigrant… We can write pseudocode to determine whether somebody is an immigrant: FUNCTION isAnImmigrant(person): IF person immigrated herself, THEN: return true ELSE: return isAnImmigrant(person's parent) END IF This is a recursive function, since it uses itself to compute its own value. [According to some authors (Rudbeckius) Adam and Eve were Swedish.]

  12. Functions From math classes, we have seen many ways of defining and combining numerical functions. • Inverse f-1 • Composition f ◦g • Derivatives f´(x), f´´(x), … • Iteration f1(x), f2(x), f3(x), f4(x), … • …

  13. Functions Look at what happens when we use only some of these. • How can we define standard interesting functions? • How do these relate to e.g. TM computations? We have seen TMs as functions. They are cumbersome! As alternative, look at a more intuitive definition of functions.

  14. Notation For brevity, limit to functions on natural numbers N= {0,1,2,…} Notation will also use n-tuples of numbers (m1, …, mn)

  15. Natural Numbers Start with standard recursive definition of natural numbers (remember Peano?): • A natural number is either • 0, or • successor(n), where n is a natural number.

  16. What is a recurrence? A recurrence is a well-defined mathematical function written in terms of itself. It is a mathematical function defined recursively.

  17. Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,... The first two numbers of the sequence are both 1, while each succeeding number is the sum of the two numbers before it. (We arrived at 55 as the tenth number, since it is the sum of 21 and 34, the eighth and ninth numbers.)

  18. F(0) = 1 F(1) = 1 (base cases) F(n) = F(n - 1) + F(n - 2) F is called a recurrence, since it is defined in terms of itself evaluated at other values.

  19. Recursion & Recurrence A recursive process is one in which objects are defined in terms of other objects of the same type. Using some sort of recurrence relation*, the entire class of objects can then be built up from a few initial values and a small number of rules. (*Recurrence is a mathematical function defined recursively.)

  20. Computable Function Any computable function can be programmed using while-loops (i.e., "while something is true, do something else"). For-loops (which have a fixed iteration limit) are a special case of while-loops. Computable functions could also be coded using a combination of for- and while-loops.

  21. Primitive Recursive Function Total Function A function which can be implemented using only for-loops. A function defined for all possible input values.

  22. An example function Domain Range

  23. We need a set of basic functions. We need a way to define functions.

  24. Basic Primitive Recursive Functions Zero function: Successor function: Projection functions:

  25. Building functions Composition

  26. Composition, Generally • Given • g1 : Nk N • . • . • . • gm : Nk N • f : Nm N • h(n1,…,nk) = f(g1(n1,…,nk), …, gm(n1,…,nk)) • h = f ◦(g1,…,gm) Alternate notation. • Create h : Nk N

  27. Primitive Recursion “Template” N.B. For primitive recursive functions recursionin only oneargument.

  28. Any function built from the basic primitive recursive functions is called Primitive Recursive Function.

  29. Basic Primitive Zero function (a constant function) Example

  30. Basic Primitive Identity function Recursive definition

  31. Basic Primitive Successor function

  32. Using Basic Primitive Zero function and a Successor function we can construct Constant functions etc..

  33. Example

  34. A Primitive Recursive Function (projection) (successor function)

  35. Example

  36. Example

  37. Basic Primitive Predecessor function

  38. Predecessor Predecessor is a primitive recursive function with no direct self-reference.

  39. Subtraction

  40. Example

  41. A Primitive Recursive Function

  42. Example

  43. A Primitive Recursive Function

  44. Example

  45. Primitive Recursion: Logic A predicate (Boolean function) with output in the set {0,1} which is interpreted as {yes, no}, can be used to define standard functions. • Logical connectives  , ,, , … • Numeric comparisons =, < ,, … • Bounded existential quantification in, f(i) • Bounded universal quantification in, f(i) • Bounded minimization min i in, f(i) where result = 0 if f(i) never true within bounds.

  46. Recursive Predicates and

  47. More Recursive Predicates

  48. More Recursive Predicates...

  49. Example Recursive predicates can combine into powerful functions. What does this compute? ???(n) = in,jn, ((i=1  j=n)  (j=1  i=n)  ijn) Tests primality.

  50. ExampleAnother version of prime(n) prime(n) = n2  i<n, (i1  mod(n,i) > 0) mod(m,n) = if n>0 then (min i im, div(m,n)n+i=m) else 0 div(m,n) = if n>0 then (min i im, (i+1)n>m) else 0

More Related