lonati@dsi.unimi.it pradella@elet.polimi · Violetta Lonati1,Matteo Pradella2 lonati@dsi.unimi.it,...

Post on 25-Aug-2020

12 views 0 download

transcript

Picture Recognizability with Automata Based on Wang Tiles

Violetta Lonati1, Matteo Pradella2

lonati@dsi.unimi.it,pradella@elet.polimi.it

(1) DSI, Universita degli studi di Milano(2) IEIIT, Consiglio Nazionale delle Ricerche

SOFSEM 2010.01.25 (Spindleruv Mlyn, Czech Rep.)

Outline

• Picture languages and class REC

• Wang Systems + example

• Determinism and scanning strategies

• Wang automata + example

• Properties, new results and open problems

2

Picture languages: class REC

• Seminal work on 2D languages:Dora Giammarresi and Antonio Restivo. Two-dimensional languages. Hand-book of Formal Languages, volume 3, Beyond Words, pages 215-267, 1997.

• Strings are 2D arrays of symbols, called pictures.

• REC is proposed by the authors as a 2D analogous of Regular languages -Tiling Systems, Online Tessellation Cellular Automata, Wang Systems are allequivalent formalisms.

3

Pictures

An example of bordered picture (conventionally, # marks borders)

p =

# # # # # # # # ## 1 0 0 0 0 0 1 ## 0 1 0 0 0 0 1 ## 0 0 1 0 0 0 1 ## 0 0 0 1 0 0 1 ## 0 0 0 0 1 0 1 ## 0 0 0 0 0 1 1 ## # # # # # # # #

Notation: the red pixel is at position (4, 2), i.e. p(4, 2) = 0.The size of p is |p| = (6, 7) (i.e. # of rows, columns).

4

Wang Systems (WS): a simple formalization of jigsaw puzzles

Introduced by de Prophetis, Varricchio (1997).

Every labeled Wang tile bears a central symbol (its label), and has four “colored”edges. To “compose” tiles, you have to match edges.

E.g.

# ## a D D a #

A CA C

# b B B a ## #

represents the picturea ab a

Given a set of tiles Θ, a picture p ∈ L(Θ) if it is possible to take tiles from Θ and builda picture p′ having label p. (It is possible to take a tile more than once, if needed.)

5

An example

Language Lhalf of pictures of size (n, 2n) with the first row like x x,where x is the reverse of x.

For example

p =

a b c c b ab b a c b ac a a b a a

6

WS of the example: main idea

To generate this kind of pictures, the idea is using tiles to “propagate” the symbolsfound in the first row, to check their consistency in the lower part of the tiled picture.

For example, if we have a at the top left corner, we propagate this information below,

with the tiles:#

# a ·

A,

A# ? ·

A(? stands for “don’t care”).

Then, when we reach the border, we propagate A towards east withA

# ? A#

,

·

A ? A#

. Last, we go back north:A

A ? ##

,A

· ? #A

, and check#

· a #A

.

7

Recognizing p with the WS

Hence, the information flows following nested “U-like” paths.

In the case of the example picture p, we obtain:

## a ·

A

#· b ·

B

#· c C·

#C c ·

·

#· b ·

B

#· a #

AA

# b ·

A

B· b B·

·

B a B·

·

B c B·

BB b ·

·

A· a #

AA

# c A#

·

A a A#

·

A a A#

·

A b A#

·

A a A#

AA a #

#

8

Determinism and scanning

WSs are implicitly non-deterministic: REC is not closed under complement and pars-ing is NP-complete.

It is natural to introduce some kind of scanning strategy, to define the order in whichpixels of the picture are visited (and then determinism)

The classical approach is the one used in Online Tessellation Automata, introducedby Inoue, Nakamura (’77) and recently generalized and studied by Anselmo, Gi-ammarresi, Madonia: Diagonal determinism

In this case, pictures are visited starting from a corner, and considering diagonals (or

counter-diagonals), e.g. following this order:1 2 4 73 5 8 106 9 11 12

9

Determinism and scanning: approaches in the literature

Recent approaches are the following:

• Tiling automata by Anselmo, Giammarresi, Madonia (CIAA 2007)

• Sudoku determinism by Borchert, Reinhardt (LATA 2007)

• Quilted snake tilings by Brijder, Hoogeboom (TCS 2009)

10

Scanning strategies

We consider here various kinds of strategies. The main properties that we requireare

• continuity: the next considered position must be adjacent to the previous one

• one-pass: each position is considered exactly once

• blind: it cannot “see” pixels, but can only “feel” borders and already consideredpositions

We will call polite any such kind of strategy.11

Examples of polite strategies

Snake:1

12

Examples of polite strategies

Snake:1 2

Examples of polite strategies

Snake:1 2 3

Examples of polite strategies

Snake:1 2 3 4

Examples of polite strategies

Snake:1 2 3 4

5

Examples of polite strategies

Snake:1 2 3 4

6 5

Examples of polite strategies

Snake:1 2 3 4

7 6 5

Examples of polite strategies

Snake:1 2 3 48 7 6 5

Examples of polite strategies

Snake:1 2 3 48 7 6 59

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10 11

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10 11 12

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10 11 12

Spiral:1 2 3 410 11 12 59 8 7 6

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10 11 12

Spiral:1 2 3 410 11 12 59 8 7 6

U-like:1 12 9 82 11 10 73 4 5 6

Examples of polite strategies

Snake:1 2 3 48 7 6 59 10 11 12

Spiral:1 2 3 410 11 12 59 8 7 6

U-like:1 12 9 82 11 10 73 4 5 6

L-like:1 2 3 410 9 8 511 12 7 6

We have recently proved that all possible polite strategies can be described in termsof these ones (submitted).

Wang automata (WA)

Wang automata are finite-state devices that follow some polite scanning strategy, tovisit the input picture.

During the visit of each pixel, WAs try to “color” the edges of the position, thus ob-taining an analogous of a labeled Wang tile.

The direction of movement of the head is given by the scanning strategy.

In a sense, colors and directions define the states of the automaton.

If the “coloring” is unique, then the automaton is deterministic (DWA).

13

An example run of a DWA with Lhalf

We consider picture p of the previous example, and a “U-like” polite strategy.

↓ ## a ⊥

→ #⊥ b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ ⊥

# b ⊥

↑ ⊥

⊥ b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ ⊥

# c ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

14

An example run of a DWA with Lhalf

Arrows represent next-position movements of the strategy:

↓ ## a ⊥

→ #⊥ b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ ⊥

# b ⊥

↑ ⊥

⊥ b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ ⊥

# c ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

The data structure starts like this (red marks the head position):

↓ ## a ⊥

→ #⊥ b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ ⊥

# b ⊥

↑ ⊥

⊥ b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ ⊥

# c ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ⊥

↑ ⊥

⊥ b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ ⊥

# c ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ A# c ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ A# c A

#

→ ⊥

A a ⊥

#

→ ⊥

⊥ a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ A# c A

#

→ ·

A a A#

→ ⊥

A a ⊥

#

→ ⊥

⊥ b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ⊥

A b ⊥

#

→ ⊥

⊥ a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← ⊥

⊥ b ⊥

↑ ⊥

⊥ a #⊥

→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ⊥

A a ⊥

#

↑ ⊥

⊥ a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← ⊥

⊥ b ⊥

·

↑ ⊥

⊥ a #⊥

→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ ⊥

A a ##

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #⊥

↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← ⊥

⊥ b ⊥

·

↑ ⊥

⊥ a #A

→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ⊥

← #⊥ a #

A↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← ⊥

⊥ b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

The symbol found under the head is compatible, so we continue...

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ⊥

↓ #⊥ b ·

← #· a #

A↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← ⊥

⊥ b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c ⊥

·

← B⊥ b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a ⊥

·

← ⊥

⊥ c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

→ #⊥ c ·

·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ ⊥

· b ⊥

·

← ⊥

⊥ a B·

← ·

B c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

→ #⊥ c ⊥

·

→ #⊥ c ·

·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ ⊥

· b B·

← ·

B a B·

← ·

B c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ⊥

B

→ #⊥ c ⊥

·

→ #⊥ c ·

·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ B· b B·

← ·

B a B·

← ·

B c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

Again, the found symbol is compatible...

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ·

B

→ #· c ⊥

·

→ #⊥ c ·

·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ B· b B·

← ·

B a B·

← ·

B c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

An example run of a DWA with Lhalf

↓ ## a ·

A

→ #· b ·

B

→ #· c C·

→ #C c ·

·

↓ #· b ·

B

← #· a #

A↓ A# b ·

A

↑ B· b B·

← ·

B a B·

← ·

B c B·

← BB b ·

·

↑ A· a #

A→ A# c A

#

→ ·

A a A#

→ ·

A a A#

→ ·

A b A#

→ ·

A a A#

↑ AA a #

#

so we accept.

Main properties

For every polite scanning strategy µ, we have:

• L(µ-WA) = REC

• L(µ-DWA) is a Boolean sub-class of REC

15

Properties of L(µ-DWA)

• L(Snake-DWA) = top-to-bottom unambiguous REC of Anselmo et al.

• L(Spiral-DWA) is closed under rotation

• L(Spiral-DWA) and L(Snake-DWA) are incomparable (submitted)

16

Scan-DREC

We call Scan-DREC the union of classes L(µ-DWA) over all polite strategies µ.

• Scan-DREC is closed under complement and rotation

• Diagonal Deterministic REC ⊂ Scan-DREC ⊂ REC

17

Open problems

Is Scan-DREC closed under union or intersection?

Is Scan-DREC properly contained in unambiguous REC?

Which are the relations among the various L(µ-DWA)?

Which is the relation between Scan-DREC and the class of languages recognizedby deterministic 4-way automata?

18