Before reading the regular language, we should make clear the basic concepts of language and grammar.
first, the basic concept
- Language
first, a finite, non-empty symbol set σ is given, which becomes the alphabet .
A string of any character in the alphabet is a sentence , such as aaa,bbb, which is the σ * element.
The collection of these strings is a language , such as {aaa,bbb}, which is a subset of σ *.
To give an example:
σ={a,b}, then σ*={ε,a,b,aa,ab,bb,aaa,bbb, ...}, each element inside is a sentence, and the set {a,aa,bbb} is a language on σ because it has a finite number of sentences, so it is called a finite language. Set l={a?b?:n>=0} is also the language of σ, and the language is Infinite.
2. grammar
Grammar G is a four-tuple g= (v,t,s,p)
V: variable T: terminator S: start character, s∈t P: production Type
The formula can be used to know how a grammar converts a string into another string, as in the form of a x->y.
- What is the grammar used for?
Grammar is used to generate Language.
For example, in our natural language, the sentence patterns are:
S+v
S+v+o
Eg:he works very Hard. He took your bag.
The s,v,o in the inside is equivalent to the variable V, and the string in the sentence resembles the he,very equivalent to terminator, and the p-generation is equivalent to the sentence pattern.
v={s,v,o,...}
t={he,works,very,hard,...}
S=sentence
p={
Sentence->svo
S->he
V->works
O->hard
}
That is, set g=(v,t,s,p) is a grammar, then the set L (g) ={w∈t*:s*=>w} is the language of the grammar G generated, S through the multi-step derivation to obtain w, the derivation process of variables and terminator composed of strings as deduced sentence patterns, such as s-> aSb, in fact, This derivation process is a recursive process, in order to finally get a sentence, the need to s->ε as a termination condition, the final launch of a?b? The sentence Pattern.
- When several produce have the same left part, their right part can be written on the right side of the same production, separated by |, for example S->ASB| ε.
Basic concepts of language and grammar