Presentation is loading. Please wait.

Presentation is loading. Please wait.

Context Sensitive Grammar & Turing Machines

Similar presentations


Presentation on theme: "Context Sensitive Grammar & Turing Machines"— Presentation transcript:

1 Context Sensitive Grammar & Turing Machines
Akram Salah

2 Language L is a set of strings, w, over an alphabet S
A grammar G(V, T, S, P) in which P is a set of rules. Strings generated, or accepted, by G, L(G), is a language An automaton is a machine that accepts, or acts upon, a set of strings. Strings that are generated, or accepted, by an automaton defines a language.

3 Regular Languages Simple Nested patterns
We need a higher level languages Regular grammars Production rules are restricted LHS must be a single variable RHS is either left linear or right linear Automata associated with regular languages are finite.

4 Context free Languages
A level higher than regular languages Grammars Production rules RHS constraints are relaxed Parsing is tree like, ambiguity Automata Push down automata Stack, in addition to finite automata

5 Context Sensitive Grammar
A grammar G = (V, T, S, P) is said to be context-sensitive if production rules in P have the form x -> x, where x& y e (V u T)+ and |x| < |y| Non-contracting A language L is said to be context sensitive iff there is a context sensitive grammar G such that L = L(G) u L. We have relaxed the constraints on RHS & LHS Note that a regular and context free languages, are also context sensitive.

6 Context sensitive G = ({A, B, S}, {a, b, c}, S, P), where P
S -> abc|aAbc,, Ab -> bA, Ac -> Bbcc, bB -> Bb, aB -> aa|aaA. S => aAbc => abAc => abBbcc => aBbbcc => aaAbbbb => aabBbcc => aabbAcc => aabbBbccc => aabBbbccc => aaBbbbccc => aaabbbccc. a3b3c L= {anbncn : n > 1}

7 Control Unit Read-write head Tape

8 Turing Machine A Turing machine M is
M = (Q, S, G, d, q0, [], F), where Q finite set of internal states of control unit, S input alphabet, G finite set of symbols called tape alphabet, d: Q x G -> Q x G x {L, R} is a transition function, [] e G is a special symbol called blank, q0 e Q is the initial state of the control unit, F subset Q is the set of final states.

9 Turing Machine Design a Turing machine that accepts
L = {an bn : n > 1}

10 Turing Machine Q = {q0, q1, q2, q3, q4} F = {q4}, S = {a, b}
G = {a, b, x, y, []}.

11 Turing Machine d(q0, a) = (q1, x, R), d(q1, a) = (q1, a, R),
d(q1, y) = (q1, y, R), d(q1, b) = (q2, y, R), d(q2, y) = (q2, y, L), d(q2, a) = (q2, a, L), d(q2, x) = (q0, x, R), d(q0, y) = (q3, y, R), d(q3, y) = (q3, y, R), d(q3, []) = (q4, [], R).

12 Turing Machine There are several models that follow Turing machine

13 Universal Turing Machine
Control Unit of Mu Internal State of M Description of M Tape content of M

14 Universal Turing Machine
A universal Turing machine (reprogrammable Turing machine) Mu An automaton that, given as input a description of any Turing machine M and a string w, can simulate the computation of M on w

15 The Chomsky Hierarchy Type 0: languages generated by unrestricted grammars Recursively enumerable languages (LRE) Type 1: languages generated by context sensitive grammars (LCS). Type 2: languages generated by context-free grammars (LCF). Type 3: languages generated by regular grammars (LREG) Each language family type i is proper subset of the family type i-1. deterministic context-free (LDCF), recursive languages (LREC)

16 The Chomsky Hierarchy RE CS CF REG


Download ppt "Context Sensitive Grammar & Turing Machines"

Similar presentations


Ads by Google