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
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
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
Query evaluation
The main database problem isquery evaluation DataD: what we know
?
QueryQ: question asked about the datai
Result: all results of the queryQon the dataDMeasure of efficiency:computational complexity:
•
Combined complexity:D andQareinputs•
Data complexity:Qisfixed,Dis theinput2/35
Query evaluation
The main database problem isquery evaluation
DataD: what we know
?
QueryQ: question asked about the datai
Result: all results of the queryQon the dataDMeasure of efficiency:computational complexity:
•
Combined complexity:D andQareinputs•
Data complexity:Qisfixed,Dis theinputQuery evaluation
The main database problem isquery evaluation
DataD: what we know
?
QueryQ: question asked about the datai
Result: all results of the queryQon the dataDMeasure of efficiency:computational complexity:
•
Combined complexity:D andQareinputs•
Data complexity:Qisfixed,Dis theinput2/35
Query evaluation
The main database problem isquery evaluation
DataD: what we know
?
QueryQ: question asked about the datai
Result: all results of the queryQon the dataDMeasure of efficiency:computational complexity:
•
Combined complexity:DandQareinputsStructured 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
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
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
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”
•x→ymeans “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 elementaryQuery 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”
•x→ymeans “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 elementary4/35
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”
•x→ymeans “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 elementaryQuery 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”
•x→ymeans “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 elementary4/35
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 treechangesMain 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 treechanges8/35
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 treechangesMain 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 treechanges8/35
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 circuitsStructure 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
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
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
Building a set circuit
Monadic second-order logic (MSO)
•
P (x)means “xis blue”; alsoP (x),P (x)•
x→ymeans “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 closurex→∗y, i.e.,“xis an ancestor ofy”
• ∀x P (x)⇒ ∃y P (y)∧x→∗y
means“There is a blue node below every pink node”
10/35
Monadic second-order logic (MSO)
•
P (x)means “xis blue”; alsoP (x),P (x)•
x→ymeans “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 closurex→∗y, i.e.,“xis an ancestor ofy”
• ∀x P (x)⇒ ∃y P (y)∧x→∗y
means“There is a blue node below every pink node”
Monadic second-order logic (MSO)
•
P (x)means “xis blue”; alsoP (x),P (x)•
x→ymeans “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 closurex→∗y, i.e.,“xis an ancestor ofy”
• ∀x P (x)⇒ ∃y P (y)∧x→∗y
means“There is a blue node below every pink node”
10/35
Monadic second-order logic (MSO)
•
P (x)means “xis blue”; alsoP (x),P (x)•
x→ymeans “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”
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): PP ⊥
> B P
⊥
⊥
⊥
11/35
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): PP ⊥
> B P
⊥
⊥
⊥
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): PP ⊥
> B P
⊥
⊥
⊥
11/35
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): PP ⊥
> B P
⊥
⊥
⊥
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): PP ⊥
> B P
⊥
⊥
⊥
11/35
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): PP ⊥
> B P
⊥
⊥
⊥
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
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
⊥
⊥
⊥
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
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
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
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
A small hack for non-Boolean queries
Remember our problem on non-Boolean queries:
Data: AtreeT
AtreeTwithmore colorsto select nodes
?
Query:Anon-BooleanMSOQ(x)formulaABooleanMSO 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)holdsAll 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 tree13/35
A small hack for non-Boolean queries
Remember our problem on non-Boolean queries:
Data: AtreeT
AtreeTwithmore colorsto select nodes
?
Query:Anon-BooleanMSOQ(x)formulaABooleanMSO 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)holdsAll 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 treeA small hack for non-Boolean queries
Remember our problem on non-Boolean queries:
Data: AtreeT
AtreeTwithmore colorsto select nodes
?
Query:Anon-BooleanMSOQ(x)formulaABooleanMSO 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)holdsAll 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 tree13/35
A small hack for non-Boolean queries
Remember our problem on non-Boolean queries:
Data: AtreeT
AtreeTwithmore colorsto select nodes
?
Query:Anon-BooleanMSOQ(x)formulaABooleanMSO 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)holdsAll 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 treeA small hack for non-Boolean queries
Remember our problem on non-Boolean queries:
Data: AtreeT
AtreeT withmore colorsto select nodes
?
Query:Anon-BooleanMSOQ(x)formulaABooleanMSO 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)holdsAll 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 tree13/35
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)formulaABooleanMSO 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)holdsAll thewaysν to colorT such thatQ0 holds onν(T)
Fortechnical reasonsit will be simpler to:
•
•
Enumerate theways to color the treeA 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)holdsAll 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 tree13/35
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)holdsAll thewaysν to colorT such thatQ0 holds onν(T)
Fortechnical reasonsit will be simpler to:
•
Write the choice for variablesas colors on the treeA 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)holdswaysν 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/35Uncertain 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
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
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
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
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
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
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
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
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
Set circuits
We want to represent these results as aset circuit:
∪
×
x
>
×
y
•
Directed acyclic graph ofgates•
Outputgate:•
Variablegates: x•
Constantgates: > ⊥•
Internalgates: × ∪15/35
Set circuits
We want to represent these results as aset circuit:
∪
×
x
>
×
y
•
Directed acyclic graph ofgates•
Outputgate:•
Variablegates: x•
Constantgates: > ⊥•
Internalgates: × ∪Set circuits
We want to represent these results as aset circuit:
∪
×
x
>
×
y
•
Directed acyclic graph ofgates•
Outputgate:•
Variablegates: x•
Constantgates: > ⊥•
Internalgates: × ∪15/35
Set circuits
We want to represent these results as aset circuit:
∪
×
x
>
×
y
•
Directed acyclic graph ofgates•
Outputgate:•
Variablegates: x•
Constantgates: > ⊥•
Internalgates: × ∪Set circuits
We want to represent these results as aset circuit:
∪
×
x
>
×
y
•
Directed acyclic graph ofgates•
Outputgate:•
Variablegates: x•
Constantgates: > ⊥•
Internalgates: × ∪15/35
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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)16/35
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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)16/35
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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)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) :={s1∪s2|s1∈S(g1),s2∈S(g2)}
•
∪-gate with childreng1,g2: S(g) :=S(g1)∪S(g2)16/35
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
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
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
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
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
×
×
× ×
∪ ∪ ∪ ∪
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
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 >
×
×
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
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 >
×
×
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
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 >
×
×