reminder
play

Reminder Final exam Unrestricted Grammars The date for the Final - PDF document

Reminder Final exam Unrestricted Grammars The date for the Final has been decided: Saturday, November 16 th 12:30pm 2:30pm 07 1420 Homework Announcement October 31 st (today) is halloween Homework #7


  1. Reminder • Final exam Unrestricted Grammars – The date for the Final has been decided: – Saturday, November 16 th – 12:30pm – 2:30pm – 07 – 1420 Homework Announcement • October 31 st (today) is halloween • Homework #7 – Help after lecture – Why isn’t anyone dressed as Kleene?!?! – Refreshments at CS Offices • After this course – Remember…valuable prizes. Plan for today Before We Start • Relating CFL to Recursive Languages • An example of computing a numerical function with a TM – Unrestricted Grammars 1

  2. Computation with Turing Machines Computation with Turing Machines • Computing functions with TMs • A TM that computes n mod 2 – n is input on the tape as a sequence of n 1’s – Formally, – Solution will be the number of 1’s remaining on the • Let T = (Q, Σ , Γ , q 0 , δ ) be a TM and let f be a tape when the machine halts. partial function on Σ * . We say T computes f if for – Basic idea: every x ∈ Σ * where f is defined: – (q 0 , ∆ x) a * (h, ∆ f(x)) • Machine makes a pass from left to right to first blank. • Move left, “erasing” 1’s two at a time • And for every other x, T fails to halt on input x. • If n is odd, a single 1 will be left on the tape • Otherwise no 1’s will be left on the tape. Computation with Turing Machines Computation with Turing Machines • You know you want to see it… 1/1,R – A final JFLAP run Odd # of 1’s 1/ ∆ ,L ∆ / ∆ ,R ∆ / ∆ ,R ∆ / ∆ ,L ∆ / 1,L 1/ ∆ ,L ∆ / ∆ ,S Move to right Even # of 1’s Read 1’s two of string by two Grammars Languages • Now back to our regularly scheduled • You are the weakest link! lecture. – What is a language? – What is a class of languages? 2

  3. Now we have 2 pictures…this And this one… one Context Free Languages Recursively Deterministic Context Free Languages Enumerable Regular Languages Recursive Finite Languages How do these 2 relate Unrestricted grammars Context Free Grammars • To answer this we’ll have to take another • Let’s formalize this a bit: look at grammars. – A context free grammar (CFG) is a 4-tuple: (V, Σ , S, P) where • V is a set of variables • Σ is a set of terminals • V and Σ are disjoint (I.e. V ∩ Σ = ∅ ) • S ∈ V, is your start symbol Context Free Grammars Context Free Grammars • Let’s formalize this a bit: • Let’s formalize this a bit: – Production rules – Production rules • Of the form A → β where • We say that the grammar is context-free since this – A ∈ V substitution can take place regardless of where A is. – β ∈ (V ∪ ∑ ) * string with symbols from V and ∑ • We write α ⇒ * γ if γ can be derived from α in zero • We say that γ can be derived from α in one step: or more steps. – A → β is a rule – α = α 1 A α 2 – γ = α 1 β α 2 – α ⇒ γ 3

  4. Unrestricted Grammars Unrestricted grammars • With unrestricted grammars, there is no • Let’s formalize this a bit: restriction on the length of the left hand side – An unrestricted (or phase-structure) grammar is of a production. a 4-tuple: (V, Σ , S, P) where • The only rule is that the left hand side must • V is a set of variables contain at least 1 varaible • Σ is a set of terminals – Example: • V and Σ are disjoint (I.e. V ∩ Σ = ∅ ) • ABC → aB • S ∈ V, is your start symbol • Ba → ACA • aAa → b Unrestricted grammars Unrestricted grammar • Let’s formalize this a bit: • Example – L = { a i b i c i | i ≥ 1 } note: this is not a CFL – Production rules – S → Α 1 BCS 1 | A 1 BC (1) • Of the form α → β where – S 1 → ABCS 1 | ABC (2) – α , β ∈ (V ∪ ∑ ) * string with symbols from V and ∑ – BA → AB (3) CA → AC (4) – α contains at least 1 variable. • If α → β is a rule , we say that γ can be derived – CB → BC (5) cC → cc (6) from α in one step: – bC → bc (7) bB → bb (8) – By replacing a occurrence of α on the right hand side with – aB → ab (9) aA → aa (10) β – Α 1 → a (11) Unrestricted grammar Unrestricted grammar • Derive aabbcc • Derive aabbcc – S → Α 1 BCS 1 (1) – → aABACBCBC → Α 1 BCABCS – (2) – → aAABCBCBC (3) → Α 1 BCABCABC (2) – – → aAABBCCBC (5) → aBCABCABC (11) – – → aAABBCBCC (5) → aBACBCABC (4) – – → aAABBBCCC (5) → aABCBCABC (3) – – → aaABBBCCC (10) → aABCBACBC (4) – – → aaaBBBCCC (10) → aABCABCBC (3) – – → aaabBBCCC (9) → aABACBCBC (4) – 4

  5. Unrestricted grammar Context Sensitive Grammar • Context Sensitive Grammars • Derive aabbcc – → aaabBBCCC – Productions – → aaabbBCCC (8) • α → β where α contains at least 1 variable – → aaabbbCCC (8) • And | α | ≤ | β | – → aaabbbcCC (7) – A variable can only be replaced in the context of other symbols – → aaabbbccC (6) – A language derived fron a context sensitive – → aaabbbccc (6) grammar is a context sensitive language. • The last example was a context sensitive language • Questions? Context Sensitive Grammar It can be shown that: • Do Context Sensitive Languages have a • Every Context Free Language is Context Sensitive corresponding machine ? – By definition of the grammars – Of course, all language classes do. • Every Context Sensitive Language is Recursive – Linear Bounded Automata – Minor modification to turn an LBA into a TM that always halts. • Like a TM except – Has two additional symbols 〈 and 〉 • There is a recursive language that is not Context – The LBA’s starting configuration is (q 0 , 〈 x 〉 ) Sensitive – The machine cannot move left of the 〈 or right of the 〉 – One of those strange diagonal type languages. – An LBA can only use n cells on the tape where n is the size of the input string. – Captain Kirk → Robot → BOOM. Our complete picture: Context Sensitive Languages Recursively Enumerable • Fun facts Recursive – Context Sensitive Languages are closed under Context Sensitive • Union, Intersection, and Concatenation… Context Free • If L is context sensitive, so is L + • Complement…Open question for quite some time Deterministic Context Free – Turns out to be yes. Finite • Still unknown if every CSL can be accepted by a Regular DETERMINISTIC Linear Bounded Automata. 5

  6. Context Sensitive Languages It also can be shown: • More fun facts • Every recursively enumerable language can be generated by an unrestricted grammar. – Most “practical” languages are context sensitive. • In fact, Chomksy (the grammar guy), set out • Programming languages to define the four language classes: • Spoken languages – Regular, CF, CS, Recursively Enumerable – By just using grammars. Theory Hall of Fame Chomsky Hierarchy (1956, 1959) • Noam Chomsky – The Grammar Guy – 1928 – – b. Philadelphia, PA – PhD – UPenn (1955) • Linguistics – Prof at MIT (Linguistics) (1955 - present) – Probably more famous for his leftist political views. Summary • Unrestricted Grammars • Context Sensitive Grammars • Linear Bounded Automata • Chomsky Hierarchy • Questions? – Next time…Computability 6

Recommend


More recommend