SLIDE 1 Enumeration on Trees with Tractable Combined Complexity and Efficient Updates
Antoine Amarilli1, Pierre Bourhis2, Stefan Mengel3, Matthias Niewerth4 May 20th, 2019
1Télécom ParisTech 2CNRS, CRIStAL, Lille 3CNRS, CRIL, Lens 4University of Bayreuth 1/16
SLIDE 2 Dramatis Personae
Antoine Amarilli Pierre Bourhis Stefan Mengel Matthias Niewerth
2/16
SLIDE 3
Problem statement
SLIDE 4 MSO query evaluation on trees
Data: a tree T where nodes have a color from an alphabet
3/16
SLIDE 5 MSO query evaluation on trees
Data: a tree T where nodes have a color from an alphabet
?
Query Q: a formula in monadic second-order logic (MSO)
- P (x) means “x is blue”
- x → y means “x is the parent of y”
“Return all blue nodes that have a pink child” ∃y P (x) ∧ P (y) ∧ x → y
3/16
SLIDE 6 MSO query evaluation on trees
Data: a tree T where nodes have a color from an alphabet
?
Query Q: a formula in monadic second-order logic (MSO)
- P (x) means “x is blue”
- x → y means “x is the parent of y”
“Return all blue nodes that have a pink child” ∃y P (x) ∧ P (y) ∧ x → y
i
Result: { (x1, . . . , xk) | (x1, . . . , xk) | = Q }
3/16
SLIDE 7 MSO query evaluation on trees
Data: a tree T where nodes have a color from an alphabet
?
Query Q: a formula in monadic second-order logic (MSO)
- P (x) means “x is blue”
- x → y means “x is the parent of y”
“Return all blue nodes that have a pink child” ∃y P (x) ∧ P (y) ∧ x → y
i
Result: { (x1, . . . , xk) | (x1, . . . , xk) | = Q } Up to |T|k many answers
3/16
SLIDE 8
Enumeration algorithm
Input
SLIDE 9
Enumeration algorithm
Input Step 1: Indexing in O(input)
SLIDE 10
Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input
SLIDE 11
Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
SLIDE 12 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a b c
Results
SLIDE 13 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a b c
Results State 0011
SLIDE 14 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a b c
Results State 0011
4/16
SLIDE 15 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a’ b c
Results State 010001
4/16
SLIDE 16 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a b’ c
Results State 01100111
4/16
SLIDE 17 Enumeration algorithm
Input Step 1: Indexing in O(input) Indexed input Step 2: Enumeration in O(result)
A B C a’ b’ c
Results State ⊥
4/16
SLIDE 18 Known results on dynamic trees
All these results are on data complexity in T (for a fixed pattern): Work Data Preproc. Delay Updates
[Bagan, 2006], [Kazana and Segoufin, 2013]
trees O(T) O(1) O(T)
5/16
SLIDE 19 Known results on dynamic trees
All these results are on data complexity in T (for a fixed pattern): Work Data Preproc. Delay Updates
[Bagan, 2006], [Kazana and Segoufin, 2013]
trees O(T) O(1) O(T)
[Losemann and Martens, 2014] trees
O(T) O(log2 T) O(log2 T)
5/16
SLIDE 20 Known results on dynamic trees
All these results are on data complexity in T (for a fixed pattern): Work Data Preproc. Delay Updates
[Bagan, 2006], [Kazana and Segoufin, 2013]
trees O(T) O(1) O(T)
[Losemann and Martens, 2014] trees
O(T) O(log2 T) O(log2 T)
[Niewerth, 2018]
trees O(T) O(log T) O(log T)
5/16
SLIDE 21 Known results on dynamic trees
All these results are on data complexity in T (for a fixed pattern): Work Data Preproc. Delay Updates
[Bagan, 2006], [Kazana and Segoufin, 2013]
trees O(T) O(1) O(T)
[Losemann and Martens, 2014] trees
O(T) O(log2 T) O(log2 T)
[Niewerth, 2018]
trees O(T) O(log T) O(log T)
[Niewerth and Segoufin, 2018]
text O(T) O(1) O(log T)
5/16
SLIDE 22 Known results on dynamic trees
All these results are on data complexity in T (for a fixed pattern): Work Data Preproc. Delay Updates
[Bagan, 2006], [Kazana and Segoufin, 2013]
trees O(T) O(1) O(T)
[Losemann and Martens, 2014] trees
O(T) O(log2 T) O(log2 T)
[Niewerth, 2018]
trees O(T) O(log T) O(log T)
[Niewerth and Segoufin, 2018]
text O(T) O(1) O(log T) this paper trees O(T) O(1) O(log T)
5/16
SLIDE 23 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
6/16
SLIDE 24 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
6/16
SLIDE 25 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
- We use bottom-up (binary) tree-automata
6/16
SLIDE 26 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
- We use bottom-up (binary) tree-automata
∃y . . . Query
SLIDE 27 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
- We use bottom-up (binary) tree-automata
∃y . . . Query Automaton
SLIDE 28 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
- We use bottom-up (binary) tree-automata
∃y . . . Query Automaton Tree
SLIDE 29 Tree Automata
- MSO query evaluation is non-elementary (if P = NP)
- Most queries are much simpler
- We use bottom-up (binary) tree-automata
∃y . . . Query Automaton Tree Knowlege Compilation Set Circuit in DNNF
6/16
SLIDE 30 Semantics of set circuits
∪ × x:1 ⊤ × y:3 Every gate g captures set of sets S(g)
7/16
SLIDE 31 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}}
7/16
SLIDE 32 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} {{}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}} S( ⊤ ) := {{}}
7/16
SLIDE 33 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} {{}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}} S( ⊤ ) := {{}} S( ⊥ ) := ∅
7/16
SLIDE 34 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} {{}} {{x}} {{x, y}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}} S( ⊤ ) := {{}} S( ⊥ ) := ∅ S( × ) := {s1 ∪ s2 | s1 ∈ S(g1), s2 ∈ S(g2)}
7/16
SLIDE 35 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} {{}} {{x}} {{x, y}} {{x}, {x, y}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}} S( ⊤ ) := {{}} S( ⊥ ) := ∅ S( × ) := {s1 ∪ s2 | s1 ∈ S(g1), s2 ∈ S(g2)} S( ∪ ) := S(g1) ∪ S(g2)
7/16
SLIDE 36 Semantics of set circuits
∪ × x:1 ⊤ × y:3 {{x}} {{y}} {{}} {{x}} {{x, y}} {{x}, {x, y}} Every gate g captures set of sets S(g) S( x:1 ) := {{x:1}} S( ⊤ ) := {{}} S( ⊥ ) := ∅ S( × ) := {s1 ∪ s2 | s1 ∈ S(g1), s2 ∈ S(g2)} S( ∪ ) := S(g1) ∪ S(g2) Task: Enumerate the elements of the set S(g) captured by a gate g →E.g., for S(g) = {{x}, {x, y}}, enumerate {x} and then {x, y}
7/16
SLIDE 37 Compiling Trees in Set Circuits
8/16
SLIDE 38 Compiling Trees in Set Circuits
8/16
SLIDE 39 Compiling Trees in Set Circuits
- One box for each node of the tree
8/16
SLIDE 40 Compiling Trees in Set Circuits
- One box for each node of the tree
- In each box: one ∪-gate for each state q of the automaton
- Captures partial runs that end in q
8/16
SLIDE 41 Enumerate Circuit Results
Preprocessing phase:
∪ × x z
DNNF set circuit
SLIDE 42 Enumerate Circuit Results
Preprocessing phase:
∪ × x z
DNNF set circuit Normalization (linear-time)
× x z
Normalized circuit
SLIDE 43 Enumerate Circuit Results
Preprocessing phase:
∪ × x z
DNNF set circuit Normalization (linear-time)
× x z
Normalized circuit Indexing (linear-time)
× x z
Indexed normalized circuit
9/16
SLIDE 44 Enumerate Circuit Results
Preprocessing phase:
∪ × x z
DNNF set circuit Normalization (linear-time)
× x z
Normalized circuit Indexing (linear-time)
× x z
Indexed normalized circuit Enumeration phase:
× x z
Indexed normalized circuit
SLIDE 45 Enumerate Circuit Results
Preprocessing phase:
∪ × x z
DNNF set circuit Normalization (linear-time)
× x z
Normalized circuit Indexing (linear-time)
× x z
Indexed normalized circuit Enumeration phase:
× x z
Indexed normalized circuit Enumeration (constant delay)
A B C a b c a b’ c
Results
9/16
SLIDE 46 Compiling Trees in Set Circuits
10/16
SLIDE 47 Compiling Trees in Set Circuits
- Constructions are bottom-up
10/16
SLIDE 48 Compiling Trees in Set Circuits
- Constructions are bottom-up
- Updates can be done in O(depth(T))
10/16
SLIDE 49 Compiling Trees in Set Circuits
- Constructions are bottom-up
- Updates can be done in O(depth(T))
- Problem: depth(T) can be linear in T
10/16
SLIDE 50 Compiling Trees in Set Circuits
- Constructions are bottom-up
- Updates can be done in O(depth(T))
- Problem: depth(T) can be linear in T
- Solution: Depict trees by forest algebra terms
10/16
SLIDE 51 Free Forest Algebra in a Nutshell
‘ = concatenation
11/16
SLIDE 52 Free Forest Algebra in a Nutshell
‘ = concatenation d = context application
11/16
SLIDE 53 Free Forest Algebra in a Nutshell
‘ = concatenation d = context application d = context application
11/16
SLIDE 54 Free Forest Algebra in a Nutshell
tree
12/16
SLIDE 55 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term
12/16
SLIDE 56 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term
12/16
SLIDE 57 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term
12/16
SLIDE 58 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term
12/16
SLIDE 59 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term d d ‘ ‘ alternative term
12/16
SLIDE 60 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term d d ‘ ‘ alternative term
12/16
SLIDE 61 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term d d ‘ ‘ alternative term
12/16
SLIDE 62 Free Forest Algebra in a Nutshell
tree d ‘ d ‘ term d d ‘ ‘ alternative term The leaves of the formula correspond to the nodes of the tree
12/16
SLIDE 63 Rebalancing Forest Algebra Terms
‘ ‘ 1 2 3
13/16
SLIDE 64 Rebalancing Forest Algebra Terms
‘ ‘ 1 2 3 ‘ 1 ‘ 2 3
13/16
SLIDE 65 Rebalancing Forest Algebra Terms
‘ ‘ 1 2 3 ‘ 1 ‘ 2 3
13/16
SLIDE 66 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3
13/16
SLIDE 67 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3 ‘ ‘ 1 ‘ 2 3 4 ‘ ‘ 1 2 ‘ 3 4 ‘ 1 ‘ ‘ 2 3 4
13/16
SLIDE 68 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3 d d 1 d 2 3 4 d d 1 2 d 3 4 d 1 d d 2 3 4
13/16
SLIDE 69 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3 d d 1 d 2 3 4 d d 1 2 d 3 4 d 1 d d 2 3 4
13/16
SLIDE 70 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3 d d 1 d 2 3 4 d d 1 2 d 3 4 d 1 d d 2 3 4 ‘ d 1 3 2 d ‘ 1 2 3
1 contains the hole
13/16
SLIDE 71 Rebalancing Forest Algebra Terms
d d 1 2 3 d 1 d 2 3 d d 1 d 2 3 4 d d 1 2 d 3 4 d 1 d d 2 3 4 ‘ d 1 3 2 d ‘ 1 2 3
1 contains the hole
‘ 1 d 2 3
2 contains the hole
13/16
SLIDE 72 Main Result
Theorem Enumertion of MSO formulas on trees can be done in time: Preprocessing O( |T| × |Q|4ω+1 ) Delay O( |Q|4ω × |S| ) Updates O( log(|T|) × |Q|4ω+1 ) |T| size of tree |Q| number of states of a nondeterministic tree automaton |S| size of result ω exponent for Boolean matrix multiplication
14/16
SLIDE 73
Lower Bound
SLIDE 74 Lower Bound
Existencial Marked Ancestor Queries Input: Tree t with some marked nodes Query: Does node v have a marked ancestor? Updates: Mark or unmark a node
15/16
SLIDE 75 Lower Bound
Existencial Marked Ancestor Queries Input: Tree t with some marked nodes Query: Does node v have a marked ancestor? Updates: Mark or unmark a node Theorem: tquery ∈ Ω
log(tupdate log(n))
SLIDE 76 Lower Bound
Existencial Marked Ancestor Queries Input: Tree t with some marked nodes Query: Does node v have a marked ancestor? Updates: Mark or unmark a node Theorem: tquery ∈ Ω
log(tupdate log(n))
- Reduction to Query Enumeration with Updates
Fixed Query Q: Return all special nodes with a marked ancestor For every marked ancestor query v:
- 1. Mark node v special
- 2. Enumerate Q and return “yes”, iff Q produces some result
- 3. Mark v as non-special again
15/16
SLIDE 77 Lower Bound
Existencial Marked Ancestor Queries Input: Tree t with some marked nodes Query: Does node v have a marked ancestor? Updates: Mark or unmark a node Theorem: tquery ∈ Ω
log(tupdate log(n))
- Reduction to Query Enumeration with Updates
Fixed Query Q: Return all special nodes with a marked ancestor For every marked ancestor query v:
- 1. Mark node v special
- 2. Enumerate Q and return “yes”, iff Q produces some result
- 3. Mark v as non-special again
Theorem: max(tdelay, tupdate) ∈ Ω
log log(n)
SLIDE 78 Results
Theorem Enumertion of MSO formulas on trees can be done in time: Preprocessing O( |T| × |Q|4ω+1 ) Delay O( |Q|4ω × |S| ) Updates O( log(|T|) × |Q|4ω+1 ) |T| size of tree |Q| number of states of a nondeterministic tree automaton |S| size of result ω exponent for Boolean matrix multiplication Theorem max(tdelay, tupdate) ∈ Ω
log log(n)
SLIDE 79 Results
Theorem Enumertion of MSO formulas on trees can be done in time: Preprocessing O( |T| × |Q|4ω+1 ) Delay O( |Q|4ω × |S| ) Updates O( log(|T|) × |Q|4ω+1 ) |T| size of tree |Q| number of states of a nondeterministic tree automaton |S| size of result ω exponent for Boolean matrix multiplication Theorem max(tdelay, tupdate) ∈ Ω
log log(n)
16/16
SLIDE 80
References i
Bagan, G. (2006). MSO queries on tree decomposable structures are computable with linear delay. In CSL. Kazana, W. and Segoufin, L. (2013). Enumeration of monadic second-order queries on trees. TOCL, 14(4). Losemann, K. and Martens, W. (2014). MSO queries on trees: Enumerating answers under updates. In CSL-LICS.
SLIDE 81
References ii
Niewerth, M. (2018). Mso queries on trees: Enumerating answers under updates using forest algebras. In LICS. Niewerth, M. and Segoufin, L. (2018). Enumeration of MSO queries on strings with constant delay and logarithmic updates. In PODS.
SLIDE 82
Normalization: handling ∅
× × x ⊥ y
SLIDE 83
Normalization: handling ∅
× × x ⊥ y {{x}} ∅
SLIDE 84
Normalization: handling ∅
× × x ⊥ y {{x}} ∅ {{y}} ∅
SLIDE 85
Normalization: handling ∅
× × x ⊥ y {{x}} ∅ {{y}} ∅ ∅
SLIDE 86 Normalization: handling ∅
× × x ⊥ y {{x}} ∅ {{y}} ∅ ∅
- Problem: if S(g) = ∅ we waste time
SLIDE 87 Normalization: handling ∅
× × x ⊥ y {{x}} ∅ {{y}} ∅ ∅
- Problem: if S(g) = ∅ we waste time
- Solution: in preprocessing
- compute bottom-up if S(g) = ∅
SLIDE 88 Normalization: handling ∅
× × x ⊥ y {{x}} ∅ {{y}} ∅ ∅
- Problem: if S(g) = ∅ we waste time
- Solution: in preprocessing
- compute bottom-up if S(g) = ∅
- then get rid of the gate
SLIDE 89
Normalization: handling empty sets
× × × x × × ×
SLIDE 90
Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}}
SLIDE 91
Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}}
SLIDE 92
Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}}
SLIDE 93
Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}} {{x}}
SLIDE 94 Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
SLIDE 95 Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
SLIDE 96 Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
- Solution:
- remove inputs with S(g) = {{}} for ×-gates
SLIDE 97 Normalization: handling empty sets
× × × x × × × {{}} {{}} {{}} {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
- Solution:
- remove inputs with S(g) = {{}} for ×-gates
SLIDE 98 Normalization: handling empty sets
× × × x {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
- Solution:
- remove inputs with S(g) = {{}} for ×-gates
- collapse ×-chains with fan-in 1
SLIDE 99 Normalization: handling empty sets
× × × x {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
- Solution:
- remove inputs with S(g) = {{}} for ×-gates
- collapse ×-chains with fan-in 1
SLIDE 100 Normalization: handling empty sets
× × × x {{x}} {{x}} {{x}} {{x}}
- Problem: if S(g) contains {} we waste time
in chains of ×-gates
- Solution:
- remove inputs with S(g) = {{}} for ×-gates
- collapse ×-chains with fan-in 1
→ Now, traversing a ×-gate ensures that we make progress: it splits the sets non-trivially
SLIDE 101
Indexing: handling ∪-hierarchies
∪ g1 ∪ ∪ g2 g3 g4 ∪ • Problem: we waste time in ∪-hierarchies to find a reachable exit (non-∪ gate)
SLIDE 102 Indexing: handling ∪-hierarchies
∪ g1 ∪ ∪ g2 g3 g4 ∪ • Problem: we waste time in ∪-hierarchies to find a reachable exit (non-∪ gate)
- Solution: compute reachability index
SLIDE 103 Indexing: handling ∪-hierarchies
∪ g1 ∪ ∪ g2 g3 g4 ∪ • Problem: we waste time in ∪-hierarchies to find a reachable exit (non-∪ gate)
- Solution: compute reachability index
SLIDE 104 Indexing: handling ∪-hierarchies
∪ g1 ∪ ∪ g2 g3 g4 ∪ • Problem: we waste time in ∪-hierarchies to find a reachable exit (non-∪ gate)
- Solution: compute reachability index
- Problem: must be done in linear time
SLIDE 105 Indexing: handling ∪-hierarchies
∪ g1 ∪ ∪ g2 g3 g4 ∪ • Problem: we waste time in ∪-hierarchies to find a reachable exit (non-∪ gate)
- Solution: compute reachability index
- Problem: must be done in linear time
- Solution: Compute reachability index with box-granularity
- Use matrix multiplication
- Circuit has bounded width (by the size of the automaton)