SlideShare a Scribd company logo
1 of 64
Download to read offline
Precedence Automata and Languages

                Violetta Lonati

                       `
        DSI - Universita degli studi di Milano



                  Joint work with
        Dino mandrioli and Matteo Pradella
            DEI - Politecnico di Milano


                   CSR 2011
Outline




Violetta Lonati - Precedence Automata and Languages - CSR 2011
Outline
Historical background (1)

        Floyd languages
                Operator precedence grammars, inspired by the structure of
                arithmetic expressions, and aimed at deterministic (hence
                efficient) parsing [Floyd 1963]
                Dyck languages and the fundamental theorem by Chomsky
                       ¨
                and Shutzemberger [1963]
                Parenthesis grammars [McNaughton 1967]
                Tree automata [Thatcher 1967]
                Some early investigation on the algebraic properties of
                operator precedence grammars and closure properties of
                context-free languages compared with regular languages
                [Crespi Reghizzi, Mandrioli and Martin 1978]


Violetta Lonati - Precedence Automata and Languages - CSR 2011               1 /1
Historical background (2)

        After 40 years and more
                Visibly Pushdown Languages [Alur and Madhusudan 2004]
                       suitable to model structured mark-up languages such as XML
                       and apply model checking techniques
                       closure 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 VPLs
                             and enjoy the same closure properties

                                                         [Crespi Reghizzi and Mandrioli 2009]

Violetta Lonati - Precedence Automata and Languages - CSR 2011                                  2 /1
Outline
Let’s start with an example


        We have an arithmetic expression

                                                       4+5×6

        we want to evaluate it respecting the precedence among operators




Violetta Lonati - Precedence Automata and Languages - CSR 2011             3 /1
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 × 6
                                                         30
                                                      34




Violetta Lonati - Precedence Automata and Languages - CSR 2011             3 /1
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 × 6
                                                         30
                                                      34
        It’s like we add some parentheses

                                                      4 + (5 × 6)




Violetta Lonati - Precedence Automata and Languages - CSR 2011             3 /1
How does the parsing work?
        Implicitly, we refer to a context-free grammar:



          S   →E
          E   →E+T
          E   →T ×n
          E   →n
          T   →T ×n
          T   →n




Violetta Lonati - Precedence Automata and Languages - CSR 2011   4 /1
How does the parsing work?
        Implicitly, we refer to a context-free grammar:
                                                                     S

          S   →E
          E   →E+T                                                   E
          E   →T ×n
          E   →n                                  n+n×n          E   +   T
          T   →T ×n
          T   →n                                                 n   T   ×   n

                                                                     n




Violetta Lonati - Precedence Automata and Languages - CSR 2011                   4 /1
How does the parsing work?
        Implicitly, we refer to a context-free grammar:
                                                                      S

          S   →E
          E   →E+T                                                    E
          E   →T ×n
          E   →n                                  n+n×n           E   +   T
          T   →T ×n
          T   →n                                                  n   T   ×   n

                                                                      n

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

                                                    n + (n × n)

Violetta Lonati - Precedence Automata and Languages - CSR 2011                    4 /1
How does the parsing work?
        Implicitly, we refer to a context-free grammar:
                                                                      S

          S   →E
          E   →E+T                                                    E
          E   →T ×n
          E   →n                                  n+n×n           E   +   T
          T   →T ×n
          T   →n                                                  n   T   ×   n

                                                                      n

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

                                                    n + (n × n)

Violetta Lonati - Precedence Automata and Languages - CSR 2011                    4 /1
How does the parsing work?
        Implicitly, we refer to a context-free grammar:

                                                                      S

          S   →E
          E   →E+T                                                    E
          E   →T ×n
          E   →n                                  n+n×n           E   +   T
          T   →T ×n
          T   →n                                                  n   T   ×   n

                                                                      n

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

                                                    n + (n × n)

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


        Whenever a parenthesis could be inserted between two symbol,
        we introduce a parentheses generator
                open-parentheses generator
                closed-parentheses generator
                no parentheses =
                               ˙
        If a     b we say that a yields precedence
        if a     b we say that a takes precedence

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




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

            Grammar
             S   →E
             E   →E+T
             E   →T ×n
             E   →n
             T   →T ×n
             T   →n




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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                      E      +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×

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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                      E      +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×        =
                       ˙

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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                      E      +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×        =
                       ˙

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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                      E      +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×        =
                       ˙

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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                       E     +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×        =
                       ˙

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

            Grammar
             S     →E
             E     →E+T                                          Derivation tree
             E     →T ×n
                                                                         S
             E     →n
             T     →T ×n
             T     →n                                                    E

            Precedence table                                      E      +         T
                        n          +           ×
                                                                   n     T         ×   n
               n

              +                                                          n

              ×        =
                       ˙

Violetta Lonati - Precedence Automata and Languages - CSR 2011                             6 /1
Operator precedence grammars, or Floyd grammars


                A CF grammar is an operator grammar if each right-hand
                side is not empty and no right-hand side contains two
                consecutive terminals. (Every grammar admits an equivalent
                operator precedence grammar.)
                An operator grammar is a operator-precedence grammar if
                there are no conflicts in its precedence matrix (given a pair of
                subsequent symbols, there is at most one parenthesis
                generator).

                                We name them Floyd grammar
                           in honour of their inventor Robert W. Floyd.




Violetta Lonati - Precedence Automata and Languages - CSR 2011                    7 /1
Outline
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.




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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 #




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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.



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




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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.



        3 kinds of moves, depending on the precedence relation between
        the symbol a on top of the stack and next input symbol b:
        push move when a b
                  b is pushed on the stack




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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.



        3 kinds of moves, depending on the precedence relation between
        the symbol a on top of the stack and next input symbol b:
        push move when a b
                  b is pushed on the stack
        mark move when a b
                  b is pushed on the stack




Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
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.



        3 kinds of moves, depending on the precedence relation between
        the symbol a on top of the stack and next input symbol b:
        push move when a b
                  b is pushed on the stack
        mark move when a b
                  b is pushed on the stack
        flush move when a b
                  symbols are popped from the stack until a marked
                  symbol is found; b is not consumed

Violetta Lonati - Precedence Automata and Languages - CSR 2011               8 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



                                                                     abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



                           [# q0 ]                                   abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           mark
                           [# q0 ]                                   abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



                           [# q0 ][a q1 ]                            abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           mark
                           [# q0 ][a q1 ]                            abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



                           [# q0 ][a q1 ]                            abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           push
                           [# q0 ][a q1 ]                            abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           mark
                           [# q0 ][a q1 ][a q1 ]                     abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           push
                           [# q0 ][a q1 ][a q1 ][a q1 ]              abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           flush
                           [# q0 ][a q1 ][a q1 ][a q1 ][a q1 ]       abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



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

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           flush
                           [# q0 ][a q1 ][a q1 ]                     abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙



                           [# q0 ]                                   abaabaaa #

Violetta Lonati - Precedence Automata and Languages - CSR 2011                           9 /1
An automata model for Floyd languages - example
           restart                                                                skip



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

                     a          a          b          b          #
            a                   =
                                ˙                                         a ,b
            a                                                        q0          q1      q1
            b                                         =
                                                      ˙                   q0

            b                                                              a, a, b , b

            #                                                    =
                                                                 ˙


           accept!
                           [# q0 ]                                   abaabaaa #

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


        Theorem
        It is easy to define a deterministic version of Floyd automata (as
        usual: require that the transition function is deterministic).
        Deterministic Floyd automata are equivalent to nondeterministic
        ones.

        Theorem
        Any language generated by a Floyd grammar can be recognized
        by a Floyd automaton.

        Theorem
        Any language recognized by a Floyd automaton can be generated
        by a Floyd grammar.



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


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

                         ¨
        The classical Buchi condition of acceptance can be adapted to
        FAs: an infinite word x is accepted if and only if configurations with
        stack [a qf ], where qf is final, occur infinitely often in the infinite
        computation on x.


        Example
        We can model the stack management of a simple programming
        language that is able to handle nested exceptions




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

                there are only two procedures, called a and b
                calls and returns are denoted by calla , callb , reta , retb
                during execution, it is possible to install an exception handler
                hnd
                signal rst is issued when an exception occur, or after a correct
                execution to uninstall the handler (with a rst the stack is
                “flushed”, restoring the state right before the last hnd).

               calla    reta     callb    retb    hnd     rst
      calla               =
                          ˙                                           call• , hnd
      reta
      callb                                =
                                           ˙                     q0                      q1      q1
      retb                                                                q0
      hnd                                                  =
                                                           ˙
       rst                                                                     call• , ret• , hnd , rst
        #


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

        Floyd grammars and languages
        deserve renewed attention in the realm of formal languages
                FL family properly includes VPL
                FL family enjoys all closure properties of VPL and regular
                languages

        Automaton
        that perfectly matches the generative power of FGs
                extension to Ω-languages

        Prototypical tool called Flup
        http://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
Further research




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


        Logic characterization
        In order to apply strong model checking techniques to this class of
        languages




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

More Related Content

More from CSR2011

Csr2011 june18 15_15_bomhoff
Csr2011 june18 15_15_bomhoffCsr2011 june18 15_15_bomhoff
Csr2011 june18 15_15_bomhoffCSR2011
 
Csr2011 june18 14_00_sudan
Csr2011 june18 14_00_sudanCsr2011 june18 14_00_sudan
Csr2011 june18 14_00_sudanCSR2011
 
Csr2011 june18 15_45_avron
Csr2011 june18 15_45_avronCsr2011 june18 15_45_avron
Csr2011 june18 15_45_avronCSR2011
 
Csr2011 june18 09_30_shpilka
Csr2011 june18 09_30_shpilkaCsr2011 june18 09_30_shpilka
Csr2011 june18 09_30_shpilkaCSR2011
 
Csr2011 june18 12_00_nguyen
Csr2011 june18 12_00_nguyenCsr2011 june18 12_00_nguyen
Csr2011 june18 12_00_nguyenCSR2011
 
Csr2011 june18 11_00_tiskin
Csr2011 june18 11_00_tiskinCsr2011 june18 11_00_tiskin
Csr2011 june18 11_00_tiskinCSR2011
 
Csr2011 june18 11_30_remila
Csr2011 june18 11_30_remilaCsr2011 june18 11_30_remila
Csr2011 june18 11_30_remilaCSR2011
 
Csr2011 june17 17_00_likhomanov
Csr2011 june17 17_00_likhomanovCsr2011 june17 17_00_likhomanov
Csr2011 june17 17_00_likhomanovCSR2011
 
Csr2011 june17 16_30_blin
Csr2011 june17 16_30_blinCsr2011 june17 16_30_blin
Csr2011 june17 16_30_blinCSR2011
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCSR2011
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCSR2011
 
Csr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCsr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCSR2011
 
Csr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCsr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCSR2011
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCSR2011
 
Csr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCsr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCSR2011
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCSR2011
 
Csr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCsr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCSR2011
 
Csr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCsr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCSR2011
 
Csr2011 june17 11_00_lonati
Csr2011 june17 11_00_lonatiCsr2011 june17 11_00_lonati
Csr2011 june17 11_00_lonatiCSR2011
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCSR2011
 

More from CSR2011 (20)

Csr2011 june18 15_15_bomhoff
Csr2011 june18 15_15_bomhoffCsr2011 june18 15_15_bomhoff
Csr2011 june18 15_15_bomhoff
 
Csr2011 june18 14_00_sudan
Csr2011 june18 14_00_sudanCsr2011 june18 14_00_sudan
Csr2011 june18 14_00_sudan
 
Csr2011 june18 15_45_avron
Csr2011 june18 15_45_avronCsr2011 june18 15_45_avron
Csr2011 june18 15_45_avron
 
Csr2011 june18 09_30_shpilka
Csr2011 june18 09_30_shpilkaCsr2011 june18 09_30_shpilka
Csr2011 june18 09_30_shpilka
 
Csr2011 june18 12_00_nguyen
Csr2011 june18 12_00_nguyenCsr2011 june18 12_00_nguyen
Csr2011 june18 12_00_nguyen
 
Csr2011 june18 11_00_tiskin
Csr2011 june18 11_00_tiskinCsr2011 june18 11_00_tiskin
Csr2011 june18 11_00_tiskin
 
Csr2011 june18 11_30_remila
Csr2011 june18 11_30_remilaCsr2011 june18 11_30_remila
Csr2011 june18 11_30_remila
 
Csr2011 june17 17_00_likhomanov
Csr2011 june17 17_00_likhomanovCsr2011 june17 17_00_likhomanov
Csr2011 june17 17_00_likhomanov
 
Csr2011 june17 16_30_blin
Csr2011 june17 16_30_blinCsr2011 june17 16_30_blin
Csr2011 june17 16_30_blin
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhanin
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhanin
 
Csr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCsr2011 june17 12_00_morin
Csr2011 june17 12_00_morin
 
Csr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCsr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyi
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
Csr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCsr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminski
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
Csr2011 june17 12_00_morin
Csr2011 june17 12_00_morinCsr2011 june17 12_00_morin
Csr2011 june17 12_00_morin
 
Csr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyiCsr2011 june17 11_30_vyalyi
Csr2011 june17 11_30_vyalyi
 
Csr2011 june17 11_00_lonati
Csr2011 june17 11_00_lonatiCsr2011 june17 11_00_lonati
Csr2011 june17 11_00_lonati
 
Csr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhaninCsr2011 june17 09_30_yekhanin
Csr2011 june17 09_30_yekhanin
 

Csr2011 june17 11_00_lonati

  • 1. Precedence Automata and Languages Violetta Lonati ` DSI - Universita degli studi di Milano Joint work with Dino mandrioli and Matteo Pradella DEI - Politecnico di Milano CSR 2011
  • 2. Outline Violetta Lonati - Precedence Automata and Languages - CSR 2011
  • 4. Historical background (1) Floyd languages Operator precedence grammars, inspired by the structure of arithmetic expressions, and aimed at deterministic (hence efficient) parsing [Floyd 1963] Dyck languages and the fundamental theorem by Chomsky ¨ and Shutzemberger [1963] Parenthesis grammars [McNaughton 1967] Tree automata [Thatcher 1967] Some early investigation on the algebraic properties of operator precedence grammars and closure properties of context-free languages compared with regular languages [Crespi Reghizzi, Mandrioli and Martin 1978] Violetta Lonati - Precedence Automata and Languages - CSR 2011 1 /1
  • 5. Historical background (2) After 40 years and more Visibly Pushdown Languages [Alur and Madhusudan 2004] suitable to model structured mark-up languages such as XML and apply model checking techniques closure 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 VPLs and enjoy the same closure properties [Crespi Reghizzi and Mandrioli 2009] Violetta Lonati - Precedence Automata and Languages - CSR 2011 2 /1
  • 7. Let’s start with an example We have an arithmetic expression 4+5×6 we want to evaluate it respecting the precedence among operators Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 /1
  • 8. 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 × 6 30 34 Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 /1
  • 9. 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 × 6 30 34 It’s like we add some parentheses 4 + (5 × 6) Violetta Lonati - Precedence Automata and Languages - CSR 2011 3 /1
  • 10. How does the parsing work? Implicitly, we refer to a context-free grammar: S →E E →E+T E →T ×n E →n T →T ×n T →n Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 /1
  • 11. How does the parsing work? Implicitly, we refer to a context-free grammar: S S →E E →E+T E E →T ×n E →n n+n×n E + T T →T ×n T →n n T × n n Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 /1
  • 12. How does the parsing work? Implicitly, we refer to a context-free grammar: S S →E E →E+T E E →T ×n E →n n+n×n E + T T →T ×n T →n n T × n n Suppose you have a method for inserting the proper parentheses into an expression . . . you get the stencil of the parsing tree n + (n × n) Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 /1
  • 13. How does the parsing work? Implicitly, we refer to a context-free grammar: S S →E E →E+T E E →T ×n E →n n+n×n E + T T →T ×n T →n n T × n n Suppose you have a method for inserting the proper parentheses into an expression . . . you get the stencil of the parsing tree n + (n × n) Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 /1
  • 14. How does the parsing work? Implicitly, we refer to a context-free grammar: S S →E E →E+T E E →T ×n E →n n+n×n E + T T →T ×n T →n n T × n n Suppose you have a method for inserting the proper parentheses into an expression . . . you get the stencil of the parsing tree n + (n × n) Violetta Lonati - Precedence Automata and Languages - CSR 2011 4 /1
  • 15. Precedence table Whenever a parenthesis could be inserted between two symbol, we introduce a parentheses generator open-parentheses generator closed-parentheses generator no parentheses = ˙ If a b we say that a yields precedence if a b we say that a takes precedence For each pair of symbols we determine the admissible parentheses generator and obtain the precedence table Violetta Lonati - Precedence Automata and Languages - CSR 2011 5 /1
  • 16. Precedence table - example Grammar S →E E →E+T E →T ×n E →n T →T ×n T →n Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 17. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 18. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × = ˙ Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 19. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × = ˙ Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 20. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × = ˙ Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 21. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × = ˙ Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 22. Precedence table - example Grammar S →E E →E+T Derivation tree E →T ×n S E →n T →T ×n T →n E Precedence table E + T n + × n T × n n + n × = ˙ Violetta Lonati - Precedence Automata and Languages - CSR 2011 6 /1
  • 23. Operator precedence grammars, or Floyd grammars A CF grammar is an operator grammar if each right-hand side is not empty and no right-hand side contains two consecutive terminals. (Every grammar admits an equivalent operator precedence grammar.) An operator grammar is a operator-precedence grammar if there are no conflicts in its precedence matrix (given a pair of subsequent symbols, there is at most one parenthesis generator). We name them Floyd grammar in honour of their inventor Robert W. Floyd. Violetta Lonati - Precedence Automata and Languages - CSR 2011 7 /1
  • 25. 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. Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 26. 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 Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 27. 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 # Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 28. 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. 3 kinds of moves, depending on the precedence relation between the symbol a on top of the stack and next input symbol b: Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 29. 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. 3 kinds of moves, depending on the precedence relation between the symbol a on top of the stack and next input symbol b: push move when a b b is pushed on the stack Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 30. 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. 3 kinds of moves, depending on the precedence relation between the symbol a on top of the stack and next input symbol b: push move when a b b is pushed on the stack mark move when a b b is pushed on the stack Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 31. 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. 3 kinds of moves, depending on the precedence relation between the symbol a on top of the stack and next input symbol b: push move when a b b is pushed on the stack mark move when a b b is pushed on the stack flush move when a b symbols are popped from the stack until a marked symbol is found; b is not consumed Violetta Lonati - Precedence Automata and Languages - CSR 2011 8 /1
  • 32. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 33. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 34. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ mark [# q0 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 35. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 36. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ mark [# q0 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 37. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 38. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ mark [# q0 ][a q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 39. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][b q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 40. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ push [# q0 ][a q1 ][b q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 41. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][b q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 42. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ flush [# q0 ][a q1 ][b q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 43. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 44. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ push [# q0 ][a q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 45. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][b q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 46. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ flush [# q0 ][a q1 ][b q1 ][b q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 47. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 48. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ push [# q0 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 49. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 50. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ mark [# q0 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 51. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 52. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ push [# q0 ][a q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 53. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][a q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 54. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ flush [# q0 ][a q1 ][a q1 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 55. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 56. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ flush [# q0 ][a q1 ][a q1 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 57. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ [# q0 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 58. An automata model for Floyd languages - example restart skip Dyck language of balanced string of parenthesis, with 2 pairs a , a and b , b. a a b b # a = ˙ a ,b a q0 q1 q1 b = ˙ q0 b a, a, b , b # = ˙ accept! [# q0 ] abaabaaa # Violetta Lonati - Precedence Automata and Languages - CSR 2011 9 /1
  • 59. Equivalence theorems Theorem It is easy to define a deterministic version of Floyd automata (as usual: require that the transition function is deterministic). Deterministic Floyd automata are equivalent to nondeterministic ones. Theorem Any language generated by a Floyd grammar can be recognized by a Floyd automaton. Theorem Any language recognized by a Floyd automaton can be generated by a Floyd grammar. Violetta Lonati - Precedence Automata and Languages - CSR 2011 10 / 1
  • 61. Ω-languages Having an operational model that defines FLs, it is now easy to introduce extensions to infinite words, i.e. to ω-languages. ¨ The classical Buchi condition of acceptance can be adapted to FAs: an infinite word x is accepted if and only if configurations with stack [a qf ], where qf is final, occur infinitely often in the infinite computation on x. Example We can model the stack management of a simple programming language that is able to handle nested exceptions Violetta Lonati - Precedence Automata and Languages - CSR 2011 11 / 1
  • 62. Ω-language - Example there are only two procedures, called a and b calls and returns are denoted by calla , callb , reta , retb during execution, it is possible to install an exception handler hnd signal rst is issued when an exception occur, or after a correct execution to uninstall the handler (with a rst the stack is “flushed”, restoring the state right before the last hnd). calla reta callb retb hnd rst calla = ˙ call• , hnd reta callb = ˙ q0 q1 q1 retb q0 hnd = ˙ rst call• , ret• , hnd , rst # Violetta Lonati - Precedence Automata and Languages - CSR 2011 12 / 1
  • 63. Conclusions Floyd grammars and languages deserve renewed attention in the realm of formal languages FL family properly includes VPL FL family enjoys all closure properties of VPL and regular languages Automaton that perfectly matches the generative power of FGs extension to Ω-languages Prototypical tool called Flup http://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
  • 64. Further research Parallel parsing FLs can be parsed without applying a strictly left-to-right order [Google grant] Logic characterization In order to apply strong model checking techniques to this class of languages Violetta Lonati - Precedence Automata and Languages - CSR 2011 14 / 1