230 likes | 248 Views
Explore the classification of programmed grammars as graphs and their impact on language generation, including complete, planar, connected, Eulerian, Hamiltonian, bipartite graphs, and more.
E N D
Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan Delaney, Mihai Ionescu, GuangWu Liu, Atif Lodhi
A programmed grammar is a quadruple G=(N, T, S, P) where: • N, T and S are specified as in a context-free grammar and • P is a finite set of triples r = (p, σ, φ) where p is a context-free production and σ and φ are subsets of P (σ and φ are called the success field and the failure field, respectively). If the failure field of any rule in P is empty we say that G is a programmed grammar without appearance checking. Otherwise G is a programmed grammar with appearance checking.
We will consider another interpretation of the programmed grammars: as graphs. From now on, we will consider only programmed grammars without appearance checking. Let G = (N, T, S, P) be a programmed grammar. We can construct a graph H=(P, E), where P is the set of rules from G and (r, r’) is in E if and only if r’ is one of the rules from the success field of r.
For a particular class of restricted graphs, one can determine which class of languages can be generated with it. Types of graphs that we had in mind: • Complete graphs • Planar graphs • Connected graphs • Eulerian graphs • Hamiltonian graphs • Bipartite graphs • Ring backbones • Graphs with limited degree ( )
Complete Graphs Theorem The language obtained by a programmed grammar in which the corresponding graph is a complete one is context-free. Proof: We know that the rules in a programmed grammar are all context-free. A complete graph is simply telling us that each rule of the grammar can be followed (in the derivation) by any of the other rules. That reduces the power of the given programmed grammar to an arbitrary context-free grammar.
Planar Graphs Theorem All languages obtained by a programmed grammar can be obtained by a programmed grammar using a planar graph. Proof: Planar graphs are graphs which can be drawn in such a way that their edges do not intersect each other, so our task here is to avoid the intersections without altering the generated language. It suffices to consider a simpler case, with only four vertices. We will apply this algorithm to all the other intersections from the graph.
A → u B → v
A → u B → v
A → u X → λ B → v
A → u B → BX X → λ A → AX B → v
A → u B → BXA1 A2→ λ X → λ A → AXA2 A1→ λ B → v
Connected Graphs Theorem Any language obtained by a programmed grammar can be obtained by a programmed grammar with a connected graph. Proof: Consider the programmed grammar associated with the graph . We define: • - the union of all maximally connected subgraphs of containing at least one of the vertices from the set .
We introduce a new terminal symbol , which will be the new start symbol for our grammar and we define . The grammar is a programmed grammar in which the associated graph is connected, and it generates the same language as
Eulerian Graphs Theorem Any language obtained by a programmed grammar can be obtained by a programmed grammar with an eulerian graph. Proof: Let be a programmed grammar and the associated graph. We denote the vertices by . A directed connected graph is eulerian if and only if for every vertex, the in-degree equals the out-degree. We will extend our graph to a new one by introducing the vertices where . The new non-terminals are meant to block the undesired derivations. Our goal is to connect the old nodes to the new one such that the in-degree for each node equals the out-degree.
Put the new edges in the following way: • For each connect the node to the node if and only if there was not an edge from to . In this way all vertices will have out-degree . • For each connect the node to the node if and only if there was not an edge from to . In this way all vertices will have in-degree . In this way in our new graph, for all nodes , we have that the in-degree equals the out-degree. • All we have to do now is to make sure that this property will hold also for each .
The following property is true for any directed graph: But we know that: From and we obtain: Connect any node which has higher in-degree than out-degree to any node having higher out-degree than in-degree. In this way the number of in-degrees and out-degrees will increase both, and after finitely many steps (the difference for any node is not more than n) each node will have equal number of in- and out-degree.
Hamiltonian Graphs Theorem Any language obtained by a programmed grammar can be obtained by a programmed grammar with an Hamiltonian graph. Proof: Given a programmed grammar , let ( is the number of rules in ) be new non-terminal symbols which were not in . Let . We introduce new nodes: and we connect each node to the node
Other Results • Any language obtained by a programmed grammar can be obtained by a programmed grammar with a bipartite graph. • Any language obtained by a programmed grammar can be obtained by a programmed grammar with the graph having the nodes’ degree at most 3.
Conclusions and Further Research Combining our constructive proofs one can generate any language obtained by a programmed grammar without appearance checking with a connected planar graph having nodes degree at most 3. There are some related open questions, for example what is the language family generated by programmed grammars such a way that there is a word which is generated by a Hamiltonian or Eulerian trail/cycle.