csr2011 june17 11_00_lonati

64
Precedence Automata and Languages Violetta Lonati DSI - Universit` a degli studi di Milano Joint work with Dino mandrioli and Matteo Pradella DEI - Politecnico di Milano CSR 2011

Upload: csr2011

Post on 11-May-2015

364 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Csr2011 june17 11_00_lonati

Precedence Automata and Languages

Violetta Lonati

DSI - Universita degli studi di Milano

Joint work withDino mandrioli and Matteo Pradella

DEI - Politecnico di Milano

CSR 2011

Page 2: Csr2011 june17 11_00_lonati

Outline

Violetta Lonati - Precedence Automata and Languages - CSR 2011

Page 3: Csr2011 june17 11_00_lonati

Outline

Page 4: Csr2011 june17 11_00_lonati

Historical background (1)

Floyd languages

Operator precedence grammars, inspired by the structure ofarithmetic expressions, and aimed at deterministic (henceefficient) parsing [Floyd 1963]

Dyck languages and the fundamental theorem by Chomskyand Shutzemberger [1963]

Parenthesis grammars [McNaughton 1967]

Tree automata [Thatcher 1967]

Some early investigation on the algebraic properties ofoperator precedence grammars and closure properties ofcontext-free languages compared with regular languages[Crespi Reghizzi, Mandrioli and Martin 1978]

Violetta Lonati - Precedence Automata and Languages - CSR 2011 1 / 1

Page 5: Csr2011 june17 11_00_lonati

Historical background (2)

After 40 years and more

Visibly Pushdown Languages [Alur and Madhusudan 2004]suitable to model structured mark-up languages such as XMLand apply model checking techniquesclosure properties of regular languages (boolean,concatenation, kleene ∗, . . . )

various related familes have been then defined and studied[Nowotka and Srba 2007, Caucal 2008]

FLs are back

FLs actually include VPLsand enjoy the same closure properties

[Crespi Reghizzi and Mandrioli 2009]

Violetta Lonati - Precedence Automata and Languages - CSR 2011 2 / 1

Page 6: Csr2011 june17 11_00_lonati

Outline

Page 7: Csr2011 june17 11_00_lonati

Let’s start with an example

We have an arithmetic expression

4 + 5 × 6

we want to evaluate it respecting the precedence among operators

4 + 5 × 630

34

It’s like we add some parentheses(4 + (5 × 6)

)

Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 / 1

Page 8: Csr2011 june17 11_00_lonati

Let’s start with an example

We have an arithmetic expression

4 + 5 × 6

we want to evaluate it respecting the precedence among operators

4 + 5 × 630

34

It’s like we add some parentheses(4 + (5 × 6)

)

Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 / 1

Page 9: Csr2011 june17 11_00_lonati

Let’s start with an example

We have an arithmetic expression

4 + 5 × 6

we want to evaluate it respecting the precedence among operators

4 + 5 × 630

34

It’s like we add some parentheses(4 + (5 × 6)

)

Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 / 1

Page 10: Csr2011 june17 11_00_lonati

How does the parsing work?

Implicitly, we refer to a context-free grammar:

S → EE → E + TE → T × nE → nT → T × nT → n

n + n × n

S

E

E

n

+ T

T

n

× n

Suppose you have a method for inserting the proper parenthesesinto an expression . . . you get the stencil of the parsing tree(

n + (n × n))

Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 / 1

Page 11: Csr2011 june17 11_00_lonati

How does the parsing work?

Implicitly, we refer to a context-free grammar:

S → EE → E + TE → T × nE → nT → T × nT → n

n + n × n

S

E

E

n

+ T

T

n

× n

Suppose you have a method for inserting the proper parenthesesinto an expression . . . you get the stencil of the parsing tree(

n + (n × n))

Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 / 1

Page 12: Csr2011 june17 11_00_lonati

How does the parsing work?

Implicitly, we refer to a context-free grammar:

S → EE → E + TE → T × nE → nT → T × nT → n

n + n × n

S

E

E

n

+ T

T

n

× n

Suppose you have a method for inserting the proper parenthesesinto an expression . . . you get the stencil of the parsing tree(

n + (n × n))

Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 / 1

Page 13: Csr2011 june17 11_00_lonati

How does the parsing work?

Implicitly, we refer to a context-free grammar:

S → EE → E + TE → T × nE → nT → T × nT → n

n + n × n

S

E

E

n

+ T

T

n

× n

Suppose you have a method for inserting the proper parenthesesinto an expression . . . you get the stencil of the parsing tree(

n + (n × n))

Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 / 1

Page 14: Csr2011 june17 11_00_lonati

How does the parsing work?

Implicitly, we refer to a context-free grammar:

S → EE → E + TE → T × nE → nT → T × nT → n

n + n × n

S

E

E

n

+ T

T

n

× n

Suppose you have a method for inserting the proper parenthesesinto an expression . . . you get the stencil of the parsing tree(

n + (n × n))

Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 / 1

Page 15: Csr2011 june17 11_00_lonati

Precedence table

Whenever a parenthesis could be inserted between two symbol,we introduce a parentheses generator

open-parentheses generator l

closed-parentheses generator m

no parentheses =

If a l b we say that a yields precedenceif a m b we say that a takes precedence

For each pair of symbols we determine the admissibleparentheses generator and obtain the precedence table

Violetta Lonati - Precedence Automata and Languages - CSR 2011 5 / 1

Page 16: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

= =

+

=

×

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 17: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

= =

+

=

×

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 18: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

= =

+

=

× =

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 19: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

= =

+ l

=

× =

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 20: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

=

m

=

+ l

=

× =

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 21: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

=

m m

=

+ l

=

× =

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 22: Csr2011 june17 11_00_lonati

Precedence table - example

Grammar

S → EE → E + TE → T × nE → nT → T × nT → n

Precedence table

n + ×

n

=

m m

=

+ l m l

=

× =

=

= = =

Derivation tree

S

E

E

n

+ T

T

n

× n

Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 / 1

Page 23: Csr2011 june17 11_00_lonati

Operator precedence grammars, or Floyd grammars

A CF grammar is an operator grammar if each right-handside is not empty and no right-hand side contains twoconsecutive terminals. (Every grammar admits an equivalentoperator precedence grammar.)

An operator grammar is a operator-precedence grammar ifthere are no conflicts in its precedence matrix (given a pair ofsubsequent symbols, there is at most one parenthesisgenerator).

We name them Floyd grammarin honour of their inventor Robert W. Floyd.

Violetta Lonati - Precedence Automata and Languages - CSR 2011 7 / 1

Page 24: Csr2011 june17 11_00_lonati

Outline

Page 25: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant:

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 26: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a′ q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant: the symbol may be marked

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 27: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ # q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant: special starting symbol #

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 28: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant:

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 29: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant:

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 30: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant:

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 31: Csr2011 june17 11_00_lonati

Automata for Floyd languages

The stack alphabet consists of pairs [ a q ] where

a is a symbol from the input alphabet (sort of),

q is a state.

Variant:

3 kinds of moves, depending on the precedence relation betweenthe symbol a on top of the stack and next input symbol b:

push move when a bb is pushed on the stack

mark move when a l bb ′ is pushed on the stack

flush move when a m bsymbols are popped from the stack until a markedsymbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 / 1

Page 32: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 33: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 34: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

mark

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 35: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 36: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

mark

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 37: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 38: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

mark

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 39: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 40: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

push

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 41: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 42: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

flush

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 43: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 44: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

push

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 45: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][b q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 46: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

flush

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][b ′ q1][b q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 47: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 48: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

push

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 49: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 50: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

mark

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 51: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 52: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

push

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1][a′ q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 53: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 54: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

flush

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 55: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 56: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

flush

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0][a′ q1][a q1] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 57: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 58: Csr2011 june17 11_00_lonati

An automata model for Floyd languages - examplerestart skip

Dyck language of balanced string of parenthesis,with 2 pairs a, a and b , b.

a a b b #

a l = l

a l m l m m

b l l =

b l m l m m

# l l =

q0 q1

a , b

a , a , b , b

q1q0

accept!

[# q0][a′ q1][b ′ q1][a′ q1][a q1]

[# q0] abaabaaa#

Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 / 1

Page 59: Csr2011 june17 11_00_lonati

Equivalence theorems

TheoremIt is easy to define a deterministic version of Floyd automata (asusual: require that the transition function is deterministic).Deterministic Floyd automata are equivalent to nondeterministicones.

TheoremAny language generated by a Floyd grammar can be recognizedby a Floyd automaton.

TheoremAny language recognized by a Floyd automaton can be generatedby a Floyd grammar.

Violetta Lonati - Precedence Automata and Languages - CSR 2011 10 / 1

Page 60: Csr2011 june17 11_00_lonati

Outline

Page 61: Csr2011 june17 11_00_lonati

Ω-languages

Having an operational model that defines FLs, it is now easy tointroduce extensions to infinite words, i.e. to ω-languages .

The classical Buchi condition of acceptance can be adapted toFAs: an infinite word x is accepted if and only if configurations withstack [a qf ], where qf is final, occur infinitely often in the infinitecomputation on x.

ExampleWe can model the stack management of a simple programminglanguage that is able to handle nested exceptions

Violetta Lonati - Precedence Automata and Languages - CSR 2011 11 / 1

Page 62: Csr2011 june17 11_00_lonati

Ω-language - Example

there are only two procedures, called a and b

calls and returns are denoted by calla , callb , reta , retbduring execution, it is possible to install an exception handlerhnd

signal rst is issued when an exception occur, or after a correctexecution to uninstall the handler (with a rst the stack is“flushed”, restoring the state right before the last hnd).

calla reta callb retb hnd rstcalla l = l l mreta l m l m mcallb l l = l mretb l m l m mhnd l l l l =rst m m m m# l l l

q0 q1

call•, hnd

q1

call•, ret•, hnd, rst

q0

Violetta Lonati - Precedence Automata and Languages - CSR 2011 12 / 1

Page 63: Csr2011 june17 11_00_lonati

Conclusions

Floyd grammars and languagesdeserve renewed attention in the realm of formal languages

FL family properly includes VPL

FL family enjoys all closure properties of VPL and regularlanguages

Automatonthat perfectly matches the generative power of FGs

extension to Ω-languages

Prototypical tool called Fluphttp://home.dei.polimi.it/pradella

interpreter for non-deterministic Floyd Automata

FG to Floyd Automata translator

Violetta Lonati - Precedence Automata and Languages - CSR 2011 13 / 1

Page 64: Csr2011 june17 11_00_lonati

Further research

Parallel parsingFLs can be parsed without applying a strictly left-to-right order[Google grant]

Logic characterizationIn order to apply strong model checking techniques to this class oflanguages

Violetta Lonati - Precedence Automata and Languages - CSR 2011 14 / 1