Context Sensitive Grammar (Automata theory)

  • Thread starter Dafydd
  • Start date
  • Tags
    Theory
In summary, the example shown in the textbook shows how to create a string using the language defined by the grammar. The first substitution is done from [ to [D, and the second substitution is done from epsilon to 11111111.
  • #1
Dafydd
12
0
Sorry if this is the wrong forum.

I'm trying to get my head around Context Sensitive Grammar. In my coursebook, there's an example ('e' here is the empty string, epsilon, and 'E' is the "set member" symbol):

The language {an bn cn | n E N} is described by the following rules:

S -> e | abNSc
bNa -> abN
bNb -> bbN
bNc -> bc

And then it shows how to build aabbcc:

S -> abNSc
-> abNabNScc
-> abNabNcc
-> aabNbcc
-> aabbNcc
-> aabbcc

The part I don't understand is why S becomes abNSc after the first substitution, while the second time it becomes an empty string. The rules state both substitutions are possible, but not when to use which one. Can this be choosen freely?

Another language (with 4 non-deterministic symbols S, D, [, ]) describes {1, 1^2, 1^4, 1^8, ...}. Its rules:

S -> [1]
[ -> [D
D1 -> 11D
D] -> ]
[ -> e
] -> e

Example, building the string 11111111:

S -> [1] -> [D1] ->* [DDD1]
-> [DD1D]
-> [D11D1D]
-> [D1111DD]
-> [11D111DD]
-> [1111D11DD]
-> [111111D1DD]
-> [11111111DDD]
-> [11111111DD]
-> [11111111D]
-> [11111111]
-> [11111111
-> 11111111

Again, the number of times a substitution is carried out seems to be random, or at least arbitrary. Why do you not just keep doing the substitution from [ to [D indefinitely? Because you know how many times it needs to be done in order to get the resulting string you want? Can you choose to do the substitutions in any order you want (as long as it gets you the result you want), or is there a pattern to follow?

Thanks for any help.
 
Technology news on Phys.org
  • #2
The language defined by a grammar consists of every string that you can produce by applying the production rules.
Can you choose to do the substitutions in any order you want
So yeah.
 
  • #3
That's all I needed to hear. Thank you!
 

Related to Context Sensitive Grammar (Automata theory)

1. What is context sensitive grammar?

Context sensitive grammar is a type of formal grammar in automata theory that describes the rules for generating strings in a language. It is a more powerful form of grammar compared to regular and context-free grammar, as it can take into account the context in which a symbol appears in a string.

2. What are the components of a context sensitive grammar?

A context sensitive grammar consists of a set of terminal symbols, a set of non-terminal symbols, a set of production rules, and a start symbol. The production rules define how the symbols can be replaced to generate strings in the language.

3. How is context sensitive grammar different from context-free grammar?

The main difference between context sensitive and context-free grammar is that context sensitive grammar allows for the use of rules that take into account the context in which a symbol appears, whereas context-free grammar only looks at the symbol itself. This makes context sensitive grammar more powerful and able to generate a wider range of languages.

4. What is the role of automata theory in context sensitive grammar?

Automata theory is used in context sensitive grammar to determine whether a given string is a valid sentence in the language. This is done by constructing a pushdown automaton, which is a type of finite state machine that can handle context sensitive languages.

5. What are some real-world applications of context sensitive grammar?

Context sensitive grammar has many practical applications, such as natural language processing, computer programming, and artificial intelligence. It is also used in the development of programming languages and compilers, as well as in the analysis of DNA sequences in bioinformatics.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Beyond the Standard Models
Replies
9
Views
573
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
4K
  • Beyond the Standard Models
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
293
Replies
7
Views
9K
Replies
2
Views
3K
  • General Discussion
Replies
2
Views
3K
Back
Top