23
Languages Generated Languages Generated by Programmed by Programmed Grammars with Grammars with Various Graphs Various Graphs Jurgen Dassow, Benedek Nagy, Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Barbaiani, Szilard Fazekas, Aidan Delaney, Mihai Ionescu, Aidan Delaney, Mihai Ionescu, GuangWu Liu, Atif Lodhi GuangWu Liu, Atif Lodhi

Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Embed Size (px)

Citation preview

Page 1: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Languages Generated by Languages Generated by Programmed Grammars Programmed Grammars

with Various Graphswith Various Graphs

Jurgen Dassow, Benedek Nagy, Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Cristina Bibire, Madalina Barbaiani,

Szilard Fazekas, Aidan Delaney, Mihai Szilard Fazekas, Aidan Delaney, Mihai Ionescu, GuangWu Liu, Atif LodhiIonescu, GuangWu Liu, Atif Lodhi

Page 2: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A A programmed grammarprogrammed grammar is a quadruple is a quadruple

G=(N, T, S, P) where:G=(N, T, S, P) where:

N, T and S are specified as in a context-free grammar N, T and S are specified as in a context-free grammar andand

P is a finite set of triples r = (p, P is a finite set of triples r = (p, σσ, , φφ) where p is a ) where p is a context-free production and context-free production and σσ and and φφ are subsets of P are subsets of P ((σσ and and φφ are called the success field and the failure are called the success field and the failure field, respectively).field, respectively).

If the failure field of any rule in P is emptyIf the failure field of any rule in P is empty we we say that G is a programmed grammar without say that G is a programmed grammar without appearance checking. Otherwise G is a programmed appearance checking. Otherwise G is a programmed grammar with appearance checking.grammar with appearance checking.

Page 3: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

We will consider another interpretation of the We will consider another interpretation of the programmed grammars: as graphs. From now on, we programmed grammars: as graphs. From now on, we will consider only programmed grammars without will consider only programmed grammars without appearance checking.appearance checking.

Let G = (N, T, S, P) be a programmed Let G = (N, T, S, P) be a programmed grammar. We can construct a graph H=(P, E), where 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 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.only if r’ is one of the rules from the success field of r.

Page 4: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

ExampleExample LetLet

Note: because the order in which an edge binds two vertices does matter, in this presentation we will consider only directed graphs.

0 1 8, , , , , , , ...G S A B a b S r r r 0 1 3 5 8, , , , ,r S AB r r r r

1 2, ,r A aA r 2 1 3 5 8, , , , ,r B aB r r r r 4 1 3 5 8, , , , ,r B bB r r r r 3 4, ,r A bA r

5 6, ,r A a r 7 8, ,r A b r

6 , ,r B a 8 , ,r B b

*,L G ww w a b

Page 5: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

1r 2r

0r

3r 4r

8r

6r5r

7r

The corresponding graph is:The corresponding graph is:

Page 6: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

For a particular class of restricted graphs, one For a particular class of restricted graphs, one can determine which class of languages can be can determine which class of languages can be generated with it.generated with it.

Types of graphs that we had in mind:Types of graphs that we had in mind:

Complete graphsComplete graphs

Planar graphsPlanar graphs

Connected graphsConnected graphs

Eulerian graphsEulerian graphs

Hamiltonian graphs Hamiltonian graphs

Bipartite graphsBipartite graphs

Ring backbonesRing backbones

Graphs with limited degree ( ) Graphs with limited degree ( ) 2 , 3

Page 7: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Complete GraphsComplete 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.

Page 8: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Planar GraphsPlanar 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.

Page 9: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A → u

B → v

1 3

42

Page 10: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A → u

B → v

1 3

42

Page 11: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A → u

B → v

1 3

42

X → λ

Page 12: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A → u

B → v

3

42

B → BX

A → AX

1

X → λ

Page 13: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

A → u

B → v

3

42

B → BXA1

A1 → λA → AXA2

A2 → λ

1

X → λ

Page 14: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Connected GraphsConnected GraphsTheoremTheorem Any language obtained by a programmed Any language obtained by a programmed

grammar can be obtained by a programmed grammar grammar can be obtained by a programmed grammar with a connected graph.with a connected graph.

ProofProof: Consider the programmed grammar : Consider the programmed grammar associated with the graph . associated with the graph .

We define:We define:

- the union of all maximally connected - the union of all maximally connected subgraphs of containing at least one of the vertices subgraphs of containing at least one of the vertices from the set . from the set .

, ,SP r P r S w

, , ,G N T S P ,H P E

H

SP

,H P E

Page 15: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

We introduce a new terminal symbol , We introduce a new terminal symbol , which will be the new start symbol for our grammar and which will be the new start symbol for our grammar and we define .we define .

The grammar is a The grammar is a programmed grammar in which the associated graph is programmed grammar in which the associated graph is connected, and it generates the same language as connected, and it generates the same language as

, , ,G N S T S P

G

S N

, ,SP P S S P

S

1S w 2S wS S

Page 16: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Eulerian GraphsEulerian GraphsTheoremTheorem Any language obtained by a programmed grammar can Any language obtained by a programmed grammar can

be obtained by a programmed grammar with an eulerian graph.be obtained by a programmed grammar with an eulerian graph.

ProofProof: Let be a programmed grammar and : Let be a programmed grammar and

the associated graph. We denote the vertices by . the associated graph. We denote the vertices by .

A directed connected graph is eulerian if and only if for A directed connected graph is eulerian if and only if for every vertex, the in-degree equals the out-degree. every vertex, the in-degree equals the out-degree.

We will extend our graph to a new one by introducing the We will extend our graph to a new one by introducing the vertices where . The new non-vertices where . The new non-terminals are meant to block the undesired terminals are meant to block the undesired

derivations. derivations.

Our goal is to connect the old nodes to the new one such Our goal is to connect the old nodes to the new one such that the in-degree for each node equals the out-degree.that the in-degree for each node equals the out-degree.

1 2, ,... n 1 2, ,... nF F F

( , , , )G N T S P ,H P E

1 2, ,... n

, ,i i iS F

Page 17: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Put the new edges in the following way:Put the new edges in the following way:

1.1. For each connect the node to the node if and For each connect the node to the node if and only if there was not an edge from to . In this way all only if there was not an edge from to . In this way all vertices will have out-degree .vertices will have out-degree .

2.2. For each connect the node to the node if and For each connect the node to the node if and only if there was not an edge from to . In this way all only if there was not an edge from to . In this way all vertices will have in-degree .vertices will have in-degree .

In this way in our new graph, for all nodes , we have that In this way in our new graph, for all nodes , we have that the in-degree equals the out-degree. the in-degree equals the out-degree.

3.3. All we have to do now is to make sure that this property will All we have to do now is to make sure that this property will hold also for each . hold also for each .

, 1,i j n

, 1,i j n

ii j

i

ij

i

i

j

j

i

i

n

n

Page 18: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

The following property is true for any directed graph:The following property is true for any directed graph:

But we know that:But we know that:

From and we obtain:From and we obtain:

Connect any node which has higher in-degree than out-Connect any node which has higher in-degree than out-degree to any node having higher out-degree than in-degree to any node having higher out-degree than in-degree. In this way the number of in-degrees and out-degrees degree. In this way the number of in-degrees and out-degrees will increase both, and after finitely many steps (the difference will increase both, and after finitely many steps (the difference for any node is not more than n) each node will have equal for any node is not more than n) each node will have equal number of in- and out-degree. number of in- and out-degree.

1, deg degin i out ii n n

1 1

deg degn n

in i out ii i

i

i

i

1 1

deg deg deg degn n

in i in i out i out ii i

2

1

1 2

Page 19: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Hamiltonian GraphsHamiltonian Graphs

TheoremTheorem Any language obtained by a programmed Any language obtained by a programmed grammar can be obtained by a programmed grammar grammar can be obtained by a programmed grammar with an Hamiltonian graph.with an Hamiltonian graph.

ProofProof: Given a programmed grammar , let : Given a programmed grammar , let

( is the number of rules in ) be new non-( is the number of rules in ) be new non-terminal symbols which were not in . terminal symbols which were not in .

Let . We introduce new nodes:Let . We introduce new nodes:

and we connect each node to the node and we connect each node to the node

, , ,G N T S P

1 2, ,... nP

, 1,iF i n n PN

n

1

1

1, 1 , ,

( , , )

i i i

n n

i n S F

S F

i , 1,i i n

Page 20: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

2

1

1

n5

4

3

n

5

4

32

Page 21: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Other ResultsOther Results

Any language obtained by a programmed Any language obtained by a programmed grammar can be obtained by a programmed grammar can be obtained by a programmed grammar with a bipartite graph. grammar with a bipartite graph.

Any language obtained by a programmed Any language obtained by a programmed grammar can be obtained by a programmed grammar can be obtained by a programmed grammar with the graph having the nodes’ grammar with the graph having the nodes’ degree at most 3.degree at most 3.

Page 22: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan

Conclusions and Further ResearchConclusions 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.

Page 23: Languages Generated by Programmed Grammars with Various Graphs Jurgen Dassow, Benedek Nagy, Cristina Bibire, Madalina Barbaiani, Szilard Fazekas, Aidan