1 Section 14.2 A Hierarchy of Languages Context-Sensitive Languages A context-sensitive grammar has productions of the form xAz  xyz, where A is a nonterminal.

Slides:



Advertisements
Similar presentations
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
Advertisements

Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Variants of Turing machines
Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
Reducibility 2 Theorem 5.1 HALT TM is undecidable.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata are like Turing Machines with a restriction: The working space of the tape is the space of the.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Linear Bounded Automata LBAs
1 Decidability continued. 2 Undecidable Problems Halting Problem: Does machine halt on input ? State-entry Problem: Does machine enter state halt on input.
LING 388 Language and Computers Lecture 11 10/7/03 Sandiway FONG.
Fall 2006Costas Busch - RPI1 The Chomsky Hierarchy.
A shorted version from: Anastasia Berdnikova & Denis Miretskiy.
Fall 2003Costas Busch - RPI1 Turing Machines (TMs) Linear Bounded Automata (LBAs)
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Formal Grammars Denning, Sections 3.3 to 3.6. Formal Grammar, Defined A formal grammar G is a four-tuple G = (N,T,P,  ), where N is a finite nonempty.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
Introduction to Language Theory
Computing languages by (bounded) local sets Dora Giammarresi Università di Roma “Tor Vergata” Italy.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
1 Section 12.3 Context-Free Parsing We know (via a theorem) that the context-free languages are exactly those languages that are accepted by PDAs. When.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
9.7: Chomsky Hierarchy.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Recursively Enumerable Languages
Discrete Structures ICS252 Chapter 5 Lecture 2. Languages and Grammars prepared By sabiha begum.
Recursively Enumerable and Recursive Languages
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Course Overview Why this course “formal languages and automata theory?” What do computers really do? What are the practical benefits/application of formal.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
Unrestricted Grammars
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
Undecidability and The Halting Problem
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Chapter 5 Recursive and recursively enumerable functions Phrase-structure grammars.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
1 Recursively Enumerable and Recursive Languages.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesAlgebraic.
Linear Bounded Automata LBAs
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Language and Grammar classes
Complexity and Computability Theory I
Natural Language Processing - Formal Language -
Context Sensitive Grammar & Turing Machines
Context Sensitive Languages and Linear Bounded Automata
The chomsky hierarchy Module 03.3 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
CSE322 Chomsky classification
CSE322 The Chomsky Hierarchy
A HIERARCHY OF FORMAL LANGUAGES AND AUTOMATA
Jaya Krishna, M.Tech, Assistant Professor
Decidable Languages Costas Busch - LSU.
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Decidability continued….
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
The Chomsky Hierarchy Costas Busch - LSU.
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

1 Section 14.2 A Hierarchy of Languages Context-Sensitive Languages A context-sensitive grammar has productions of the form xAz  xyz, where A is a nonterminal and x, y, z are strings of grammar symbols with y ≠ . The production S   is also allowed if S is the start symbol and it does not appear on the right side of any production. A context-sensitive language has a context-sensitive grammar. Example. The following grammar is context-sensitive. S  aTb | ab aT  aaTb | ac. Quiz. What is the language of the grammar? Answer: {ab}  {a n+1 cb n+1 | n  N}. This language is context-free. For example, it has the grammar S  aTb | ab, and T  aTb | c. Any context-free language is context sensitive. Example. {a n b n c n | n ≥ 0} is context-sensitive but not context-free. Here is a csg. S   | abc | aTBc T  abC | aTBC CB  CX  BX  BC bB  bb. Cc  cc. Quiz. Derive aaabbbccc. Answer: S  aTBc  aaTBCBc  aaabCBCBc  aaabBCCBc  aaabBCBCc  aaabBBCCc  aaabbBCCc  aaabbbCCc  aaabbbCcc  aaabbbccc.

2 Linear Bounded Automata (LBA) A linear bounded automaton (LBA) is a Turing machine that may be nondeterministic and that restricts the tape to the length of the input with two boundary cells that may not change. Example. An LBA to check whether a natural number n is divisible by k ≠ 0. Idea for a Solution: Use a 2-tape (or 2-head single tape) machine. For ease of explanation, represent k by the nonempty string 1 k and represent n by the string a n. For example, if k = 3 and n = 9, the input is represented by, 111a a a a a a a a a If n = 0, which is represented by , then halt. Otherwise, move both tape heads to the right k places while there are a’s to read. Then leave the tape head for a’s in place and move the tape head for k back to the left end and start the process over. Continue in this manner and enter the halt state if both tape heads point to . Theorem: The context-sensitive languages are exactly the languages that are accepted by linear bounded automata (LBA). Example/Quiz. Find an LBA to accept {a p | p is prime}. Idea for a Solution: Use the the divisibility algorithm in the previous example to implement the following algorithm, where p ≥ 2. k := 2; while k < p do if k divides p then stop (but don’t enter the halt state) else k := k + 1 fi od; Enter the halt state (accept).

3 Recursively Enumerable Languages An unrestricted grammar has productions of the form s  t, where s ≠ . So any grammar is an unrestricted grammar. An unrestricted or recursively enumerable language has an unrestricted grammar. Example. The following grammar is unrestricted.S  TbC Tb  c cC  Sc | . This grammar is not context-sensitive, not context-free, and not regular. But we can transform it into S  Sc | . So the language of the grammar is regular. Theorem: The recursively enumerable languages are exactly the languages that can be accepted by Turing machines. These languages can also be enumerated by Turing machines. (That’s where “enumerable” comes from.) Theorem: {a n | ƒ n (n) halts} is recursively enumerable and not context-sensitive. Proof: (1) Set k := 0. (2) For each pair (n, m), where n + m = k, execute ƒ n (n) for m steps to see if it halts. If it halts, output a n. (3) Increment k and go to (2). Languages With No Grammars Since there are a countable number of Turing machines, there are a countable number of languages with grammars. But there are an uncountable number of languages over any finite alphabet. So there are an uncountable number of languages don’t have a grammar. Theorem: {a n | ƒ n is total} is not recursively enumerable. So it has no grammar. Proof: If, BWOC, the language is recursively enumerable, then we can enumerate it by a TM. So we can enumerate the total computable functions, which we can’t do. QED.