SLIDE 1 Finding a Forest in a Tree
The matching problem for wide reactive systems
Giorgio Bacci, Marino Miculan, Romeo Rizzi
- Dept. of Computer Science, Aalborg University
Breakfast Talk (presented @ TGC 2014)
SLIDE 2 Outline of the talk
- Introduction
- The problem: forest matching
- NP-completeness
- Fixed-parameter Algorithm (the core only)
- Concluding remaks
SLIDE 3 Motivations
- Reactive systems (aka reduction systems)
are common in process calculi
- Defined by
- a set of reduction rules l(x)→r(x)
- a contextual closure
l(x)→r(x) a=C[l(x)σ] b=C[r(x)σ] a→b
- However: not always easy to apply,
especially in models of global computing
SLIDE 4 Ex: Message Passing
S1 S2 x
ā⟨M⟩.P | a(x).Q → P | Q[M/x] a
M
SLIDE 5 Ex: Message Passing
S1 S2 x
ā⟨M⟩.P | a(x).Q → P | Q[M/x]
M
SLIDE 6 C2 C1
Ex: Remote Message Passing
S1 S2 M x
C1[ā⟨M⟩.P] | C2[a(x).Q] → C1[P] | C2[Q{M/x}] a
SLIDE 7 C2 C1
Ex: Remote Message Passing
S1 S2 M x
C1[ā⟨M⟩.P] | C2[a(x).Q] → C1[P] | C2[Q{M/x}] a Infinite reduction rules are needed (one for each pair C1,C2)
SLIDE 8 ⟨C1 , C2⟩ S1 S2 M x
⟨ā⟨M⟩.P , a(x).Q⟩ → ⟨P , Q{M/x}⟩ a
Ex: Remote Message Passing
SLIDE 9 ⟨C1 , C2⟩ S1 S2 M x
⟨ā⟨M⟩.P , a(x).Q⟩ → ⟨P , Q{M/x}⟩ a Just one wide reduction rule Context has two holes
Ex: Remote Message Passing
SLIDE 10 Wide reactive systems
A set of wide reaction rules ⟨l1(x1),…, ln(xn)⟩ → ⟨r1(y1),…, rn(yn)⟩ with {y1,…, yn} ⊆ {x1,…, xn} Contextual closure:
⟨l1(x1),…, ln(xn)⟩ → ⟨r1(y1),…, rn(yn)⟩ a=C[l1(x1)σ,…, ln(xn)σ] b=C[r1(y1)σ,…, rn(yn)σ] a→b
SLIDE 11
Wide vs. Non-wide
SLIDE 12 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
SLIDE 13 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
- non-wide are a particular case of wide (width = 1)
SLIDE 14 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
- non-wide are a particular case of wide (width = 1)
- WRSs need less rules (often, finite instead of infinite)
SLIDE 15 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
- non-wide are a particular case of wide (width = 1)
- WRSs need less rules (often, finite instead of infinite)
- Pattern matching in WRSs is more complex
SLIDE 16 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
- non-wide are a particular case of wide (width = 1)
- WRSs need less rules (often, finite instead of infinite)
- Pattern matching in WRSs is more complex
- The bad news: NP-complete
SLIDE 17 Wide vs. Non-wide
- WRSs are more expressive than non-WRSs
- non-wide are a particular case of wide (width = 1)
- WRSs need less rules (often, finite instead of infinite)
- Pattern matching in WRSs is more complex
- The bad news: NP-complete
- The good news: combinatorial explosion depends on
redex width only (constant and usually ≤3)
SLIDE 18 Linear Context Trees
T(X) :: 0 empty tree x leaf (x ∈ X) m[ T(X)] labeled tree T(X’) | T(X’’) siblings (X = X’ ⊎ X’’) =
T(X) T(Y) m n
m[ T(X)] | n[T(Y)]
SLIDE 19 Linear Context Trees
T(X) :: 0 empty tree x leaf (x ∈ X) m[ T(X)] labeled tree T(X’) | T(X’’) siblings (X = X’ ⊎ X’’) =
Unordered
(up to structural congruence ≡) T(X) T(Y) m n
m[ T(X)] | n[T(Y)]
SLIDE 20 S
...
The matching problem
T ≡ (C{S/z}){D ,...,D /x ,...,x }
1 m 1 m
D D
1 m
C T ≡ Context Pattern Parameters
SLIDE 21 S
... T ≡ (C{S ,...,S /z ,..., z }){D ,...,D /x ,...,x }
1 h 1 h 1 m 1 m
D D
1 m
C T ≡ Context Pattern list Parameters
forest
1
S
...
h
... ...
The matching problem
SLIDE 22 Forest matching is NP-complete
- Tree matching problem is in P
(subtree isomorphim algorithm [Matula’78])
- Forest matching problem is NP-complete!
S
... D D
1 m
C
1
S
...
h
... ... The pattern matchings must not overlap = antichain in T
SLIDE 23 Forest matching is NP-complete
- Tree matching problem is in P
(subtree isomorphim algorithm [Matula’78])
- Forest matching problem is NP-complete!
S
... D D
1 m
C
1
S
...
h
... ... The pattern matchings must not overlap = antichain in T
≠ sub-forest isomorphism
SLIDE 24
Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T.
SLIDE 25
Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T. Proof sketch of NP-hardness
SLIDE 26 Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T.
reduction from 3-SAT
Proof sketch of NP-hardness
SLIDE 27 Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T. ( x v y v z ) ( x v y v z ) _ _ v
C1 C2
reduction from 3-SAT
Proof sketch of NP-hardness
SLIDE 28 Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T. ( x v y v z ) ( x v y v z ) _ _ v
C1 C2
x
x
_ y
y
_ z
z
_
C2 C2 C2 C1 C1 C1
reduction from 3-SAT
Proof sketch of NP-hardness
SLIDE 29 Rainbow antichain
Instance: a tree T colored on palette P of colors. Problem: to find a P-colorful antichain in T. ( x v y v z ) ( x v y v z ) _ _ v
C1 C2
x
x
_ y
y
_ z
z
_
C2 C2 C2 C1 C1 C1
reduction from 3-SAT
every truth assignment satisfying the formula induces a rainbow antichain ...and vice versa
Proof sketch of NP-hardness
SLIDE 30 Fixed-parameter Tractability
How to cope with computational intractability?
approximation algorithms, average case analysis, randomized algorithms, heuristics methods, etc...
SLIDE 31 Fixed-parameter Tractability
How to cope with computational intractability?
approximation algorithms, average case analysis, randomized algorithms, heuristics methods, etc... [Downey-Fellows’99] FPT’s basic observation: “for many hard problems, the seemingly inherent combinatorial explosion really can be restricted to a ‘small part’ of the input, the parameter”
SLIDE 32 Parameterized algorithm for Rainbow antichain
- Rainbow antichain is the core problem
behind the forest matching problem
- Rainbow antichain is solved in 2 steps:
- 1. Reduction to kernel-size of the input tree
- 2. Exhaustive search of a rainbow antichain
SLIDE 33 Parameterized algorithm for Rainbow antichain
- Rainbow antichain is the core problem
behind the forest matching problem
- Rainbow antichain is solved in 2 steps:
- 1. Reduction to kernel-size of the input tree
- 2. Exhaustive search of a rainbow antichain
parameter: size of P
SLIDE 34
- 1. Reduction by decoloring
delete u Deletion of uncolored nodes does not influence existence of rainbow antichain!
u x y v x y v
(*) we will assume the root cannot be deleted
SLIDE 35 Decoloring (rule 1)
u
decolor u
u
Ancestors with the same color can be decolored
SLIDE 36 Decoloring (rule 2)
u
decolor u If the tree has all leaves of the same color, then leaves with fan-out ≥ |P| can be decolored
u
fout(u) = 4 (*) fout(u) = out-degree of the whole path from u to the root
SLIDE 37
How to apply the rules?
(an example of reduction to kernel size)
P = { red, yellow, green }
SLIDE 38
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 39
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 40
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 41
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 42
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 43
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 44
How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
SLIDE 45 How to apply the rules?
(an example of reduction to kernel size)
Rule 1: Decoloring of ancestors of the same color
Uncolored nodes can be removed
SLIDE 46
How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
SLIDE 47 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
Only leaves with the same color
SLIDE 48
How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
SLIDE 49 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6
SLIDE 50 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6
SLIDE 51 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 5
SLIDE 52 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 5
SLIDE 53 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 4 fout(u) = 5
SLIDE 54 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 4 fout(u) = 5
SLIDE 55 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 3 fout(u) = 4 fout(u) = 5
SLIDE 56 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 3 fout(u) = 4 fout(u) = 5
SLIDE 57 How to apply the rules?
(an example of reduction to kernel size)
Rule 2: Decoloring of nodes with fan-out ≥ |P|
fout(u) = 6 fout(u) = 3 fout(u) = 4 fout(u) = 5
and repeat for each color...
SLIDE 58
How to apply the rules?
(an example of reduction to kernel size)
...to obtain the reduced tree
SLIDE 59 Reduction to Kernel-Size
- by repeating rule 1 ... height(T) ≤ |P|
- by repeating rule 2 ... |c-color(T)| ≤ 2|P|
SLIDE 60 Reduction to Kernel-Size
- by repeating rule 1 ... height(T) ≤ |P|
- by repeating rule 2 ... |c-color(T)| ≤ 2|P|
No repetitions of colors in a path from the root to a leaf
SLIDE 61 Reduction to Kernel-Size
- by repeating rule 1 ... height(T) ≤ |P|
- by repeating rule 2 ... |c-color(T)| ≤ 2|P|
No repetitions of colors in a path from the root to a leaf If max{ fout(n) | n node in T } ≤ m, then T has at most 2|P| leaves
SLIDE 62 Reduction to Kernel-Size
- by repeating rule 1 ... height(T) ≤ |P|
- by repeating rule 2 ... |c-color(T)| ≤ 2|P|
as a result |nodes(T)| ≤ |P| 2|P|
No repetitions of colors in a path from the root to a leaf If max{ fout(n) | n node in T } ≤ m, then T has at most 2|P| leaves
SLIDE 63
- 2. Searching for a rainbow
using the fast subset convolution algorithm by [Björklund et al. STOC’97] A(T, X) = N(T, X) v (A(T’,Y) A(T’’,Y \ X)) v
Y⊆X
T’
... T = T’’
SLIDE 64
- 2. Searching for a rainbow
using the fast subset convolution algorithm by [Björklund et al. STOC’97] A(T, X) = N(T, X) v (A(T’,Y) A(T’’,Y \ X)) v
Y⊆X
T’
... T = T’’
true iff T contains all the colors in X⊆P
SLIDE 65
- 2. Searching for a rainbow
using the fast subset convolution algorithm by [Björklund et al. STOC’97] A(T, X) = N(T, X) v (A(T’,Y) A(T’’,Y \ X)) v
Y⊆X
T’
... T = T’’
true iff T contains all the colors in X⊆P
O(|P|2 2|P|) for each node:
SLIDE 66 From Forest Matching to Rainbow Antichain
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z ⟨m[x] | n[0] , m[0]⟩
Target T Forest pattern S
SLIDE 67 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z ⟨m[x] | n[0] , m[0]⟩
Target T Forest pattern S
SLIDE 68 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z ⟨m[x] | n[0] , m[0]⟩
Target T Forest pattern S subtrees isomorphisms
SLIDE 69 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z ⟨m[x] | n[0] , m[0]⟩
Target T Forest pattern S
are freely matchable
subtrees isomorphisms
SLIDE 70 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z ⟨m[x] | n[0] , m[0]⟩
Target T Forest pattern S
closed nodes can only be matched by closed nodes
are freely matchable
subtrees isomorphisms
SLIDE 71 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z
Target T Forest pattern S
1 2
the reduction is done on a 2-level palette
⟨m[x] | n[0] , m[0]⟩
SLIDE 72 From Forest Matching to Rainbow Antichain
m k m n * n n n m * * m
n[0] | m[x | n[0]] | k[n[y]] | m[0] | z
Target T Forest pattern S
the rainbow antichain is found on the children’s palette 1 2
the reduction is done on a 2-level palette
⟨m[x] | n[0] , m[0]⟩
SLIDE 73 Forest matching is Fixed Parameter Tractable
- subtree isomorphisms:
- reduction to kernel size:
- exhaustive search of antichains: O(h3 k 22h)
O(|T|) O(|S| |T|3/2) h = “# trees in pattern S” k = “max # of 1 -level children in S”
st Parameters
SLIDE 74 Forest matching is Fixed Parameter Tractable
- subtree isomorphisms:
- reduction to kernel size:
- exhaustive search of antichains: O(h3 k 22h)
O(|T|) O(|S| |T|3/2) h = “# trees in pattern S” k = “max # of 1 -level children in S”
st Parameters
O(h3 k 22h) + O(|S| |T|3/2)
Total:
SLIDE 75 Conclusions
- WRSs yield simpler and smaller semantics
- We have shown that matching for WRSs is feasible:
- exponential in redex width (constant and small)
- but polynomial in the size of agent
- Side result: rainbow antichain problem
- Applications: abstract machines (distributed π, Ambients,
CaSPiS, etc.) and bigraphic reactive systems
- Future work: quantitative variants (probabilistic, etc.)
SLIDE 76
Thanks for your attention