Nested Word Automata and Computability

S Gaurang, Pranshu Gaba

Indian Institute of Science, Bangalore

November 16, 2018 Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Proper fragment of deterministic CFL’s More expressive than regular languages Nice closure properties

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Motivation More expressive than regular languages Nice closure properties

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Motivation

Proper fragment of deterministic CFL’s Nice closure properties

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Motivation

Proper fragment of deterministic CFL’s More expressive than regular languages Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Motivation

Proper fragment of deterministic CFL’s More expressive than regular languages Nice closure properties Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Motivation

Proper fragment of deterministic CFL’s More expressive than regular languages Nice closure properties Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Nested words only go forward: if i j, then i j; No two nested edges share a position: For i , there is at most one position h such that↝h i and< at most one position j such that i j; −∞ < < ∞ A position cannot be both a call and a↝ return. ↝ Nesting edges never cross: if i j, and i j , then it is not the case that i i j j . ′ ′ ′ ′ ↝ ↝ < ≤ <

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A matching relation of length ` 0 is a subset of , 1, 2, 3, . . . , ` 1, 2, 3, . . . , `, such that: ↝ ≥ {−∞ } × { +∞} No two nested edges share a position: For i , there is at most one position h such that h i and at most one position j such that i j; −∞ < < ∞ A position cannot be both a call and a↝ return. ↝ Nesting edges never cross: if i j, and i j , then it is not the case that i i j j . ′ ′ ′ ′ ↝ ↝ < ≤ <

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A matching relation of length ` 0 is a subset of , 1, 2, 3, . . . , ` 1, 2, 3, . . . , `, such that: Nested words only↝ go forward:≥ if i j, then i j; {−∞ } × { +∞} ↝ < A position cannot be both a call and a return. Nesting edges never cross: if i j, and i j , then it is not the case that i i j j . ′ ′ ′ ′ ↝ ↝ < ≤ <

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A matching relation of length ` 0 is a subset of , 1, 2, 3, . . . , ` 1, 2, 3, . . . , `, such that: Nested words only↝ go forward:≥ if i j, then i j; {−∞ } × { +∞} No two nested edges share a position: For i , there is at most one position h such that↝h i and< at most one position j such that i j; −∞ < < ∞ ↝ ↝ Nesting edges never cross: if i j, and i j , then it is not the case that i i j j . ′ ′ ′ ′ ↝ ↝ < ≤ <

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A matching relation of length ` 0 is a subset of , 1, 2, 3, . . . , ` 1, 2, 3, . . . , `, such that: Nested words only↝ go forward:≥ if i j, then i j; {−∞ } × { +∞} No two nested edges share a position: For i , there is at most one position h such that↝h i and< at most one position j such that i j; −∞ < < ∞ A position cannot be both a call and a↝ return. ↝ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A matching relation of length ` 0 is a subset of , 1, 2, 3, . . . , ` 1, 2, 3, . . . , `, such that: Nested words only↝ go forward:≥ if i j, then i j; {−∞ } × { +∞} No two nested edges share a position: For i , there is at most one position h such that↝h i and< at most one position j such that i j; −∞ < < ∞ A position cannot be both a call and a↝ return. ↝ Nesting edges never cross: if i j, and i j , then it is not the case that i i j j . ′ ′ ′ ′ ↝ ↝ < ≤ < a call position, if i j for some j, if i , then i is a pending call. else i is a matched↝ call, and j is the return-successor of i. a return↝ position+∞ , if h i, for some h, if i, then i is a pending return. else i is a matched↝ return, and h is the call-predecessor of i. −∞ ↝ an internal position, for all remaining cases.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A position 1 i ` is referred to as

≤ ≤ a return position, if h i, for some h, if i, then i is a pending return. else i is a matched↝ return, and h is the call-predecessor of i. −∞ ↝ an internal position, for all remaining cases.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A position 1 i ` is referred to as a call position, if i j for some j, if i ≤ ≤ , then i is a pending call. else i is a matched↝ call, and j is the return-successor of i. ↝ +∞ an internal position, for all remaining cases.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A position 1 i ` is referred to as a call position, if i j for some j, if i ≤ ≤ , then i is a pending call. else i is a matched↝ call, and j is the return-successor of i. a return↝ position+∞ , if h i, for some h, if i, then i is a pending return. else i is a matched↝ return, and h is the call-predecessor of i. −∞ ↝ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A position 1 i ` is referred to as a call position, if i j for some j, if i ≤ ≤ , then i is a pending call. else i is a matched↝ call, and j is the return-successor of i. a return↝ position+∞ , if h i, for some h, if i, then i is a pending return. else i is a matched↝ return, and h is the call-predecessor of i. −∞ ↝ an internal position, for all remaining cases. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation

A position 1 i ` is referred to as a call position, if i j for some j, if i ≤ ≤ , then i is a pending call. else i is a matched↝ call, and j is the return-successor of i. a return↝ position+∞ , if h i, for some h, if i, then i is a pending return. else i is a matched↝ return, and h is the call-predecessor of i. −∞ ↝ an internal position, for all remaining cases. For 1 i `, there is a linear edge, between i and i 1. The initial node has an incoming linear edge which has no source,≤ and≤ the last node has an outgoing linear edge+ with no destination. For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: The initial node has an incoming linear edge which has no source, and the last node has an outgoing linear edge with no destination. For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: For 1 i `, there is a linear edge, between i and i 1.

≤ ≤ + For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: For 1 i `, there is a linear edge, between i and i 1. The initial node has an incoming linear edge which has no source,≤ and≤ the last node has an outgoing linear edge+ with no destination. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: For 1 i `, there is a linear edge, between i and i 1. The initial node has an incoming linear edge which has no source,≤ and≤ the last node has an outgoing linear edge+ with no destination. For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: For 1 i `, there is a linear edge, between i and i 1. The initial node has an incoming linear edge which has no source,≤ and≤ the last node has an outgoing linear edge+ with no destination. For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Matching Relation as a Graph

A matching relation can be thought of as a directed acyclic graph over ` vertices: For 1 i `, there is a linear edge, between i and i 1. The initial node has an incoming linear edge which has no source,≤ and≤ the last node has an outgoing linear edge+ with no destination. For each matched call position i, there is a outgoing nesting edge, leading to the returning successor position. For a pending call i, there is a nesting edge that has no destination, while a pending return has a nested edge that has no source. Definition A nested word is well-matched if there is no position i such that i or i .

−∞ ↝ ↝ +∞

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word

Definition

A nested word n over an alphabet A is a pair a1 a`, such that

ai A for each 1 i ` ( ⋯ ↝) is a matching relation of length `. ∈ ≤ ≤ The set of all nested words over A is denoted by NW A . ↝ ( ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word

Definition

A nested word n over an alphabet A is a pair a1 a`, such that

ai A for each 1 i ` ( ⋯ ↝) is a matching relation of length `. ∈ ≤ ≤ The set of all nested words over A is denoted by NW A . ↝ Definition ( ) A nested word is well-matched if there is no position i such that i or i .

−∞ ↝ ↝ +∞ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word

Definition

A nested word n over an alphabet A is a pair a1 a`, such that

ai A for each 1 i ` ( ⋯ ↝) is a matching relation of length `. ∈ ≤ ≤ The set of all nested words over A is denoted by NW A . ↝ Definition ( ) A nested word is well-matched if there is no position i such that i or i .

−∞ ↝ ↝ +∞ A a a A

⟩ = { ⟩S ∈ } The tagged alphabet Aˆ is defined as A A A .

∪ ⟨ ∪ ⟩

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Word Encoding

A nested word n a1 a`, over A can be written more naturally using tags and to denote calls and returns. For each symbol a A, define= ( ⋯ ↝) ⟨ ⟩ ∈ A a a A

⟨ = {⟨ S ∈ } The tagged alphabet Aˆ is defined as A A A .

∪ ⟨ ∪ ⟩

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Word Encoding

A nested word n a1 a`, over A can be written more naturally using tags and to denote calls and returns. For each symbol a A, define= ( ⋯ ↝) ⟨ ⟩ ∈ A a a A A a a A

⟨ = {⟨ S ∈ } ⟩ = { ⟩S ∈ } Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Word Encoding

A nested word n a1 a`, over A can be written more naturally using tags and to denote calls and returns. For each symbol a A, define= ( ⋯ ↝) ⟨ ⟩ ∈ A a a A A a a A

⟨ = {⟨ S ∈ } ⟩ = { ⟩S ∈ } The tagged alphabet Aˆ is defined as A A A .

∪ ⟨ ∪ ⟩ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Word Encoding

Theorem There exists a bijection between NW A and Aˆ . ∗ ( ) Define nw w NW A Aˆ as follows: For a nested word n a1 ∗a`, , we obtain its tagged word nˆ nw w n ∶ b1b(2 )b→`, bi Aˆ, where = ( ⋯ ↝) = ( ) = ⋯ai if i∈ is an internal position, b i ⎧ ai if i is a call position, ⎪ ⎪ai if i is a return position. = ⎨⟨ ⎪ ⎩⎪ ⟩ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Word Encoding

Theorem There exists a bijection between NW A and Aˆ . ∗ ( ) Since calls and returns are allowed to be pending, each tagged word in Aˆ corresponds to a word in NW A . ∗ Thus, the inverse function wn n Aˆ NW( )A also exists. ∗ ∶ → ( ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications where Q is a finite set of (linear) states

q0 Q is an initial (linear) state

Qf Q is a set of (linear) final states ∈ P is a finite set of hierarchical states ⊆ p0 P is an initial hierarchical state

Pf P is a set of final hierarchical states ∈ δc Q A Q P is a call-transition function ⊆ δi Q A Q is an internal-transition function ∶ × → × δf Q P A Q is a return-transition function ∶ × → ∶ × × →

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word Automaton

A nested word automaton over an alphabet A is a structure

Q, q0M, Qf , P, p0, Pf , δc , δi , δr

M = ( ) P is a finite set of hierarchical states

p0 P is an initial hierarchical state

Pf P is a set of final hierarchical states ∈ δc Q A Q P is a call-transition function ⊆ δi Q A Q is an internal-transition function ∶ × → × δf Q P A Q is a return-transition function ∶ × → ∶ × × →

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word Automaton

A nested word automaton over an alphabet A is a structure

Q, q0M, Qf , P, p0, Pf , δc , δi , δr

where M = ( ) Q is a finite set of (linear) states

q0 Q is an initial (linear) state

Qf Q is a set of (linear) final states ∈ ⊆ δc Q A Q P is a call-transition function

δi Q A Q is an internal-transition function ∶ × → × δf Q P A Q is a return-transition function ∶ × → ∶ × × →

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word Automaton

A nested word automaton over an alphabet A is a structure

Q, q0M, Qf , P, p0, Pf , δc , δi , δr

where M = ( ) Q is a finite set of (linear) states

q0 Q is an initial (linear) state

Qf Q is a set of (linear) final states ∈ P is a finite set of hierarchical states ⊆ p0 P is an initial hierarchical state

Pf P is a set of final hierarchical states ∈ ⊆ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word Automaton

A nested word automaton over an alphabet A is a structure

Q, q0M, Qf , P, p0, Pf , δc , δi , δr

where M = ( ) Q is a finite set of (linear) states

q0 Q is an initial (linear) state

Qf Q is a set of (linear) final states ∈ P is a finite set of hierarchical states ⊆ p0 P is an initial hierarchical state

Pf P is a set of final hierarchical states ∈ δc Q A Q P is a call-transition function ⊆ δi Q A Q is an internal-transition function ∶ × → × δf Q P A Q is a return-transition function ∶ × → ∶ × × → Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Nested Word Automaton

A nested word automaton over an alphabet A is a structure

Q, q0M, Qf , P, p0, Pf , δc , δi , δr

where M = ( ) Q is a finite set of (linear) states

q0 Q is an initial (linear) state

Qf Q is a set of (linear) final states ∈ P is a finite set of hierarchical states ⊆ p0 P is an initial hierarchical state

Pf P is a set of final hierarchical states ∈ δc Q A Q P is a call-transition function ⊆ δi Q A Q is an internal-transition function ∶ × → × δf Q P A Q is a return-transition function ∶ × → ∶ × × → if i is a call, then δc qi 1, ai qi , pi

if i is an internal, then δi qi 1, ai qi ( − ) = ( ) if i is a return, then ( − ) = if i has call-predecessor j, then δr qi−1, pj , ai qi if i is a pending return, then δr qi−1, p0, ai qi ( ) = Acceptance ( ) =

The automaton accepts a nested word n if q` Qf and for all pending calls i, pi Pf . ∈ ∈

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications A Run of the Nested Word Automaton

A run of the automaton over a nested word n a1 a`, is a sequence qi Q, for 0 i `, of states corresponding to linear edges starting with q0, andM a sequence pi P, for= calls( ⋯i, of↝ states) corresponding∈ to nested≤ edges.≤ ∈ Acceptance

The automaton accepts a nested word n if q` Qf and for all pending calls i, pi Pf . ∈ ∈

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications A Run of the Nested Word Automaton

A run of the automaton over a nested word n a1 a`, is a sequence qi Q, for 0 i `, of states corresponding to linear edges starting with q0, andM a sequence pi P, for= calls( ⋯i, of↝ states) corresponding∈ to nested≤ edges.≤ ∈ if i is a call, then δc qi 1, ai qi , pi

if i is an internal, then δi qi 1, ai qi ( − ) = ( ) if i is a return, then ( − ) = if i has call-predecessor j, then δr qi−1, pj , ai qi if i is a pending return, then δr qi−1, p0, ai qi ( ) = ( ) = Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications A Run of the Nested Word Automaton

A run of the automaton over a nested word n a1 a`, is a sequence qi Q, for 0 i `, of states corresponding to linear edges starting with q0, andM a sequence pi P, for= calls( ⋯i, of↝ states) corresponding∈ to nested≤ edges.≤ ∈ if i is a call, then δc qi 1, ai qi , pi

if i is an internal, then δi qi 1, ai qi ( − ) = ( ) if i is a return, then ( − ) = if i has call-predecessor j, then δr qi−1, pj , ai qi if i is a pending return, then δr qi−1, p0, ai qi ( ) = Acceptance ( ) =

The automaton accepts a nested word n if q` Qf and for all pending calls i, pi Pf . ∈ ∈ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Regular Nested Word Language

Definition A language L of nested words over A is a regular nested-word language if there exists a nested word automaton over A such that L L . M = (M) Example Construct a nested word automaton that accepts

L a n b n n 0

= {(⟨ ) ( ⟩) S ≥ }

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Examples of Runs

Example Construct a nested automaton over A a, b that accepts words in which every subword starting at a call and ending at a matching return contains an even number= { of }a’s. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Examples of Runs

Example Construct a nested automaton over A a, b that accepts words in which every subword starting at a call and ending at a matching return contains an even number= { of }a’s.

Example Construct a nested word automaton that accepts

L a n b n n 0

= {(⟨ ) ( ⟩) S ≥ } where

Q0 Q is a set of (linear) initial states

P0 P is a set of initial hierarchical states ⊆ δc Q A Q P is a call-transition relation ⊆ δi Q A Q is an internal-transition relation ⊆ × × × δf Q P A Q is a return-transition relation ⊆ × × ⊆ × × ×

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Non-deterministic Nested Word Automata

A non-deterministic nested word automaton over an alphabet A is a structure M Q, Q0, Qf , P, P0, Pf , δc , δi , δr

M = ( ) P0 P is a set of initial hierarchical states

δc Q A Q P is a call-transition relation ⊆ δi Q A Q is an internal-transition relation ⊆ × × × δf Q P A Q is a return-transition relation ⊆ × × ⊆ × × ×

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Non-deterministic Nested Word Automata

A non-deterministic nested word automaton over an alphabet A is a structure M Q, Q0, Qf , P, P0, Pf , δc , δi , δr

where M = ( )

Q0 Q is a set of (linear) initial states

⊆ δc Q A Q P is a call-transition relation

δi Q A Q is an internal-transition relation ⊆ × × × δf Q P A Q is a return-transition relation ⊆ × × ⊆ × × ×

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Non-deterministic Nested Word Automata

A non-deterministic nested word automaton over an alphabet A is a structure M Q, Q0, Qf , P, P0, Pf , δc , δi , δr

where M = ( )

Q0 Q is a set of (linear) initial states

P0 P is a set of initial hierarchical states ⊆ ⊆ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Non-deterministic Nested Word Automata

A non-deterministic nested word automaton over an alphabet A is a structure M Q, Q0, Qf , P, P0, Pf , δc , δi , δr

where M = ( )

Q0 Q is a set of (linear) initial states

P0 P is a set of initial hierarchical states ⊆ δc Q A Q P is a call-transition relation ⊆ δi Q A Q is an internal-transition relation ⊆ × × × δf Q P A Q is a return-transition relation ⊆ × × ⊆ × × × For a given nested word nw, let 1 i1 i2 ik ` be all the pending call positions in nw. Then the sequence ≤ < < ⋯ < ≤ pi1 ... pik q` P Q is called the frontier of the run of a NWA

M on nw, where∗ pij is the hierarchical state of the pending nesting edge∈ at position ij and q` is the last linear state of the run. The frontier of a run at position i is the frontier of the run over the prefix nw 1 i

[ ∶ ]

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier of a Run

In a call-transition, the first component is the linear state to ` be propagated to, call it δc , while the second is the h hierarchical state to be propagated along, call it δc . Then the sequence

pi1 ... pik q` P Q is called the frontier of the run of a NWA

M on nw, where∗ pij is the hierarchical state of the pending nesting edge∈ at position ij and q` is the last linear state of the run. The frontier of a run at position i is the frontier of the run over the prefix nw 1 i

[ ∶ ]

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier of a Run

In a call-transition, the first component is the linear state to ` be propagated to, call it δc , while the second is the h hierarchical state to be propagated along, call it δc . For a given nested word nw, let 1 i1 i2 ik ` be all the pending call positions in nw. ≤ < < ⋯ < ≤ The frontier of a run at position i is the frontier of the run over the prefix nw 1 i

[ ∶ ]

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier of a Run

In a call-transition, the first component is the linear state to ` be propagated to, call it δc , while the second is the h hierarchical state to be propagated along, call it δc . For a given nested word nw, let 1 i1 i2 ik ` be all the pending call positions in nw. Then the sequence ≤ < < ⋯ < ≤ pi1 ... pik q` P Q is called the frontier of the run of a NWA

M on nw, where∗ pij is the hierarchical state of the pending nesting edge∈ at position ij and q` is the last linear state of the run. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier of a Run

In a call-transition, the first component is the linear state to ` be propagated to, call it δc , while the second is the h hierarchical state to be propagated along, call it δc . For a given nested word nw, let 1 i1 i2 ik ` be all the pending call positions in nw. Then the sequence ≤ < < ⋯ < ≤ pi1 ... pik q` P Q is called the frontier of the run of a NWA

M on nw, where∗ pij is the hierarchical state of the pending nesting edge∈ at position ij and q` is the last linear state of the run. The frontier of a run at position i is the frontier of the run over the prefix nw 1 i

[ ∶ ] Ifa ˆ a, the new frontier is p1 ... pk δi q, a h ` Ifa ˆ a, the new frontier is p1 ... pk δ q, a δ q, a = (c ) c Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , = ⟨ ( ) ( ) else if k 0, the new frontier is just δr q, p0, a . − Thus the= frontier⟩ of> a run carries all the information about( the ) prefix read so= far in the run, and we can predict( the) transitions of the automaton from the frontier alone. Note that the automaton accepts a word only iff the final frontier is in P Q ∗

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ. h ` Ifa ˆ a, the new frontier is p1 ... pk δc q, a δc q, a Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , = ⟨ ( ) ( ) else if k 0, the new frontier is just δr q, p0, a . − Thus the= frontier⟩ of> a run carries all the information about( the ) prefix read so= far in the run, and we can predict( the) transitions of the automaton from the frontier alone. Note that the automaton accepts a word only iff the final frontier is in P Q ∗

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ.

Ifa ˆ a, the new frontier is p1 ... pk δi q, a

= ( ) Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , else if k 0, the new frontier is just δr q, p0, a . − Thus the= frontier⟩ of> a run carries all the information about( the ) prefix read so= far in the run, and we can predict( the) transitions of the automaton from the frontier alone. Note that the automaton accepts a word only iff the final frontier is in P Q ∗

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ.

Ifa ˆ a, the new frontier is p1 ... pk δi q, a h ` Ifa ˆ a, the new frontier is p1 ... pk δ q, a δ q, a = (c ) c = ⟨ ( ) ( ) Thus the frontier of a run carries all the information about the prefix read so far in the run, and we can predict the transitions of the automaton from the frontier alone. Note that the automaton accepts a word only iff the final frontier is in P Q ∗

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ.

Ifa ˆ a, the new frontier is p1 ... pk δi q, a h ` Ifa ˆ a, the new frontier is p1 ... pk δ q, a δ q, a = (c ) c Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , = ⟨ ( ) ( ) else if k 0, the new frontier is just δr q, p0, a . = ⟩ > − ( ) = ( ) Note that the automaton accepts a word only iff the final frontier is in P Q ∗

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ.

Ifa ˆ a, the new frontier is p1 ... pk δi q, a h ` Ifa ˆ a, the new frontier is p1 ... pk δ q, a δ q, a = (c ) c Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , = ⟨ ( ) ( ) else if k 0, the new frontier is just δr q, p0, a . − Thus the= frontier⟩ of> a run carries all the information about( the ) prefix read so= far in the run, and we can predict( the) transitions of the automaton from the frontier alone. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Frontier As a State Summary

The frontier is initially q0. Suppose at some point of the run, the frontier is p1 ... pk q, and reads an encoded alphabeta ˆ.

Ifa ˆ a, the new frontier is p1 ... pk δi q, a h ` Ifa ˆ a, the new frontier is p1 ... pk δ q, a δ q, a = (c ) c Ifa ˆ a , and k 0 the new frontier is p1 ... pk 1δr q, pk , a , = ⟨ ( ) ( ) else if k 0, the new frontier is just δr q, p0, a . − Thus the= frontier⟩ of> a run carries all the information about( the ) prefix read so= far in the run, and we can predict( the) transitions of the automaton from the frontier alone. Note that the automaton accepts a word only iff the final frontier is in P Q ∗ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Acceptance using only final linear state is adequate for linearly accepting automata.

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Definition A nested-word automaton is said to be linearly accepting if all hierarchical states are final, i.e. Pf P.

= Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Definition A nested-word automaton is said to be linearly accepting if all hierarchical states are final, i.e. Pf P.

= Acceptance using only final linear state is adequate for linearly accepting automata. Let Q, q0, Qf , P, p0, Pf , δc , δi , δr . The automaton remembers, in addition to the state of , a bit thatA = indicates( whether acceptance) requires a matching return. B A

This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . The linearly accepting NWA has the structure ∈~ Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A The automaton remembers, in addition to the state of , a bit that indicates whether acceptance requires a matching return. B A

This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . The linearly accepting NWA has the structure ∈~ Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A Let Q, q0, Qf , P, p0, Pf , δc , δi , δr .

A = ( ) This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . The linearly accepting NWA has the structure ∈~ Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A Let Q, q0, Qf , P, p0, Pf , δc , δi , δr . The automaton remembers, in addition to the state of , a bit thatA = indicates( whether acceptance) requires a matching return. B A The linearly accepting NWA has the structure Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A Let Q, q0, Qf , P, p0, Pf , δc , δi , δr . The automaton remembers, in addition to the state of , a bit thatA = indicates( whether acceptance) requires a matching return. B A

This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . ∈~ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A Let Q, q0, Qf , P, p0, Pf , δc , δi , δr . The automaton remembers, in addition to the state of , a bit thatA = indicates( whether acceptance) requires a matching return. B A

This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . The linearly accepting NWA has the structure ∈~ Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Linearly Accepting Automata

Theorem Given a nested word automaton , one can construct a linearly accepting nested word automaton such that L L , and has twice as many states as A. B (B) = (A) B A Let Q, q0, Qf , P, p0, Pf , δc , δi , δr . The automaton remembers, in addition to the state of , a bit thatA = indicates( whether acceptance) requires a matching return. B A

This bit is set to 1 if there is at least one pending call pi Pf , and 0 if all pending calls are in Pf . The linearly accepting NWA has the structure ∈~ Q 0, 1 , q0, 0 , Qf 0 , P 0, 1 , P0 0 , P B 0, 1 , δc , δi , δr . ( × { ′ }′ ( ′ ) × { } × { } × { } × { } ) The call transition function is given by

` h δc q, x , a δc q, a , y , δc q, a , x ′ h where y 0(( iff x ) 0) and= ((δc (q, a) P)f (. ( ) )) The return transition function is given by = ( = ( ) ∈ )

δr q, y , p, x , a δr q, p, a , x ′ (( ) ( ) ) = ( ( ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Linearly Accepting (contd.)

The internal transition function is given by

δi q, x , a δi q, a , x ′ (( ) ) = ( ( ) ) The return transition function is given by

δr q, y , p, x , a δr q, p, a , x ′ (( ) ( ) ) = ( ( ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Linearly Accepting (contd.)

The internal transition function is given by

δi q, x , a δi q, a , x ′ (( ) ) = ( ( ) ) The call transition function is given by

` h δc q, x , a δc q, a , y , δc q, a , x ′ h where y 0(( iff x ) 0) and= ((δc (q, a) P)f (. ( ) ))

= ( = ( ) ∈ ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Linearly Accepting (contd.)

The internal transition function is given by

δi q, x , a δi q, a , x ′ (( ) ) = ( ( ) ) The call transition function is given by

` h δc q, x , a δc q, a , y , δc q, a , x ′ h where y 0(( iff x ) 0) and= ((δc (q, a) P)f (. ( ) )) The return transition function is given by = ( = ( ) ∈ )

δr q, y , p, x , a δr q, p, a , x ′ (( ) ( ) ) = ( ( ) ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Linearly Accepting (contd.)

For a nested word n with k pending calls,

the frontier of the run on is p1 pk q

A ⋯ the frontier of the⇕ run on on n is

p1, 0 , p2, x1 ,..., pk , xk B1 q, xk ,

− ( with) x(i 1 iff) pj (Pf for all)(j i. )

Thus, both and accept= the same∈ language.≤

A B The weakly hierarchical automaton can be represented as

` Q, q0, Qf , δc , δi , δr

` δc Q A Q M =δi(Q A Q δr )Q Q A Q

∶ × → ∶ × → ∶ × × →

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Weakly Hierarchical Automata

We can assume that the hierarchical states of the automaton are implicitly defined as follows: Definition A linearly accepting nested-word automaton Q, q0, Qf , P, p0, P, δc , δi , δr is weakly hierarchical if P Q, M = ( ) p0 q0, = δh q, a q for all states q and symbols a. c = ( ) = Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Weakly Hierarchical Automata

We can assume that the hierarchical states of the automaton are implicitly defined as follows: Definition A linearly accepting nested-word automaton Q, q0, Qf , P, p0, P, δc , δi , δr is weakly hierarchical if P Q, M = ( ) p0 q0, = δh q, a q for all states q and symbols a. c = The weakly( ) hierarchical= automaton can be represented as

` Q, q0, Qf , δc , δi , δr

` δc Q A Q M =δi(Q A Q δr )Q Q A Q

∶ × → ∶ × → ∶ × × → Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Weakly Hierarchical Automata

Theorem Given a nested word automaton with s linear states over A, one can effectively construct a weakly hierarchical NWA with 2s A states such that L L . A B S S (B) = (A) Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

A The weakly hierarchical NWA remembers the state of , as well as the symbol labelling the innermost pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A A = ( ) has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A At an internal, δi q, a , b δi q, b , a At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) ∈ At a call labelled b, the automaton in state q, a transitions ` to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ ′ (( ) ) = ( ( ) ) At a return labelled c, the automaton in state q, a , if the state propagated along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . ( ) ( ( ) ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Proof of Weakly Hierarchical

can be made linearly accepting by doubling the states.

Let Q, q0, Qf , P, p0, δc , δi , δr be linearly accepting. A The weakly hierarchical NWA remembers the state of , as wellA as= the( symbol labelling the innermost) pending call for the current position. B A

has the structure Q A, q0, a0 , Qf A, δc , δi , δr for some arbitrary a0 A. ′ ′ ′ B ( × ( ) × ) At an internal, δ q, a , b δi q, b , a i ∈ At a call labelled′ b, the automaton in state q, a transitions ` (( ) ) = ( ( ) ) to δc q, b , b . At a return labelled c, the automaton in state( q), a , if the state( propagated( ) ) along the nested edge is q , b moves to h ( ) state δr q, δc q , a , c , b . ′ ′ ( ) ( ( ( ) ) ) Concatenation: Given two nested words nw1 w1, ν1 and nw2 w2, ν2 , of lengths k1 and k2 respectively, nw1.nw2 w1.w2, ν where = ( ) ν ν=1 ( k1 ) i, k1 j i, j ν2 = ( ) Reversal: Given a nested word nw a1a2 ... ak , ν of length = ∪ {( + r + )S( ) ∈ }r k, its reverse nw ak ak 1 ... a1, ν where νr i, j k 1 j, k 1 i ν= ( ) − Kleene * = ( ) = {( )S( + − + − ) ∈ }

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Operations on Nested Words

Insertion with Context: A context is a tuple nw, i where nw is a nested word of length k and 0 i k. Then nw, i nw is defined as the nested word( obtained) by inserting the nested′ word nw at position≤ ≤ i in nw. ( ) ⊕ ′ Reversal: Given a nested word nw a1a2 ... ak , ν of length r r k, its reverse nw ak ak 1 ... a1, ν where νr i, j k 1 j, k 1 i ν= ( ) − Kleene * = ( ) = {( )S( + − + − ) ∈ }

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Operations on Nested Words

Insertion with Context: A context is a tuple nw, i where nw is a nested word of length k and 0 i k. Then nw, i nw is defined as the nested word( obtained) by inserting the nested′ word nw at position≤ ≤ i in nw. ( ) ⊕ ′ Concatenation: Given two nested words nw1 w1, ν1 and nw2 w2, ν2 , of lengths k1 and k2 respectively, nw1.nw2 w1.w2, ν where = ( ) ν ν=1 ( k1 ) i, k1 j i, j ν2 = ( ) = ∪ {( + + )S( ) ∈ } Kleene *

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Operations on Nested Words

Insertion with Context: A context is a tuple nw, i where nw is a nested word of length k and 0 i k. Then nw, i nw is defined as the nested word( obtained) by inserting the nested′ word nw at position≤ ≤ i in nw. ( ) ⊕ ′ Concatenation: Given two nested words nw1 w1, ν1 and nw2 w2, ν2 , of lengths k1 and k2 respectively, nw1.nw2 w1.w2, ν where = ( ) ν ν=1 ( k1 ) i, k1 j i, j ν2 = ( ) Reversal: Given a nested word nw a1a2 ... ak , ν of length = ∪ {( + r + )S( ) ∈ }r k, its reverse nw ak ak 1 ... a1, ν where νr i, j k 1 j, k 1 i ν= ( ) = ( − ) = {( )S( + − + − ) ∈ } Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Operations on Nested Words

Insertion with Context: A context is a tuple nw, i where nw is a nested word of length k and 0 i k. Then nw, i nw is defined as the nested word( obtained) by inserting the nested′ word nw at position≤ ≤ i in nw. ( ) ⊕ ′ Concatenation: Given two nested words nw1 w1, ν1 and nw2 w2, ν2 , of lengths k1 and k2 respectively, nw1.nw2 w1.w2, ν where = ( ) ν ν=1 ( k1 ) i, k1 j i, j ν2 = ( ) Reversal: Given a nested word nw a1a2 ... ak , ν of length = ∪ {( + r + )S( ) ∈ }r k, its reverse nw ak ak 1 ... a1, ν where νr i, j k 1 j, k 1 i ν= ( ) − Kleene * = ( ) = {( )S( + − + − ) ∈ } Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Concatenation Reversal Prefixes Suffixes Kleene *

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Closure Properties

Nested Word Automata are effectively closed under the following operations: Union Intersection Complement Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Closure Properties

Nested Word Automata are effectively closed under the following operations: Union Intersection Complement Concatenation Reversal Prefixes Suffixes Kleene * 1 2 Set final states to Qf , Qf to obtain L1 L2 1 2 1 2 Set final states to Q , Q Q , Q to obtain L1 L2 ( f ) f ∩ ( ) ∪ ( ) ∪ For a linearly accepting NWA M Q, q0, Qf , P, p0, δc , δi , δr that accepts L, then M Q, q0, Q Qf , P, p0, δc , δi , δr accepts C precisely L . ′ = ( ) = ( ƒ )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Boolean Closure

j j j j j j Let Mi Q , q0, Qf , δc , δi , δr , j 1, 2 be two NWA’s. Consider 1 2 the cross-product M1 M2 defined over the linear states Q Q , = ( 1 2) = 1 2 with initial linear state q0, q0 , and transitions δk δk , δk . × × ( ) = ( ) For a linearly accepting NWA M Q, q0, Qf , P, p0, δc , δi , δr that accepts L, then M Q, q0, Q Qf , P, p0, δc , δi , δr accepts C precisely L . ′ = ( ) = ( ƒ )

Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Boolean Closure

j j j j j j Let Mi Q , q0, Qf , δc , δi , δr , j 1, 2 be two NWA’s. Consider 1 2 the cross-product M1 M2 defined over the linear states Q Q , = ( 1 2) = 1 2 with initial linear state q0, q0 , and transitions δk δk , δk . × 1 2 × Set final states to Qf , Qf to obtain L1 L2 ( 1 )2 1 2 = ( ) Set final states to Q , Q Q , Q to obtain L1 L2 ( f ) f ∩ ( ) ∪ ( ) ∪ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Boolean Closure

j j j j j j Let Mi Q , q0, Qf , δc , δi , δr , j 1, 2 be two NWA’s. Consider 1 2 the cross-product M1 M2 defined over the linear states Q Q , = ( 1 2) = 1 2 with initial linear state q0, q0 , and transitions δk δk , δk . × 1 2 × Set final states to Qf , Qf to obtain L1 L2 ( 1 )2 1 2 = ( ) Set final states to Q , Q Q , Q to obtain L1 L2 ( f ) f ∩ ( ) ∪ ( ) ∪ For a linearly accepting NWA M Q, q0, Qf , P, p0, δc , δi , δr that accepts L, then M Q, q0, Q Qf , P, p0, δc , δi , δr accepts C precisely L . ′ = ( ) = ( ƒ ) Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Congruences

Definition Let L be a nested-word language. Define a relation on nested words in NW A :

(nw)1 L nw2 if for every context nw, i ,

nw,∼i nw1 L nw, i (nw2 )L

Observe that( L is) an⊕ equivalence∈ ⇐⇒ relation.( ) ⊕ ∈

∼ It is also a congruence: if nw1 L nw2 and nw1 L nw2, then nw1.nw1 nw2.nw2. ′ ′ ′ ′ ∼ ∼ ∼ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Finite Index

Theorem

For a language L of nested words, L is regular iff L has finitely many congruence classes. ∼ Proof: ( ) Let L be a regular nested word language, accepted by an NWA with states Q. Define a new relation on nested words in L: nw⇒ nw if for all states q, q Q, A ′ ′ ≈A has a run from q ∈to q on nw ′ Ahas a run from q to q on nw . ⇕ ′ ′ Then is an equivalenceA relation and is a congruence as well. 2 There≈A at most Q equivalence classes under nw nw nw L nw S S ≈A ′ ′ ≈A ⇒ ∼ Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Finite Index (Contd.)

( ): Suppose L is such that L has finite index. If nw L, let nw denote the corresponding equivalence class. We construct a new⇐ nested-word automaton ∼ Q, Q0, Qf , δ as follows:∈ [ ]Q nw nw NW A M = ( ) Q0  = {[ ]S ∈ ( )} Qf nw nw L = {[ ]} δ δc , δi , δr : = {[ ]S ∈ } δc w, ν , a, a, w, ν NW A , a A = δi w, ν , a, w.a, ν w, ν NW A , a A δr = {([(w1, ν1 ,)] w2[(, ν2 ∅,)])a S (w2.w)1∈.a, ν (where) ∈ if } ′ w=1,{([( ν1 . w2,)] ν2 [ w1.w])2, ν S ( then) ∈ ( ) ∈ } ′ ν ([(ν )]w1 [( 1, w1)] w)2= [ 1 ] ( ) ( ) = ( ) = ∪ {(S S + S S + S S + } Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Determinisation

Theorem Given a nondeterministic linearly accepting nested word automaton , one can effectively construct a deterministic linearly accepting nested word automaton such that L L . A

Moreover, if has s` linearB states, and(Bs)h =hierarchical(A) states, then s s s2 has 2 ` h linear states, and 2 h hierarchical states. A B Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications MSO

The monadic second-order logic of nested words is given by the syntax:

ϕ Qa x x X call x ret x x y 1 x y ϕ ϕ ϕ x.ϕ X .ϕ ∶= ( )S ∈ S ( )S ( )S = + S ↝ S S ∨ S ¬ S ∃ S ∃ Theorem A language L of nested words over A is regular iff there is an MSO sentence ϕ over A that defines L. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Equivalence to VPL

Theorem A language L over A is a of nested words iff the encoded language Lˆ over Aˆ has a visibly pushdown grammar Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Overview

1 Motivation

2 Definitions

3 NWA

4 Restrictions

5 Closure

6 Equivalent Definitions

7 Applications Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Applications - XML Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Applications - NLP

Annotations adds a hierarchical structure to the standard linear ordering of words that occur in a large linguistic repositories. Traditionally, the result is represented as an ordered , but can equally be represented as a nested word, which is more succinct while querying over both linear and hierarchical data. Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications Applications - RNA Motivation Definitions NWA Restrictions Closure Equivalent Definitions Applications References

1 Alur, R. and Madhusudan, P. (2009). Adding nesting structure to words. Journal of the ACM, 56(3), pp.1-43. 2 Madhusudan Parthasarathy, Rajeev Alur, Swarat Chaudhuri, Viraj Kumar, and Mahesh Viswanathan (2006). Automata Theory for Nested Structures.