Context Sensitive Grammar

Similar documents
CA320 - Computability & Complexity

UNRESTRICTED GRAMMARS

The Post Correspondence Problem

Introduction to Formal Languages, Automata and Computability p.1/42

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Turing machines and linear bounded automata

Computability and Complexity

CSCE 551: Chin-Tser Huang. University of South Carolina

Theory of Computation Turing Machine and Pushdown Automata

UNIT-VIII COMPUTABILITY THEORY

Theory of Computation

Decidability (intro.)

DM17. Beregnelighed. Jacob Aae Mikkelsen

MA/CSSE 474 Theory of Computation

FLAC Context-Sensitive Grammars

Turing machines and linear bounded automata

Automata Theory CS F-13 Unrestricted Grammars

Undecidable Problems and Reducibility

Turing machines and linear bounded automata

Theory of Computation - Module 4

Computability and Complexity

MTH401A Theory of Computation. Lecture 17

Einführung in die Computerlinguistik

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write:

Theory of Computation (IX) Yijia Chen Fudan University

5 3 Watson-Crick Automata with Several Runs

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Introduction to Languages and Computation

Pushdown Automata: Introduction (2)

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CS481F01 Prelim 2 Solutions

Chapter 7 Turing Machines

CS20a: Turing Machines (Oct 29, 2002)

CISC4090: Theory of Computation

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

Foundations of Informatics: a Bridging Course

Chapter 8. Turing Machine (TMs)

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

ECS 120 Lesson 15 Turing Machines, Pt. 1

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Automata Theory - Quiz II (Solutions)

Homework 8. a b b a b a b. two-way, read/write

ECS 120 Lesson 20 The Post Correspondence Problem

Section 1 (closed-book) Total points 30

Introduction to Turing Machines

X-machines - a computational model framework.

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Computability Theory

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

On Rice s theorem. Hans Hüttel. October 2001

Part I: Definitions and Properties

Turing Machines Part III

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Theory & Practice Book. Computer Science & IT. for. Public Sector Exams

Computation Histories

On the Sizes of DPDAs, PDAs, LBAs. by Richard Beigel and William Gasarch

Pushdown Automata (Pre Lecture)

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Automata Theory (2A) Young Won Lim 5/31/18

Reducability. Sipser, pages

Lecture 17: Language Recognition

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

ACS2: Decidability Decidability

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Pushdown Automata (2015/11/23)

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

Computability and Complexity

Theory of Computation (Classroom Practice Booklet Solutions)

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Problems, and How Computer Scientists Solve Them Manas Thakur

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

Pushdown Automata. Reading: Chapter 6

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Theory of Computation

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Variants of Turing Machine (intro)

4.2 The Halting Problem

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Theory of Computation

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Theory Bridge Exam Example Questions

CSCE 551: Chin-Tser Huang. University of South Carolina

Computational Models - Lecture 4

Automata and Computability. Solutions to Exercises

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

How to Pop a Deep PDA Matters

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

UNIT-VI PUSHDOWN AUTOMATA

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

A Universal Turing Machine

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

Transcription:

Context Sensitive Grammar Aparna S Vijayan Department of Computer Science and Automation December 2, 2011 Aparna S Vijayan (CSA) CSG December 2, 2011 1 / 12

Contents Aparna S Vijayan (CSA) CSG December 2, 2011 2 / 12

Contents 1 Definition of CSG Aparna S Vijayan (CSA) CSG December 2, 2011 2 / 12

Contents 1 Definition of CSG 2 Context Sensitive Language(CSL) Aparna S Vijayan (CSA) CSG December 2, 2011 2 / 12

Contents 1 Definition of CSG 2 Context Sensitive Language(CSL) 3 Example of CSL Aparna S Vijayan (CSA) CSG December 2, 2011 2 / 12

Contents 1 Definition of CSG 2 Context Sensitive Language(CSL) 3 Example of CSL 4 Chomsky Hierachy Aparna S Vijayan (CSA) CSG December 2, 2011 2 / 12

Definition Context Sensitive Grammar(Type1 Grammar) A context-sensitive grammar (CSG) is an unrestricted grammar in which every production has the form α β with β α (where α and β are strings of nonterminals and terminals). The concept of context-sensitive grammar was introduced by Noam Chomsky in the 1950. In every derivation the length of the string never decreases. The term context-sensitive comes from a normal form for these grammars,where each production is of the form α 1 Aα 2 α 1 βα 2,with β ɛ. They permit replacement of variable A by string β only in the context α 1 - α 2. Aparna S Vijayan (CSA) CSG December 2, 2011 3 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: N=Set of non terminal symbols. Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: N=Set of non terminal symbols. Σ=Set of terminal symbols. Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: N=Set of non terminal symbols. Σ=Set of terminal symbols. S=Start symbol of the production. Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: N=Set of non terminal symbols. Σ=Set of terminal symbols. S=Start symbol of the production. P=Finite set of productions. Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Formal Definition A Context Sensitive Grammar is a 4-tuple, G = (N,Σ, P, S) where: N=Set of non terminal symbols. Σ=Set of terminal symbols. S=Start symbol of the production. P=Finite set of productions. All rules in P are of the form α 1 Aα 2 α 1 βα 2. A N ( A is a single nonterminal) α 1, α 2, β (N Σ) +. Aparna S Vijayan (CSA) CSG December 2, 2011 4 / 12

Context Sensitive Language The language generated by the Context Sensitive Grammar is called context sensitive language. Aparna S Vijayan (CSA) CSG December 2, 2011 5 / 12

Context Sensitive Language The language generated by the Context Sensitive Grammar is called context sensitive language. If G is a Context Sensitive Grammar then L(G)= { w (w Σ ) ( S + G w)}. Aparna S Vijayan (CSA) CSG December 2, 2011 5 / 12

Context Sensitive Language The language generated by the Context Sensitive Grammar is called context sensitive language. If G is a Context Sensitive Grammar then L(G)= { w (w Σ ) ( S + G w)}. Eg 1 of a context sensitive grammar G = {{S, A, B, C, a, b, c}, {a, b, c}, P, S}where P is the set of rules. S asbc S abc CB BC ab ab bb bb bc bc cc cc The language generated by this grammar is {a n b n c n n 1}. Aparna S Vijayan (CSA) CSG December 2, 2011 5 / 12

Context Sensitive Language The derivation for the string aabbcc is Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc aabcbc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc aabcbc aabbcc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc aabcbc aabbcc aabbcc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc aabcbc aabbcc aabbcc aabbcc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Context Sensitive Language The derivation for the string aabbcc is S asbc aabcbc aabcbc aabbcc aabbcc aabbcc aabbcc Aparna S Vijayan (CSA) CSG December 2, 2011 6 / 12

Example2 CSG L = (#a = #b = #c) G2 =({S, A, B, C, a, b, c}, {a, b, c}, P, S) S ABC S ABCS AB BA AC CA BC CB BA AB CA AC CB BC A a B b C c Aparna S Vijayan (CSA) CSG December 2, 2011 7 / 12

Hierarchy of Formal Languages Aparna S Vijayan (CSA) CSG December 2, 2011 8 / 12

Relation between Formal Languages The CFL s not containing ɛ are properly contained in the context sensitive languages Not all Context Sensitive Languages are Context Free. Every Context Sensitive Language is recusive. Aparna S Vijayan (CSA) CSG December 2, 2011 9 / 12

Chomsky Hierachy Described by Chomsky in 1956. Four classes of language Type 3,Type2,Type1,Type 0 from most restrictive to most general(unestricted). Each level of hierarchy can be characterized by a class of grammar. Aparna S Vijayan (CSA) CSG December 2, 2011 10 / 12

Chomsky Hierarchy Type Language productions Device 3 Regular A ab, A a Finite Automaton 2 CFL A α Pushdown Automaton 1 CSL α β, β α Linear Bounded Automaton 0 RE α β Turing Machine A,B Nonterminals α,β string of terminals and nonterminals a terminal symbol Aparna S Vijayan (CSA) CSG December 2, 2011 11 / 12

References Introduction to Automata Theory Languages and Computation by JOHN E HOPCROFT, JEFFERY D.ULLMAN. Introduction to Languages and the Theory of Computation JOHN MARTIN http://en.wikipedia.org/wiki/context-sensitive grammar http://adammikeal.org/courses/compute/chomsky Aparna S Vijayan (CSA) CSG December 2, 2011 12 / 12

Linear Bounded Automata Indu John Department of Computer Science and Automation Indian Institute of Science, Bangalore December 1, 2011 Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 1 / 14

Overview Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 2 / 14

Overview Definition Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 2 / 14

Overview Definition Results about LBAs Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 2 / 14

Overview Definition Results about LBAs CSLs and LBAs Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 2 / 14

Definition A Turing machine that uses only the tape space occupied by the input is called a linear-bounded automaton (LBA). A linear bounded automaton is a nondeterministic Turing machine M = (Q, Σ, Γ, δ, s, t, r) such that: There are two special tape symbols < and >(the left end marker and right end marker). The TM begins in the configuration (s, < x >, 0). The TM cannot replace < or > with anything else, nor move the tape head left of < or right of >. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 3 / 14

LBA An equivalent definition of an LBA is that it uses only k times the amount of space occupied by the input string, where k is a constant fixed for the particular machine. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 4 / 14

LBA An equivalent definition of an LBA is that it uses only k times the amount of space occupied by the input string, where k is a constant fixed for the particular machine. Possible to simulate k tape cells with a single tape cell, by increasing the size of the tape alphabet Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 4 / 14

LBA An equivalent definition of an LBA is that it uses only k times the amount of space occupied by the input string, where k is a constant fixed for the particular machine. Possible to simulate k tape cells with a single tape cell, by increasing the size of the tape alphabet Examples: {a n b n c n n 0}; counting number of a s Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 4 / 14

LBA An equivalent definition of an LBA is that it uses only k times the amount of space occupied by the input string, where k is a constant fixed for the particular machine. Possible to simulate k tape cells with a single tape cell, by increasing the size of the tape alphabet Examples: {a n b n c n n 0}; counting number of a s This limitation makes the LBA a somewhat more accurate model of computers that actually exist than a Turing machine, whose definition assumes unlimited tape. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 4 / 14

History Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 5 / 14

History In 1960, Myhill introduced an automaton model today known as deterministic linear bounded automaton. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 5 / 14

History In 1960, Myhill introduced an automaton model today known as deterministic linear bounded automaton. Shortly thereafter, Landweber proved that the languages accepted by a deterministic LBA are always context-sensitive. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 5 / 14

History In 1960, Myhill introduced an automaton model today known as deterministic linear bounded automaton. Shortly thereafter, Landweber proved that the languages accepted by a deterministic LBA are always context-sensitive. In 1964, Kuroda introduced the more general model of (nondeterministic) linear bounded automata, and showed that the languages accepted by them are precisely the context-sensitive languages. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 5 / 14

Number of configurations Suppose that a given LBA M has q states, m characters in the tape alphabet, and the input length is n. Then M can be in at most α(n) = Tapecontents {}}{ m n Headposition {}}{ n State {}}{ q configurations. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 6 / 14

Results about LBA Halting Problem The halting problem is solvable for linear bounded automata. Halt LBA = {< M, w > M is an LBA and M halts on w} is decidable. An LBA that stops on input w must stop in at most α( w ) steps Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 7 / 14

Results about LBA Halting Problem The halting problem is solvable for linear bounded automata. Halt LBA = {< M, w > M is an LBA and M halts on w} is decidable. An LBA that stops on input w must stop in at most α( w ) steps Membership problem The membership problem is solvable for linear bounded automata. A LBA = {< M, w > M is an LBA and M accepts w} is decidable. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 7 / 14

Results about LBA Emptiness Problem The emptiness problem is unsolvable for linear bounded automata. For every Turing machine there is a linear bounded automaton which accepts the set of strings which are valid halting computations for the Turing machine. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 8 / 14

LBA Problems Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 9 / 14

LBA Problems 1 Is the class of languages accepted by LBA equal to the class of languages accepted by deterministic LBA? Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 9 / 14

LBA Problems 1 Is the class of languages accepted by LBA equal to the class of languages accepted by deterministic LBA? Open Problem! Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 9 / 14

LBA Problems 1 Is the class of languages accepted by LBA equal to the class of languages accepted by deterministic LBA? Open Problem! 2 Is the class of languages accepted by LBA closed under complement? Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 9 / 14

LBA Problems 1 Is the class of languages accepted by LBA equal to the class of languages accepted by deterministic LBA? Open Problem! 2 Is the class of languages accepted by LBA closed under complement? Yes. (Immerman Szelepcsenyi Theorem) Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 9 / 14

LBAs and CSLs Theorem(Landweber-Kuroda) A language is accepted by an LBA iff it is context sensitive. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 10 / 14

Proof If L is a CSL, then L is accepted by some LBA. Let G = (N, Σ, S, P) be the given grammar such that L(G) = L. Construct LBA M with tape alphabet Σ {N Σ}(2- track machine) First track holds input string w Second track holds a sentential form α of G, initialized to S. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 11 / 14

Proof... If w = ɛ, M halts without accepting. Repeat : 1 Non-deterministically select a position i in α. 2 Non-deterministically select a production β γ of G. 3 If β appears beginning in position i of α, replace β by γ there. If the sentential form is longer than w, LBA halts without accepting. 4 Compare the resulting sentential form with w on track 1. If they match, accept. If not go to step 1. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 12 / 14

Proof... If there is a linear bounded automaton M accepting the language L, then there is a context sensitive grammar generating L {ɛ}. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 13 / 14

Proof... If there is a linear bounded automaton M accepting the language L, then there is a context sensitive grammar generating L {ɛ}. Sketch of proof : Derivation simulates moves of LBA Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 13 / 14

Proof... If there is a linear bounded automaton M accepting the language L, then there is a context sensitive grammar generating L {ɛ}. Sketch of proof : Derivation simulates moves of LBA Three types of productions 1 Productions that can generate two copies of a string in Σ, along with some symbols that act as markers to keep the two copies separate. 2 Productions that can simulate a sequence of moves of M. During this portion of a derivation, one of the two copies of the original string is left unchanged; the other, representing the input tape to M, is modified accordingly. 3 Productions that can erase everything but the unmodified copy of the string, provided that the simulated moves of M applied to the other copy cause M to accept. Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 13 / 14

References John Martin, Introduction to Languages and the Theory of Computation, Tata McGraw-Hill, Third Edition. John Hopcroft, Jeffery Ullman, Introduction to Automata Theory, Languages and Computation. http://www.cs.uky.edu/~lewis/texts/theory/automata/lb-auto.pdf http://en.wikipedia.org/wiki/linear_bounded_automaton http://www.fit.vutbr.cz/~janousek/vyuka/vsl2/newer/class19.pdf Indu John (Department of CSA) Linear Bounded Automata December 1, 2011 14 / 14