Are meant to overcome the limits of regexp
Are composed by:
A language can be defined by rules that after multiple applications allow to generates all and only the phrases in the language
Language $$L={uu^R|u\in {a,b}^}={\varepsilon,aa,bb,abba,baab,...,abbbba,...}$$ Grammar rules $\text{frase}\rightarrow \varepsilon$ - The empty string is a valid phrase $\text{frase}\rightarrow a\;\text{frase}\;a$ - A phrase encloses in a, a it's a phrase $\text{frase}\rightarrow b\;\text{frase}\;b$ - A phrase encloses in b, b it's a phrase <!----> Derivation chain $$\text{frase}\Rightarrow a\;\text{frase}\;a$$ Lista, frase are non-terminal symbols
The metalanguage of regular expressions
alphabet $\Sigma_{r.e.}={a,b,\cup,,\emptyset,(,)}$ <!----> syntax $1.\;espr \rightarrow\emptyset$ $2.\;espr \rightarrow a$ $3.\;espr \rightarrow b$ $4.\;espr \rightarrow (espr\cup espr)$ $5.\;espr \rightarrow (espr\;espr)$ $6.\;espr \rightarrow (espr)^$ <!---->
Is defined using four entities
Each rule $P$ is a pair $(X,\alpha)$ of:
Some examples are:
A grammar is in reduced form or simply reduced if both the following conditions hold:
Phase 1
In every iteration of the first phase, two events are possible:
The non-terminal symbols that belong to the $UNDEF$ set can be eliminated along with the rules where they appear.
Phase 2
The identification of the non-terminal symbols that are reachable starting from the axiom $S$ can be reduced to the problem of the existence of a path in the graph associated with the following binary relation produce
$A\overset{produce}{\rightarrow}B \;\;\text{if and only if} \;\;A\rightarrow\alpha B\beta \;\;\text{with}\;\;A\neq B\;\;\;\alpha,\beta\;\text{are any strings}$
The non-terminal $C$ is reachable from the axiom $S$ if and only if the graph of the binary relation produce contains a path from $S$ to $C$
A third property is often required for a grammar to be in the reduced form:
The grammar G may not have circular derivations, which are inessential and moreover give raise to ambiguity
$${S\rightarrow a,\;A\rightarrow b}\;\text{reduced to}\;{S\rightarrow a}$$
To generate an infinite language, composed of an infinite number of strings, it is necessary to allow derivations of unbounded length, this is called recursive grammar
$$A\overset{n}{\Rightarrow}xAy\;\;n\ge 1\;\;\text{is recursive}$$
Necessary and sufficient condition for a language $L(G)$ to be infinite:
where $G$ is a grammar in the reduced form and does not have any circular derivations, is that $G$ admits recursive derivations
A grammar does not contain recursion (or is recursion-free) if and only if the graph of the binary relation produce is acyclic