300 likes | 370 Views
Computability, etc. Recap. Present homework. Grammar and machine equivalences. Turing history Homework: Equivalence assignments. Presentation proposals, preparation. Keep up on postings. Recap. Define different types of machines. abstract machines
E N D
Computability, etc. Recap. Present homework. Grammar and machine equivalences. Turing history Homework: Equivalence assignments. Presentation proposals, preparation. Keep up on postings.
Recap • Define different types of machines. • abstract machines • Machines are fed (my term) strings in a specified alphabet. • Machines scan the strings and say yes or no (accept or reject) • Each machine accepts strings in a certain pattern. We call the set of strings in that pattern a language.
Recap • Repeat: a language is a SET of strings. • This set may be finite or infinite. • the empty set is a language, with no actual members==elements • This set may or may not include the empty string
Homework • Define a FSA, alphabet {A,blank}, that accepts strings with even number of As. Define a second FSA that accepts strings with an odd number of As. • Define a PDA, alphabet {A, blank,(, ),+} that accepts A, A+A, (A+A), (A+(A+A)) etc. NOT A+ , not unbalanced ( and ). HOLD OFF ON THIS ONE: SEE HOMEWORK! • Define TM that subtracts 1. If input is zero, then tape is cleared. • Define Turing machine to subtract two numbers a and b, represented by a+1 1s followed by a blank followed by b+1 1s • if (a>=b), put (a-b) + 1 1s on the tape • if a<b, leave zero 1s in the tape OR return something else if a<b ???
Turing machine • can perform a function or • define same type of machine plus accepting and rejecting states and say a TM defines a language L if strings in the language L make the machine stop in an accepting state and strings NOT in L stop in a rejecting state.
Decidability • A TM that always halts is called a decider. • TM can keep going, that is, loop… • A language is Turing-decidable if a decider TM recognizes it.
Univeral Turing Machine • Consider the input <M,w> where M is [some encoding for] a Turing Machine and w is a string. • Claim: it is possible to define a TM U such that U simulates M on w! This is analogous to a general purpose computer. • may have contributed to idea of stored program computing
Halting problem • Consider a universal Turing machine U. • Now, if a M loops on a w, so would U. • U is not a decider! • Put another way: the setATM = {<M,w> | M is a TM and M accepts w} is undecidable. It can be proven that there does not exist a TM that always halts, that says yes or no on all inputs <M,w>.
Recap • There are different definitions/constructions/concepts that define the same set of functions or languages. • So-called recursive functions (more next) correspond to computable (TM) functions. • Languages defined by a Regular Expression (look it up) are languages recognized by a FSA. • Languages defined by a Context Free Grammar (look it up) are languages recognized by a PDA. • Some proofs of equivalence are easy and some more substantial. • Will not focus on proofs, BUT these are possible topics for presentations.
Recursive functions Define a set of functions by specifying a starter set and then ways of adding new functions. Functions can be on vectors. Stick to integers. Starter set • identify function and projection I(x) = x and Pi(x1,x2,…xn) = xi • Add 1: A(x) = x+1 • Constant: Ck(x) = k
Ways to add • Composition: if F and G are recursive (and F produces the right size vector, then the composition G F (first you do F and then G to the result) is recursive. • Primitive recursion: Given functions F and G, define HH(0,x1, x2, …, xn) = F(x1, x2, … xn) andH(y+1, x1, x2, … xn)= G(y,x1, …,xn, H(x1,x2,…,xn)) • Minimal inverse: Given a function F, then the function H defined by H(x) = y such that F(y) = x and y is the smallest integer such that that is true.
Equivalence! • If there exists a TM for a function F, then F is recursive. • If a function F is recursive (that is, in this set), then [you can define] a TM that performs F.
Grammars • A grammar G is a • set of symbols, divided in final symbols and auxiliary symbols • (finite) set of production rules of the form string of symbols => string of symbols • final symbols have no production rules of the formf => … • In this exposition, we view certain strings of letters as single symbols. • one auxiliary is called the started symbol s • The language generated (defined by) G is all the strings of final symbols generated by a sequence starting with s
Example • Think of auxiliaries as parts of speech and final symbols as (whole) words • Let s be sentencevp be verb phrasenp be noun phrasen be nounv be verbdo be direct objectadj be adjectiveadv be adverb
Example • Think of parts of speechs => np vpnp => adj n | nvp => v | v adv | v do | v do advdo => nn => boy | girl | dog | cheesev => walks | runs | jumps | eatsadj => short | tall | spottedadv => fast | slowly
Try • To construct the parse tree fortall girl walksshort boy eats cheese slowly
Context free grammar • Production rules are of the formauxiliary symbol => string of symbols
So what isn't CFG? • There also can be rules of the formaPb => …. • where P is an auxiliary symbol. Think of it as: P in the context of a and b produces something. So this is NOT context-free.
Example CFG • S => TT => aT => a + TT => (T) • What language does this produce (list the terms)?
Regular grammar All rules are of the form: • auxiliary symbol => final symbol or • auxiliary symbol => single final symbol followed by an auxiliary symbol
Regular grammars &FSA • Any language accepted by a regular grammar is accepted by a FSA and • Any language accepted by a FSA is accepted by a regular grammar. Said a different way: If a language L is accepted by a regular grammar G, we can define a FSA that accepts it AND if a language L is accepted by a FSA, we can define a regular grammar that accepts it.
Informal proof • Have a Grammar G with production rules of the accepted form. • Define a FSA with one state for each auxiliary symbol, plus one more state. Make the initial state the one corresponding to the initial symbol. Add one more state, F and let it be the final state. • If P=>aQ, where P and Q are auxiliaries and a is a symbol in the final alphabet, make an edge from P to Q, with label a. • If P=>a, make an edge going from P to F with label a.
Cont. • Given a FSA, define a grammar with auxiliary symbols corresponding to the states. The initial symbol is the one corresponding to the initial state. • Add production rules P=>aQ for all edges from P to Q. • Change all production rules P=>aF to P=>a.
Closure Regular languages are closed with respect to various operations, including concatenation. • If M is a regular language and N is a regular language, then we can define MN is the language made up of all the strings of the form sm sn where sn where sm is in M and sn is in N. Then MN also is regular.
Closure • If M and N are regular languages then so is the union of M and N. • This is defined as the set of strings that are in M or are in N (or both). • This also is a regular language.
Regular expressions Yet another equivalent definition! • A regular expression over an alphabet is a pattern defined using letters from the alphabet combined using notation for union, concatenation, wild card, counts. • The regular expession defines a set of strings, that is, a language
CFG andPDA Same equivalence here.
Turing history • Invented what came to be called Turing machines. Proved various things about them, including Halting problem • Worked in Bletchley Park during WWII: built a machine to help decode German codes (codes changed). Given medal (in secret) • Worked in general area, including spending time at Princeton with Van Neumann, others. Wrote papers on computer chess, notion of Turing test • Arrested & convicted for homosexual acts. Made to take hormone drugs. Appeared to be okay… • Committed suicide
Homework • Pick 1: Please think about it first instead of or before trying to look it up. Informal proofs are okay. • CFG and PDA equivalence • If you believe this, then there does exist a PDA for the homework problem. • Regular expression and (either) FSA or Regular grammar equivalence • Possibilities for presentation topics in Turing work, history • Keep up postings • Shai videos