• Aucun résultat trouvé

Enumeration for MSO Queries on Trees via Circuits

N/A
N/A
Protected

Academic year: 2022

Partager "Enumeration for MSO Queries on Trees via Circuits"

Copied!
204
0
0

Texte intégral

(1)

Enumeration for MSO Queries on Trees via Circuits

Antoine Amarilli1 Pierre Bourhis2, Louis Jachiet2, Stefan Mengel3, Matthias Niewerth4

July 14, 2019

1Télécom Paris, Institut Polytechnique de Paris

2CNRS CRIStAL

(2)

Enumeration for MSO Queries on Trees via Circuits

Antoine Amarilli1 Pierre Bourhis2, Louis Jachiet2, Stefan Mengel3, Matthias Niewerth4

July141414141414141414141414,1414141414 2019

1Télécom Paris, Institut Polytechnique de Paris

2CNRS CRIStAL

3CNRS CRIL

4Universität Bayreuth 1/35

(3)

Circuits pour l’énumération de MSO sur des arbres

Antoine Amarilli1 Pierre Bourhis2, Louis Jachiet2, Stefan Mengel3, Matthias Niewerth4

July1414141414141414141414141414141414,2019

1Télécom Paris, Institut Polytechnique de Paris

2

(4)

Query evaluation

The main database problem isquery evaluation DataD: what we know

?

QueryQ: question asked about the data

i

Result: all results of the queryQon the dataD

Measure of efficiency:computational complexity:

Combined complexity:D andQareinputs

Data complexity:Qisfixed,Dis theinput

2/35

(5)

Query evaluation

The main database problem isquery evaluation

DataD: what we know

?

QueryQ: question asked about the data

i

Result: all results of the queryQon the dataD

Measure of efficiency:computational complexity:

Combined complexity:D andQareinputs

Data complexity:Qisfixed,Dis theinput

(6)

Query evaluation

The main database problem isquery evaluation

DataD: what we know

?

QueryQ: question asked about the data

i

Result: all results of the queryQon the dataD

Measure of efficiency:computational complexity:

Combined complexity:D andQareinputs

Data complexity:Qisfixed,Dis theinput

2/35

(7)

Query evaluation

The main database problem isquery evaluation

DataD: what we know

?

QueryQ: question asked about the data

i

Result: all results of the queryQon the dataD

Measure of efficiency:computational complexity:

Combined complexity:DandQareinputs

(8)

Structured data: trees

Several kinds of data are structured as atree (HTML pages, XML, folder hierarchies...)

• Important special case:text

On this kind of data, we can usemore efficient query evaluation techniques

Natural query language:monadic second-order logic(MSO)

• Very expressive

• Corresponds totree automata

• Data complexity is inlinear time

3/35

(9)

Structured data: trees

Several kinds of data are structured as atree (HTML pages, XML, folder hierarchies...)

• Important special case:text

On this kind of data, we can usemore efficient query evaluation techniques

Natural query language:monadic second-order logic(MSO)

• Very expressive

• Corresponds totree automata

• Data complexity is inlinear time

(10)

Structured data: trees

Several kinds of data are structured as atree (HTML pages, XML, folder hierarchies...)

• Important special case:text

On this kind of data, we can usemore efficient query evaluation techniques

Natural query language:monadic second-order logic(MSO)

• Very expressive

• Corresponds totree automata

• Data complexity is inlinear time

3/35

(11)

Query evaluation on trees

Data: a treeTwhere nodes have a color from an alphabet

?

QueryQ: aBooleanformula in monadic second-order logic (MSO)

P (x)means “xis blue”

xymeans “xis the parent ofy

“Is there both a pink and a blue node?”

∃x y P (x)∧P (y)

i

Result: YES/NO indicating if the treeT satisfies the queryQ

Data complexity: linear inT

Combined complexity:cannot be elementary

(12)

Query evaluation on trees

Data: a treeTwhere nodes have a color from an alphabet

?

QueryQ: aBooleanformula in monadic second-order logic (MSO)

P (x)means “xis blue”

xymeans “xis the parent ofy

“Is there both a pink and a blue node?”

∃x y P (x)∧P (y)

i

Result: YES/NO indicating if the treeT satisfies the queryQ

Data complexity: linear inT

Combined complexity:cannot be elementary

4/35

(13)

Query evaluation on trees

Data: a treeTwhere nodes have a color from an alphabet

?

QueryQ: aBooleanformula in monadic second-order logic (MSO)

P (x)means “xis blue”

xymeans “xis the parent ofy

“Is there both a pink and a blue node?”

∃x y P (x)∧P (y)

i

Result: YES/NO indicating if the treeT satisfies the queryQ

Data complexity: linear inT

Combined complexity:cannot be elementary

(14)

Query evaluation on trees

Data: a treeTwhere nodes have a color from an alphabet

?

QueryQ: aBooleanformula in monadic second-order logic (MSO)

P (x)means “xis blue”

xymeans “xis the parent ofy

“Is there both a pink and a blue node?”

∃x y P (x)∧P (y)

i

Result: YES/NO indicating if the treeT satisfies the queryQ

Data complexity: linear inT

Combined complexity:cannot be elementary

4/35

(15)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

(16)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

5/35

(17)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

(18)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

5/35

(19)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

(20)

Beyond Boolean queries

Booleanqueries only givesYES/NOanswers

YES, there is both a pink and a blue node

Better idea:non-Boolean queries

e.g.,Q(x,y): “xis a pink node andyis a blue node”

Challenge:how to define complexity for non-Boolean queries?

• Justwriting the outputis slow in the worst case

• Easy solution: thenaive algorithmthat tests all pairs

We need anew definitionof complexity

5/35

(21)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

(22)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

6/35

(23)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

(24)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

6/35

(25)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

(26)

Idea: Enumeration algorithms

Idea:In real life, we do not want to computeall the matches we just need to be able toenumeratematches quickly

→ Formalization:enumeration algorithms

6/35

(27)

Formalizing an enumeration algorithm

Input

Step 1: Indexing

in O(input) Indexed input

Step 2: Enumeration

in O(result)

A B C

a b c a’ b c a b’ c a’ b’ c

Results

State

(28)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing in O(input)

Indexed input

Step 2: Enumeration

in O(result)

A B C

a b c a’ b c a b’ c a’ b’ c

Results

State

7/35

(29)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2: Enumeration

in O(result)

A B C

a b c a’ b c a b’ c a’ b’ c

Results

State

(30)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C

a b c a’ b c a b’ c a’ b’ c

Results

State

7/35

(31)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C a b c

a’ b c a b’ c a’ b’ c

Results

State

(32)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C a b c

a’ b c a b’ c a’ b’ c

Results

State 0011

7/35

(33)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C a b c

a’ b c a b’ c a’ b’ c

Results

State 0011

(34)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C

a b c

a’ b c

a b’ c a’ b’ c

Results

State 010001

7/35

(35)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C

a b c a’ b c

a b’ c

a’ b’ c

Results

State 01100111

(36)

Formalizing an enumeration algorithm

Input

Step 1:

Indexing

in O(input) Indexed input

Step 2:

Enumeration in O(result)

A B C

a b c a’ b c a b’ c

a’ b’ c Results

State

7/35

(37)

Main results

We are given:the treeT, a non-Boolean queryQin MSO

Example:Q(x,y)asks for pairs of a blue nodexand a pink nodey

We want:enumerate the results of the query

Here, the pairs of a pink node and blue node Theorem

[Bagan, 2006, Kazana and Segoufin, 2013]

For anyfixedMSO queryQ, given a treeT,

we can preprocessT inlinear time in Tand then enumerate each result inlinear time in the result

This was already known, so what’s new?

Modular proofbased on a notion ofset circuits

Tractable in combined complexityforQgiven as an automaton

Efficientlyupdatethe preprocessing when the treechanges

(38)

Main results

We are given:the treeT, a non-Boolean queryQin MSO

Example:Q(x,y)asks for pairs of a blue nodexand a pink nodey

We want:enumerate the results of the query

Here, the pairs of a pink node and blue node

Theorem

[Bagan, 2006, Kazana and Segoufin, 2013]

For anyfixedMSO queryQ, given a treeT,

we can preprocessT inlinear time in Tand then enumerate each result inlinear time in the result

This was already known, so what’s new?

Modular proofbased on a notion ofset circuits

Tractable in combined complexityforQgiven as an automaton

Efficientlyupdatethe preprocessing when the treechanges

8/35

(39)

Main results

We are given:the treeT, a non-Boolean queryQin MSO

Example:Q(x,y)asks for pairs of a blue nodexand a pink nodey

We want:enumerate the results of the query

Here, the pairs of a pink node and blue node Theorem

[Bagan, 2006, Kazana and Segoufin, 2013]

For anyfixedMSO queryQ, given a treeT,

we can preprocessT inlinear time in Tand then enumerate each result inlinear time in the result

This was already known, so what’s new?

Modular proofbased on a notion ofset circuits

Tractable in combined complexityforQgiven as an automaton

Efficientlyupdatethe preprocessing when the treechanges

(40)

Main results

We are given:the treeT, a non-Boolean queryQin MSO

Example:Q(x,y)asks for pairs of a blue nodexand a pink nodey

We want:enumerate the results of the query

Here, the pairs of a pink node and blue node

Theorem [Bagan, 2006, Kazana and Segoufin, 2013]

For anyfixedMSO queryQ, given a treeT,

we can preprocessT inlinear time in Tand then enumerate each result inlinear time in the result This was already known, so what’s new?

Modular proofbased on a notion ofset circuits

Tractable in combined complexityforQgiven as an automaton

Efficientlyupdatethe preprocessing when the treechanges

8/35

(41)

Main results

We are given:the treeT, a non-Boolean queryQin MSO

Example:Q(x,y)asks for pairs of a blue nodexand a pink nodey

We want:enumerate the results of the query

Here, the pairs of a pink node and blue node

Theorem [Bagan, 2006, Kazana and Segoufin, 2013]

For anyfixedMSO queryQ, given a treeT,

we can preprocessT inlinear time in Tand then enumerate each result inlinear time in the result This was already known, so what’s new?

Modular proofbased on a notion ofset circuits

(42)

Structure of the talk

Building a set circuit:given a treeT and automatonA, we can build aset circuitCthat represents the results

Enumeration on set circuits:given a set circuitC,

we can enumerate efficiently the results that it captures (under some assumptions onC)

New stuff:

• Tractability in theautomatonand application to text

• Efficientupdatesof the index

9/35

(43)

Structure of the talk

Building a set circuit:given a treeT and automatonA, we can build aset circuitCthat represents the results

Enumeration on set circuits:given a set circuitC,

we can enumerate efficiently the results that it captures (under some assumptions onC)

New stuff:

• Tractability in theautomatonand application to text

• Efficientupdatesof the index

(44)

Structure of the talk

Building a set circuit:given a treeT and automatonA, we can build aset circuitCthat represents the results

Enumeration on set circuits:given a set circuitC,

we can enumerate efficiently the results that it captures (under some assumptions onC)

New stuff:

• Tractability in theautomatonand application to text

• Efficientupdatesof the index

9/35

(45)

Building a set circuit

(46)

Monadic second-order logic (MSO)

P (x)means “xis blue”; alsoP (x),P (x)

xymeans “xis the parent ofy

Propositional logic:formulas withAND∧,OR∨,NOT¬

P (x)P (y)means“Nodexis pink and nodeyis blue”

First-order logic:addsexistential quantifier∃and universal quantifier∀

∃x y P (x)P (y)means“There is both a pink and a blue node”

Monadic second-order logic (MSO):addsquantifiers over sets

∃S∀x S(x)means“there is a setScontaining every elementx”

• Can expresstransitive closurexy, i.e.,“xis an ancestor ofy”

∀x P (x)⇒ ∃y P (y)xy

means“There is a blue node below every pink node”

10/35

(47)

Monadic second-order logic (MSO)

P (x)means “xis blue”; alsoP (x),P (x)

xymeans “xis the parent ofy

Propositional logic:formulas withAND∧,OR∨,NOT¬

P (x)P (y)means“Nodexis pink and nodeyis blue”

First-order logic:addsexistential quantifier∃and universal quantifier∀

∃x y P (x)P (y)means“There is both a pink and a blue node”

Monadic second-order logic (MSO):addsquantifiers over sets

∃S∀x S(x)means“there is a setScontaining every elementx”

• Can expresstransitive closurexy, i.e.,“xis an ancestor ofy”

∀x P (x)⇒ ∃y P (y)xy

means“There is a blue node below every pink node”

(48)

Monadic second-order logic (MSO)

P (x)means “xis blue”; alsoP (x),P (x)

xymeans “xis the parent ofy

Propositional logic:formulas withAND∧,OR∨,NOT¬

P (x)P (y)means“Nodexis pink and nodeyis blue”

First-order logic:addsexistential quantifier∃and universal quantifier∀

∃x y P (x)P (y)means“There is both a pink and a blue node”

Monadic second-order logic (MSO):addsquantifiers over sets

∃S∀x S(x)means“there is a setScontaining every elementx”

• Can expresstransitive closurexy, i.e.,“xis an ancestor ofy”

∀x P (x)⇒ ∃y P (y)xy

means“There is a blue node below every pink node”

10/35

(49)

Monadic second-order logic (MSO)

P (x)means “xis blue”; alsoP (x),P (x)

xymeans “xis the parent ofy

Propositional logic:formulas withAND∧,OR∨,NOT¬

P (x)P (y)means“Nodexis pink and nodeyis blue”

First-order logic:addsexistential quantifier∃and universal quantifier∀

∃x y P (x)P (y)means“There is both a pink and a blue node”

Monadic second-order logic (MSO):addsquantifiers over sets

∃S∀x S(x)means“there is a setScontaining every elementx”

(50)

Tree automata

Tree alphabet:

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

11/35

(51)

Tree automata

Tree alphabet:

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

(52)

Tree automata

Tree alphabet:

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

11/35

(53)

Tree automata

Tree alphabet:

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

(54)

Tree automata

Tree alphabet:

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

11/35

(55)

Tree automata

Tree alphabet:

B

P

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples): P

P

> B P

(56)

Tree automata

Tree alphabet:

B

P

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples):

P P

>

B P

11/35

(57)

Tree automata

Tree alphabet:

B

B

P

P

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples):

P P

>

B P

(58)

Tree automata

Tree alphabet:

>

B

B

P

P

Bottom-up deterministictree automaton

“Is there both a pink and a blue node?”

States:{⊥,B,P,>}

Final states: {>}

Initial function: ⊥ P B

Transitions(examples):

P P

>

B P

11/35

(59)

Boolean MSO query evaluation via automata

Theorem [Thatcher and Wright, 1968]

MSOandtree automatahave the sameexpressive poweron trees

Given a Boolean MSO query, we can compute a tree automaton that accepts precisely the trees on which the query holds

Complexity (in the query) is generally nonelementary Corollary

Evaluating a Boolean MSO query on a tree is inlinear timein the tree

(60)

Boolean MSO query evaluation via automata

Theorem [Thatcher and Wright, 1968]

MSOandtree automatahave the sameexpressive poweron trees

Given a Boolean MSO query, we can compute a tree automaton that accepts precisely the trees on which the query holds

Complexity (in the query) is generally nonelementary

Corollary

Evaluating a Boolean MSO query on a tree is inlinear timein the tree

12/35

(61)

Boolean MSO query evaluation via automata

Theorem [Thatcher and Wright, 1968]

MSOandtree automatahave the sameexpressive poweron trees

Given a Boolean MSO query, we can compute a tree automaton that accepts precisely the trees on which the query holds

Complexity (in the query) is generally nonelementary Corollary

Evaluating a Boolean MSO query on a tree is inlinear timein the tree

(62)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeTwithmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

13/35

(63)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeTwithmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

(64)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeTwithmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T) Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

13/35

(65)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeTwithmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

(66)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeT withmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

13/35

(67)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeT withmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula

ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Enumerate theways to color the tree

(68)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeT withmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree

13/35

(69)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeT withmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

Result: All theasuch thatQ(a)holds

All thewaysν to colorT such thatQ0 holds onν(T)

Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

(70)

A small hack for non-Boolean queries

Remember our problem on non-Boolean queries:

Data: AtreeT

AtreeT withmore colorsto select nodes

?

Query:Anon-BooleanMSOQ(x)formula ABooleanMSO formulaQ0

“What are the pairs of a pink and blue node?”

“Are the two selected nodes pink and blue?”

i

ResultAll the: All theasuch thatQ(a)holds

waysν to colorT such thatQ0 holds onν(T) Fortechnical reasonsit will be simpler to:

Write the choice for variablesas colors on the tree

Replace the non-Boolean queryQby a Boolean queryQ0

Enumerate theways to color the tree 13/35

(71)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,3,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

(72)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels

Valuation: {2,3,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

14/35

(73)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,3,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

(74)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {27→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

14/35

(75)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

(76)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

14/35

(77)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,3,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

The tree automatonAaccepts

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

(78)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {27→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

The tree automatonArejects

→ Theresultsthat we want to enumerate are allvaluationsofT that makeAaccept

14/35

(79)

Uncertain trees

Now: Boolean query on a tree where the color of nodes isuncertain 1

5

6 7 2

4 3

Avaluationof a tree decides whether to keep(1) ordiscard(0) node labels Valuation: {2,77→1, ∗ 7→0}

A:“Is there both a pink and a blue node?”

The tree automatonAaccepts

(80)

Set circuits

We want to represent these results as aset circuit:

×

x

>

×

y

Directed acyclic graph ofgates

Outputgate:

Variablegates: x

Constantgates: >

Internalgates: ×

15/35

(81)

Set circuits

We want to represent these results as aset circuit:

×

x

>

×

y

Directed acyclic graph ofgates

Outputgate:

Variablegates: x

Constantgates: >

Internalgates: ×

(82)

Set circuits

We want to represent these results as aset circuit:

×

x

>

×

y

Directed acyclic graph ofgates

Outputgate:

Variablegates: x

Constantgates: >

Internalgates: ×

15/35

(83)

Set circuits

We want to represent these results as aset circuit:

×

x

>

×

y

Directed acyclic graph ofgates

Outputgate:

Variablegates: x

Constantgates: >

Internalgates: ×

(84)

Set circuits

We want to represent these results as aset circuit:

×

x

>

×

y

Directed acyclic graph ofgates

Outputgate:

Variablegates: x

Constantgates: >

Internalgates: ×

15/35

(85)

Semantics of set circuits

×

x

>

×

y

{{x}} {{y}} {{}}

{{x}} {{x,y}} {{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

(86)

Semantics of set circuits

×

x

>

×

y {{x}} {{y}}

{{}}

{{x}} {{x,y}} {{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

16/35

(87)

Semantics of set circuits

×

x

>

×

y {{x}} {{y}}

{{}}

{{x}} {{x,y}} {{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

(88)

Semantics of set circuits

×

x

>

×

y {{x}} {{y}}

{{}}

{{x}} {{x,y}} {{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

16/35

(89)

Semantics of set circuits

×

x

>

×

y {{x}} {{y}}

{{}}

{{x}} {{x,y}}

{{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

(90)

Semantics of set circuits

×

x

>

×

y {{x}} {{y}}

{{}}

{{x}} {{x,y}}

{{x},{x,y}}

Every gategcapturesa setS(g)

Variablegate with labelx:S(g) :={{x}}

>-gates: S(g) ={{}}

-gates: S(g) =

×-gate with childreng1,g2:

S(g) :={s1s2|s1S(g1),s2S(g2)}

-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)

16/35

(91)

Set circuit for a query on a tree 1

5 6 7 2

4 3

Set circuitfor automatonAon uncertain treeT:

Variable gates: nodes ofT

Condition:Letνbe a valuation ofT, thenA acceptsν(T)iff the setS(g0)of the output gateg0 contains{n∈T |ν(n) =1}.

Query:Is there both a pink and a blue node?

×

∪ 7

2 3

×

×

× ×

∪ ∪ ∪ ∪

> 1 > 4 > 5 > 6

(92)

Set circuit for a query on a tree 1

5 6 7 2

4 3

Set circuitfor automatonAon uncertain treeT:

Variable gates: nodes ofT

Condition:Letνbe a valuation ofT, thenA acceptsν(T)iff the setS(g0)of the output gateg0 contains{n∈T |ν(n) =1}.

Query:Is there both a pink and a blue node?

×

∪ 7

2 3

×

×

× ×

∪ ∪ ∪ ∪

> 1 > 4 > 5 > 6

17/35

(93)

Set circuit for a query on a tree 1

5 6 7 2

4 3

Set circuitfor automatonAon uncertain treeT:

Variable gates: nodes ofT

Condition:Letνbe a valuation ofT, thenA acceptsν(T)iff the setS(g0)of the output gateg0 contains{n∈T |ν(n) =1}.

Query:Is there both a pink and a blue node?

×

∪ 7

2 3

×

×

× ×

∪ ∪ ∪ ∪

> 1 > 4 > 5 > 6

(94)

Set circuit for a query on a tree 1

5 6 7 2

4 3

Set circuitfor automatonAon uncertain treeT:

Variable gates: nodes ofT

Condition:Letνbe a valuation ofT, thenA acceptsν(T)iff the setS(g0)of the output gateg0 contains{n∈T |ν(n) =1}.

Query:Is there both a pink and a blue node?

×

∪ 7

2 3

×

×

× ×

∪ ∪ ∪ ∪

> 1 > 4 > 5 > 6

17/35

(95)

Set circuit for a query on a tree 1

5 6 7 2

4 3

Set circuitfor automatonAon uncertain treeT:

Variable gates: nodes ofT

Condition:Letνbe a valuation ofT, thenA acceptsν(T)iff the setS(g0)of the output gateg0 contains{n∈T |ν(n) =1}.

Query:Is there both a pink and a blue node?

×

∪ 7

2 3

×

×

× ×

∪ ∪ ∪ ∪

(96)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

> P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

18/35

(97)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

>

P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

(98)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

>

P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

18/35

(99)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

>

P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

(100)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

>

P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

18/35

(101)

Building set circuits

Theorem

For any bottom-uptree automatonAand inputtreeT, we can build a set circuitofAonTinO(|A| × |T|)

Alphabet:

Automaton:“Is there both a pink and a blue node?”

States:

{⊥,B,P,>}

Final: {>}

Transitions:

>

P

P P

n

n

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

∪ ∪ ∪ ∪

⊥ B P >

×

×

Références

Documents relatifs

Christmas tree lights.. Nativity scene

We give a simple proof of the “tree-width duality theorem” of Seymour and Thomas that the tree-width of a finite graph is exactly one less than the largest order of its brambles..

In the last 10 years or so, several weak limit theorems for the number of cuts have been obtained for Cayley trees (Panholzer [20,21]), complete binary trees (Janson [13]),

The most popular quantitative analysis technique for attack trees is the bottom-up computation approach, in which leaf nodes are assigned values rep- resenting attributes (e.g., cost

The problem of minimizing the number of states of a finite unranked tree au- tomaton is particularly relevant for classes of deterministic automata, since, for these

Stepwise tree automata were proved to have two nice properties that yield a simple proof of the theorem. 1) N-ary queries by UTAs can be translated to n-ary queries by stepwise

Ranked monadic run-based automata queries can always be expressed in ranked monadic Datalog; the reduction is in linear time.. The resulting Datalog program models the two phases of

We now show how to reduce the acceptance problem for a large class of infinite (complete) deterministic trees to the acceptance problem for equivalent (accord- ing to a suitable