On the Complexity of pure 2D Context-free Grammars Achille Frigeri - - PowerPoint PPT Presentation

on the complexity of pure 2d context free grammars
SMART_READER_LITE
LIVE PREVIEW

On the Complexity of pure 2D Context-free Grammars Achille Frigeri - - PowerPoint PPT Presentation

Complexity of (R)2DCFG On the Complexity of pure 2D Context-free Grammars Achille Frigeri Dipartimento di Matematica Francesco Brioschi Politecnico di Milano joint work Marcello M. Bersani & Alessandra Cherubini September 21, 2012


slide-1
SLIDE 1

Complexity of (R)2DCFG

On the Complexity of pure 2D Context-free Grammars

Achille Frigeri

Dipartimento di Matematica “Francesco Brioschi” Politecnico di Milano joint work Marcello M. Bersani & Alessandra Cherubini

September 21, 2012

slide-2
SLIDE 2

Complexity of (R)2DCFG Introduction

Initial motivations

One-dimensional languages - consolidated theory Two-dimensional languages

The theory is getting consolidated Various classes are known Regular languages are not really defined TS best candidate Expressiveness hierarchy is getting to be complete Sometimes, classes are not comparable

slide-3
SLIDE 3

Complexity of (R)2DCFG Introduction Plan

Motivations

Extend classes of languages Study new closures extending the theory Need for comparisons among classes - hierarchy Algorithm for parsing - complexity

slide-4
SLIDE 4

Complexity of (R)2DCFG Introduction Example of word

What is a two-dimensional language

Alphabet Σ of finite symbols Definition A bidimensional language L ⊆ Σ∗∗ is a set of two-dimensional arrays over alphabet Σ

L = cross of • over ⋄ Σ = {•, ⋄}

⋄ ⋄

⋄ ⋄ ⋄

⋄ ⋄

⋄ ⋄ ⋄

⋄ ⋄ ⋄

⋄ ⋄ ⋄

⋄ ⋄

slide-5
SLIDE 5

Complexity of (R)2DCFG Introduction Classes considered

Formalism defining languages

Automata Grammars Expressions Logic Algebra

slide-6
SLIDE 6

Complexity of (R)2DCFG Classes of languages considered Compositional classes

Local languages

L = squares with diagonal of •

  • ,
  • ,
  • , ...

Alphabet: Γ = {◦, •} ∪ {#} Local factors to build pictures:

  • ,
  • ,
  • ,
  • Boundaries (removed after construction):

# # #

  • ,

# #

  • ,

# #

  • # , ...
slide-7
SLIDE 7

Complexity of (R)2DCFG Classes of languages considered Compositional

Tiling Systems

Projection of Local languages: Local alphabet: Γ Final alphabet: Σ Projection: π : Γ → Σ

L = squares of ⋄ Γ = {•, ◦}, Σ = {⋄}

  • π:{◦→⋄,•→⋄}

− − − − − − − − − → ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄

Cannot be defined by local construction (π is needed).

slide-8
SLIDE 8

Complexity of (R)2DCFG Classes of languages considered Compositional

Comparison Tiling Systems - Local

LOC Tiling System Closures ∪, ∩

R-C concat rotation complement ∪, ∩ R-C concat rotation NOT complement

Membership P NP-complete Emptiness D U Other

EMSO, 2-way OTA, C-free REG exp

slide-9
SLIDE 9

Complexity of (R)2DCFG Classes of languages considered Grammars

How to classify grammars

Set of rules defined by terminals - alphabet constituting final pictures; T = {a, b} non terminals - intermediate alphabet realizing projection;

N = {A, B}

set of rules; A → aBa, ... Two classes: Isometric: rules do not modify the dimensions of the area on which they are applied

→ → . . .

Non-isometric: rules transform a starting axiom by means of successive expansions of its sub-pictures.

→ → . . .

slide-10
SLIDE 10

Complexity of (R)2DCFG Classes of languages considered Grammars

Regional Tile Grammars

Isometric grammars A sub-picture is substituted with an isometric sub-picture according to a rule of the grammar

N = {•, •, •, •}

  • , ...

A “blue” area of • is replaced with an isometric subpicture of the form defined on the right.

  • rule

− − − →

slide-11
SLIDE 11

Complexity of (R)2DCFG Classes of languages considered

Pr˚ uˇ sa grammar

Non-Isometric grammars A non-terminal is substituted with a sub-picture according to a rule of the grammar

N = {•, •, •}, T = {•}

  • |
  • , ...

Each non-terminal is substituted with the subpicture defined on the right.

·

  • ·
  • ·

· → ·

  • ·
  • ·

·

slide-12
SLIDE 12

Complexity of (R)2DCFG Classes of languages considered Grammars

(R)P2DCFL

(Regularly controlled) Pure 2D Context-free Grammar

  • Pure: non-terminals not allowed
  • Tables of row/column rules

strictly separated arbitrarily applied on the picture sequence of rule can be controlled by a regular language c:

y → x y x z → b z b

, r:

x → x b | x c y → y z

Derivation:

y

c

− → x y x

r

− → x y x b z c

c

− → x x y x x b b z b c

slide-13
SLIDE 13

Complexity of (R)2DCFG Classes of languages considered Grammars

(R)P2DCFL

Language of squares of • c:

  • , r:
  • Since each derivation is legal, we need a control language
  • ver the alphabet of rules

L = (cr)∗

  • c

− →

  • r

− →

  • cr

− →

  • Note that a P2DCFG is a RP2DCFG with control Γ ∗
slide-14
SLIDE 14

Complexity of (R)2DCFG Classes of languages considered Comparisons of grammar

Comparison Regional - Pr˚ uˇ sa - (R)P2DCFL

RTG Pr˚ uˇ sa (R)P2DCFL Closures ∪

R/C • Rotation Projection ∪, ∩ R-C concat rotation NOT complement Transposition Reflection NOT ∪P and R/C ◦ ∪R, NOT ∩P

P P PP,1, PR,1 NPP,5, NPR,2 Emptiness ? ? trivial Other Normal form Normal form Normal form

slide-15
SLIDE 15

Complexity of (R)2DCFG Result Normal form

Normal form

Definition A (R)P2DCFG is in normal form if all productions have the form

a → α or a → tβ with |α| = |β| = 2.

Remark! Pure grammars do not have normal form! Theorem Each P2DCF and RP2DCF grammar is equivalent to a RP2DCFG in normal form. Example

ci : a → abcd      c1

i : a → aα1

c2

i : α1 → bα2

c3

i : α2 → cd

slide-16
SLIDE 16

Complexity of (R)2DCFG Result Parsing complexity

Parsing P2DCFL

Theorem The general problem of the membership of a picture into a language generated by a P2DCFG is NP-complete.

Φ = (x1 ∨ x2 ∨ ¬x4) ∧ (x2 ∨ ¬x3 ∨ ¬x4) ∧ (¬x1 ∨ ¬x3 ∨ x4) pΦ = P M N P P M M N N N N P

x1=1,x3=0,x4=1

− − − − − − − − − − → 1 M − − M M 1 1 1

Also, x1 = 0, x2 = 0, x4 = 1 and ...

slide-17
SLIDE 17

Complexity of (R)2DCFG Result Parsing complexity

We define a P2DCF grammar G generating the smallest set of pictures over the alphabet {P, N, M} which correspond to satisfiable CNF formulae:

pΦ ∈ L(G) iff Φ is satisfiable

generate the truth table of a satisfiable formula with n clauses

  • ver m literals/variables

each column has at least one 1

p{0,1,M} = C1 C2 . . . Cn l(x1) · M · l(x2) 1 · 1

. . .

l(xm) · 1 M

slide-18
SLIDE 18

Complexity of (R)2DCFG Result Parsing complexity

build a formula which has p{0,1,M} as truth table

C1 C2 . . . Cn l(x1) · M · l(x2) P · P

. . .

l(xm) · · M C1 C2 . . . Cn x1 · M · x2 N · · N

. . .

xm · · M x2 → 1 ¬x2 → 1

slide-19
SLIDE 19

Complexity of (R)2DCFG Result Parsing complexity

Parsing P2DCFL over unary alphabet

Theorem The parsing of a language generated by a pure 2D context free grammar with unary alphabet is in P . Parsing problem system of two Diophantine equations.

h1x1 + h2x2 + · · · + htxt = n

If gcd(h1, . . . , ht) = 1, every n C can be written as a conical combination of h1, . . . , ht

slide-20
SLIDE 20

Complexity of (R)2DCFG Result Parsing complexity

Example

G = ({a}, {c : a → a3 | a6}, {r : a → (a2)t | (a7)t}, a(2,3)).

Deciding a(n,m) ∈ L(G) amounts to verifying

  • xc1(3 − 1) + xc2(6 − 1) = n − 3

yr1(2 − 1) + yr2(7 − 1) = m − 2

has solutions xci, yri 0.

slide-21
SLIDE 21

Complexity of (R)2DCFG Result Parsing complexity

Parsing RP2DCFL over (at least) binary alphabet

Theorem The general problem of the membership of a picture to a language generated by a RP2DCFG with (at least) two symbols is NP-complete. Definition Let {S1, . . . Sn} be a family of finite sets and C ⊆ {S1, . . . Sn}. We say that C is a k-set-covering for n

i=1 Si when

  • Sj∈C Sj = n

i=1 Si and |C| k. The set-covering problem is

defined for a family {S1, . . . Sn} and with respect to a positive integer k and it requires to check whether there exists a

k-set-covering for {S1, . . . Sn}.

We define a RP2DCF grammar defining the language of pictures representing family of sets S = {S1, . . . , Sn} which are

k-set-covering of n

i=1 Si = s1, s2, . . . , sm

slide-22
SLIDE 22

Complexity of (R)2DCFG Result Parsing complexity

Parsing RP2DCFL over (at least) binary alphabet

S = {S1, . . . , Sn}, n

i=1 Si = σ1, σ2, . . . , σm

pS = σ1 σ2 . . . σm S1 ∗ X ∗ S2 X ∗ X

. . .

Sn X ∗ ∗

slide-23
SLIDE 23

Complexity of (R)2DCFG Result Parsing complexity

Generating a picture is in two phase and ruled by rk−1(r1 + r2) build a k-cover of n

i=1 Si

r : {X → tα, ∗ → tβ | α ∈ {∗X | X∗ | X2}, β ∈ Σ2} X X X

r

− → X ∗ X ∗ X X

freely add rows without altering the k-cover by r1, r2

r1 : {X → tα, ∗ → tβ | α ∈ {X∗ | X2}, β ∈ Σ2}

slide-24
SLIDE 24

Complexity of (R)2DCFG Result Parsing complexity

Summary on parsing

P2DCF RP2DCF

|Σ| = 1 P P |Σ| = 2

?

NP-c 3 |Σ| 4

?

NP-c |Σ| 5 NP-c NP-c

slide-25
SLIDE 25

Complexity of (R)2DCFG Result Some closure for (R)P2DCFL

Some closure for (R)P2DCFL - projection

Projection may change the expressiveness of the class of languages of P2DCFG (also RP2DCFG) Theorem Let G = (Σ, Pc, Pr, S) be a P2DCFG and let π be a projection from the alphabet Σ to the alphabet ∆. Then π(L(G)) is a subset of the language generated by a P2DCFG G such that

π(L(G)) = L(G) ∩ ∆++.

In general, projection requires a non-regular control language.

slide-26
SLIDE 26

Complexity of (R)2DCFG Result Some closure for (R)P2DCFL

Some closure for (R)P2DCFL - union

RP2DCFG is closed under union. Theorem Let G1

r = (G1, Γ1, C1) and G2 r = (G2, Γ2, C2) be two RP2DCFG.

Then, the language L(G1

r) ∪ L(G2 r) is RP2DCFL.

tag the productions tables the control language of L(G1

r) ∪ L(G2 r) is the union of C1, C2

(over tagged symbols)

slide-27
SLIDE 27

Complexity of (R)2DCFG Result Some closure for (R)P2DCFL

Some closure for (R)P2DCFL - Intersection

Theorem The family of P2DCFL is not closed under intersection.

Lsquare(a) = Lrect(a) ∩ L

where L = Lsquare(a) ∪ Lspurious is a language containing squares of a rectangles defined over {a, b, c, d} (b, c, d are symbols generating squares but not used along with a control language)

slide-28
SLIDE 28

Complexity of (R)2DCFG Comparisons

LOC, (R)P2DCFG, RTG & Pr˚ uˇ sa

LOC and P2DCFG: incomparable & nonempty intersection LOC∩RP2DCFG∩Pr˚ uˇ sa= ∅ RP2DCFG∩Pr˚ uˇ saLOC RP2DCFG, Pr˚ uˇ sa (RTG): incomparable

slide-29
SLIDE 29

Complexity of (R)2DCFG Conclusion

Future works

Complete membership hierarchy for (R)P2DCFL

when membership is in P, RTG ∩ (R)P2DCFL ⊆ PG?

P2DCFL ∩ P2DCFL

?

∼ (R)P2DCFL

Family of automata recognizing (R)P2DCFL Other closures

concatenation of RP2DCFL