1 / 13

Computability

Computability. Five lectures. Slides available from my web page http://www.dcs.gla.ac.uk/~muffy/teaching.html There is some formality, but it is gentle, have courage. The lectures that will change your life . Computability. Input x. Black box. output f(x). What is a computer?

aregina
Download Presentation

Computability

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. Computability Five lectures. Slides available from my web page http://www.dcs.gla.ac.uk/~muffy/teaching.html There is some formality, but it is gentle, have courage. The lectures that will change your life .

  2. Computability Input x Black box output f(x) What is a computer? What can the black box do? Which functions can be expressed as programs? Is there any limit to the kinds of programs you can write (except for your own proficiency at programming)? Operational approach Mathematical approach Alan Turing 1936 Alonzo Church 1936 Turing computable Effectively computable Church-Turing thesis Every computer algorithm can be implemented as a TM

  3. Some fundamentals What is a language? • A set of (finite) strings/words over an alphabet. • Most interesting languages are infinite, i.e. they consist of an infinite number of finite words. e.g. L = {a, aa, aaa, aaaa, aaaaa, …} How do you represent a language? • What is a finite representation of an infinite language? (a grammar) (an algorithm which determines whether a word is in the language) Does there exist a finite representation for every language? • (No) What can be said about the languages for which there is a finite representation? • That’s the topic of these lectures!

  4. More fundamentals What is an algorithm/procedure/mc? • A procedure is a finite sequence of instructions that can be mechanically executed (on a mc). • An algorithm is a procedure that terminates. Example procedures: determine whether or not an integer is a prime determine whether or not there is a perfect number greater than i (Perfect no is a no. which is equal to the sum of all divisors, e.g. 6 = 1+2+3)

  5. Example procedures start start j=2 k=i is j>=i halt k=k+1 i is prime is i/j integer? halt sum=0 i is not prime j=j+1 j=1 is j<k does sum=k? j=j+1 is k/j halt integer? there is a perfect no>i sum=sum+j yes yes no no yes no yes determine whether or not an integer is a prime determine whether or not there is a perfect number greater than i The lhs is an algorithm. Termination of the rhs depends on number theory: is there an infinite number of perfect numbers?

  6. Questions - Design a mc/prog to recognise the language {a, aa, aaa, …} i.e. a+ . - Design a mc/prog to recognise the language {aba, aabaa, aaabaaa, …} i.e. anban . - Design a mc/prog to recognise the language {abc, aabbcc, aaabbbccc, …} i.e. anbncn . - Design a mc/prog to recognise whether or not a Java program has any type errors. - Design a mc/prog to recognise whether or not a Java program will terminate, for a given input. Aims of course: to answer these questions and give you an… • appreciation of which functions are computable • appreciation of link between languages and machines • appreciation of Chomsky hierarchy

  7. Outline • Lectures • Regular languages and FSA • Context-free, context-sensitive languages and Pushdown automata • Turing machines • Extended Turing machines, universal Turing machines • Halting problem, undecidability • Tutorial • Surprise Disclaimer: These lecture notes are not pretty, nor animated, but they contain the core material!

  8. Grammars and Languages A language is generated by a grammar, G= (N, T, P, S), consisting of T terminal symbols (alphabet, characters) e.g. {a,b} N nonterminal symbols (which stand for strings of characters) e.g. S, A P production rules (which describe how the language is generated) S a special start symbol. All sets are finite. Example -- Language {ab,abab, ababab, …} T = {a,b} N= {S} S = {S} P = S -> ab | abS | or S -> ab S -> abS A derivation of a string in L(G) is S => abS => ababS => ababab Another one is S => ab NB.Finite set of terminals, finite set of strings, but infinitely many strings. Much more in Prog. Lang. 3!

  9. A Regular language is generated by a regular grammar G= (N, T, P, S) with restrictions on the form of productions 1. If there is an e-production, then it has form S-> e and S does not appear on the rhs of any other production 2. All other productions have form A -> a, A e N, a e T or A -> aB, A,B e N, a e T. Regular expressions (RE) are alternative way to define regular languages. Given an alphabet S, 1. e is a RE. For alla eS, a e RE. 2. If a and b are REs, then so too are a U b (union), ab (concatenation), and a* (Kleene star). • No other string is a RE. If a is a RE, then L(a) is defined by L(e) = {e} L(a) = {a} for a e S L(a U b) = L(a) U L(b) L(ab) = {uv| u L(a),v L(b)} L(a *) = {e} U a U a2U a3 e.g. L(a*b*) = {e,b,a, ab, aa, aab, abb, …}, ba e L(a*b*) How do you know which strings are in this language? How do you recogniseL(a*b*)? How do you computeL(a*b*)? grep == get RE pattern

  10. Deterministic Finite State Automata (FSA) States Q and transition relation (Q x S) -> Q, represented as directed graph. Nodes represent states. Arrows represent the transitions and are labelled by characters from S (input alphabet). Start state >. Accepting state(s) . (favoured states or favored states, yuk) Accepts the language anbm (S is {a,b}). Think of the input as a one-way, read-only tape a a b b b … NB. One automaton. Several automata. b a a a a > b

  11. b a b a a > b Accepts the language of strings containing two consecutive a’s. (a*b*)* aa (a*b*)*. b a b a a > b Accepts the complement i.e. language of strings which do not containing two consecutive a’s.

  12. FSAs recognise Regular languages; they are as expressive as each other. • FSA  Regular Languages (machine) (language) • But what if we add nondeterminism to FSAs?

  13. a b b > Nondeterminism can yield a more efficient machine, but it does not increase any computational power. Any nondeterministic FSA can be converted (by an algorithm) into a deterministic FSA. b A nondeterministic FSA to recognise strings which start and end with a b. i.e. b (a|b)* b. But this can be converted into a deterministic FSA: a b b b > a

More Related