A grammar G is a set of 4 elements. It was defined by a mathematician-linguist Naom Chomski as follows.
Definition:
A formal grammar G is a set of 4 elements
G: {N,T,S,P},
Terminal and non-terminal symbols create a vocabulary V=N
T.
The set S includes start state S0
and also finite states F. The rules P can be phrase structural rules or substitution rules and also
transform rules.
Formal languages includes 4 classes correspondingly to 4 types of grammars (Table 3.1):
Such hierarchy is known as hierarchy of N. Chomsky.
Table 1: Classification of Formal Languages (Chomsky Hierarchy)
Type of language |
Grammar |
Example |
0 - natural |
G: {V=N P: x->y, x,y |
P.: x->y, S -> x, xAy -> w, x,y,w |
1 - context |
G: {V=N P: xAy -> xwy, a,b,w |
G: T={a,b,c,d},
N={I,A,B}, P.:I -> aAI, bI -> ba, AI -> ABA, A -> b, AI -> A, bBA -> bcdA |
2 - context free |
G: {V=N P: A -> x, x |
G: T={a,b },
N={I }, P.: I -> aI, I -> bIb, I -> aa, I -> bb |
3 - regular |
G: {V=N P: A -> x, A -> aB (right-side) lub A -> Ba (left-side), a |
G: T={a,b },
N={I,A}, P.: I -> aI, I -> aA, A -> bA, A -> S |
Automata theory is a part of mathematical linguistics, which describes formal languages through Automaton. The most popular model of Automaton is Turing machine. In Turing theory each type of language corresponds to an Automaton model (Table 3.2).
Table 2: Classification of Formal Languages and Automata
Type of language |
Type of Automaton |
0 - natural |
Turing machine, Post machine |
1 - context |
Linear Automaton |
2 - context free |
Pushdown Automaton |
3 - regular |
Finite Automaton |
Definition:
Turing machine is an abstract Automaton, or model of a device for computations, which includes:
The program of Automaton behaviour is a finite state of rules described as below:
If the computer is in state Qi and symbol ti is read on the tape, move the read/write head k steps to the right (left if k is negative) and write symbol sj on the tape; then switch the machine to state Qj.
Definition:
Abstarct Automata A is a set of 4 elements
A: {T,Q,R,F,S},
T - is an input alphabet,
Q - is a set of internal states of the Automaton, or non-terminal symbols,
R - is a finite state of transition rules,
F - is a set of finite states,
S - is a set of output or stack symbols.
The relations between formal grammars and Automaton are shown in Table:
Table 3: Relation between Formal grammar and Automaton
Definition |
|
Grammar |
Automaton |
|
|
| Automaton A read the input symbol, transits to the state qj and generates the symbol sj | |