Homework • Homework #7 – Due today Unrestricted Grammars • Homework #8 (due Tuesday or Thursday) – 9.5 – 9.38 (only decode first 4 transitions) – 11.6 – Give the topic presented in this class that your enjoyed the most. – Give the topic presented in this class that your enjoyed the least. Plan for today Before We Start • Relating CFL to Recursive Languages • Any questions? – Unrestricted Grammars • Computation and Unsolvability Now we have 2 pictures…this Languages one • You are the weakest link! Context Free Languages – What is a language? Deterministic Context Free Languages – What is a class of languages? Regular Languages Finite Languages 1
And this one… Unrestricted grammars • To answer this we’ll have to take another Recursively look at grammars. Enumerable Recursive How do these 2 relate Context Free Grammars Context Free Grammars • Let’s formalize this a bit: • Let’s formalize this a bit: – Production rules – A context free grammar (CFG) is a 4-tuple: (V, • Of the form A → β where Σ , S, P) where – A ∈ V • V is a set of variables – β ∈ (V ∪ ∑ ) * string with symbols from V and ∑ • Σ is a set of terminals • We say that γ can be derived from α in one step: • V and Σ are disjoint (I.e. V ∩ Σ = ∅ ) – A → β is a rule – α = α 1 A α 2 • S ∈ V, is your start symbol – γ = α 1 β α 2 – α ⇒ γ Context Free Grammars Unrestricted Grammars • With unrestricted grammars, there is no • Let’s formalize this a bit: restriction on the length of the left hand side – Production rules of a production. • We say that the grammar is context-free since this • The only rule is that the left hand side must substitution can take place regardless of where A is. • We write α ⇒ * γ if γ can be derived from α in zero contain at least 1 varaible or more steps. – Example: • ABC → aB • Ba → ACA • aAa → b 2
Unrestricted grammars Unrestricted grammars • Let’s formalize this a bit: • Let’s formalize this a bit: – An unrestricted (or phase-structure) grammar is – Production rules a 4-tuple: (V, Σ , S, P) where • Of the form α → β where – α , β ∈ (V ∪ ∑ ) * string with symbols from V and ∑ • V is a set of variables – α contains at least 1 variable. • Σ is a set of terminals • If α → β is a rule , we say that γ can be derived • V and Σ are disjoint (I.e. V ∩ Σ = ∅ ) from α in one step: • S ∈ V, is your start symbol – By replacing a occurrence of α on the right hand side with β Unrestricted grammar Unrestricted grammar • Derive aabbcc • Example – S → Α 1 BCS 1 – L = { a i b i c i | i ≥ 1 } note: this is not a CFL (1) → Α 1 BCABCS – (2) – S → Α 1 BCS 1 | A 1 BC (1) → Α 1 BCABCABC (2) – – S 1 → ABCS 1 | ABC (2) → aBCABCABC (11) – – BA → AB (3) CA → AC (4) → aBACBCABC (4) – – CB → BC (5) cC → cc (6) → aABCBCABC (3) – – bC → bc (7) bB → bb (8) → aABCBACBC (4) – – aB → ab (9) aA → aa (10) → aABCABCBC (3) – – Α 1 → a (11) → aABACBCBC (4) – Unrestricted grammar Unrestricted grammar • Derive aabbcc • Derive aabbcc – → aABACBCBC – → aaabBBCCC – → aAABCBCBC (3) – → aaabbBCCC (8) – → aAABBCCBC (5) – → aaabbbCCC (8) – → aAABBCBCC (5) – → aaabbbcCC (7) – → aAABBBCCC (5) – → aaabbbccC (6) – → aaABBBCCC (10) – → aaabbbccc (6) – → aaaBBBCCC (10) – → aaabBBCCC (9) • Questions? 3
Context Sensitive Grammar Context Sensitive Grammar • Context Sensitive Grammars • Do Context Sensitive Languages have a corresponding machine ? – Productions • α → β where α contains at least 1 variable – Of course, all language classes do. • And | α | ≤ | β | – Linear Bounded Automata – A variable can only be replaced in the context • Like a TM except of other symbols – Has two additional symbols 〈 and 〉 – The LBA’s starting configuration is (q 0 , 〈 x 〉 ) – A language derived fron a context sensitive – The machine cannot move left of the 〈 or right of the 〉 grammar is a context sensitive language. – An LBA can only use n cells on the tape where n is the • The last example was a context sensitive language size of the input string. It can be shown that: Our complete picture: Recursively Enumerable • Every Context Free Language is Context Sensitive Recursive – By definition of the grammars Context Sensitive • Every Context Sensitive Language is Recursive Context Free – Minor modification to turn an LBA into a TM that always halts. Deterministic Context Free • There is a recursive language that is not Context Sensitive Finite – One of those strange diagonal type languages. Regular – Captain Kirk → Robot → BOOM. It also can be shown: Chomsky Hierarchy (1956, 1959) • Every recursively enumerable language can be generated by an unrestricted grammar. • In fact, Chomksy (the grammar guy), set out to define the four language classes: – Regular, CF, CS, Recursively Enumerable – By just using grammars. 4
Summary • Unrestricted Grammars • Context Sensitive Grammars • Linear Bounded Automata • Chomsky Hierarchy • Questions? 5
Recommend
More recommend