Non-linear Associative-Commutative Many-to-One Pattern...
Transcript of Non-linear Associative-Commutative Many-to-One Pattern...
Non-linear Associative-CommutativeMany-to-One Pattern Matching with
Sequence Variables
Manuel Krebber
June 30, 2017
Manuel Krebber | June 30, 2017 0/31
Non-linear Associative-Commutative Many-to-One Pattern Matching with Sequence Variables
Manuel Krebber | June 30, 2017 1/31
1 Introduction
2 Types of Matching
3 Algorithms
4 Experiments
5 Conclusions
Introduction
Table of Contents
Manuel Krebber | June 30, 2017 2/31
Function Symbols: f , g
Constant Symbols: a, b, c
Variables: x
x
x ,yyy
Examples: a, f (xxx , b),f (g(a, b), c)
f
g
a
b
c
Introduction
Term
Manuel Krebber | June 30, 2017 3/31
Function Symbols: f , g
Constant Symbols: a, b, c
Variables: x
x
x ,yyy
Examples: a, f (xxx , b),f (g(a, b), c)
f
g
a
b
c
Introduction
Term
Manuel Krebber | June 30, 2017 3/31
Function Symbols: f , g
Constant Symbols: a, b, c
Variables: x
x
x ,yyy
Examples: a, f (xxx , b),f (g(a, b), c)
f
g
a
b
c
Introduction
Term
Manuel Krebber | June 30, 2017 3/31
Function Symbols: f , g
Constant Symbols: a, b, c
Variables: x
x
x ,yyy
Examples: a, f (xxx , b),f (g(a, b), c)
f
g
a
b
c
Introduction
Term
Manuel Krebber | June 30, 2017 3/31
Definition: Find substitution � : X 9 T such that�̂(pattern) = subject
Example: f (xxx ,yyy)
f (a, g(b))
x
x
x 7! a
y
y
y 7! g(b)
Subject:
Pattern:
Introduction
Pattern Matching
Manuel Krebber | June 30, 2017 4/31
Definition: Find substitution � : X 9 T such that�̂(pattern) = subject
Example: f (xxx ,yyy)
f (a, g(b))
x
x
x 7! a
y
y
y 7! g(b)
Subject:
Pattern:
Introduction
Pattern Matching
Manuel Krebber | June 30, 2017 4/31
Definition: Find substitution � : X 9 T such that�̂(pattern) = subject
Example: f (xxx ,yyy)
f (a, g(b))
x
x
x 7! a
y
y
y 7! g(b)
Subject:
Pattern:
Introduction
Pattern Matching
Manuel Krebber | June 30, 2017 4/31
I Functional programming languages
I Computer algebra systems (Mathematica)I Term rewriting systemsI In this case: Linear Algebra
Introduction
Applications
Manuel Krebber | June 30, 2017 5/31
I Functional programming languagesI Computer algebra systems (Mathematica)
I Term rewriting systemsI In this case: Linear Algebra
Introduction
Applications
Manuel Krebber | June 30, 2017 5/31
I Functional programming languagesI Computer algebra systems (Mathematica)I Term rewriting systems
I In this case: Linear Algebra
Introduction
Applications
Manuel Krebber | June 30, 2017 5/31
I Functional programming languagesI Computer algebra systems (Mathematica)I Term rewriting systemsI In this case: Linear Algebra
Introduction
Applications
Manuel Krebber | June 30, 2017 5/31
1 Introduction
2 Types of Matching
3 Algorithms
4 Experiments
5 Conclusions
Types of Matching
Table of Contents
Manuel Krebber | June 30, 2017 6/31
I Syntactic
I Linear (xxx + y
y
y) vs. non-linear (xxx + x
x
x)I Sequence variablesI AssociativityI CommutativityI Many-to-one vs. one-to-one
Types of Matching
Types of Matching
Manuel Krebber | June 30, 2017 7/31
I SyntacticI Linear (xxx + y
y
y) vs. non-linear (xxx + x
x
x)
I Sequence variablesI AssociativityI CommutativityI Many-to-one vs. one-to-one
Types of Matching
Types of Matching
Manuel Krebber | June 30, 2017 7/31
I SyntacticI Linear (xxx + y
y
y) vs. non-linear (xxx + x
x
x)I Sequence variablesI AssociativityI Commutativity
I Many-to-one vs. one-to-one
Types of Matching
Types of Matching
Manuel Krebber | June 30, 2017 7/31
I SyntacticI Linear (xxx + y
y
y) vs. non-linear (xxx + x
x
x)I Sequence variablesI AssociativityI CommutativityI Many-to-one vs. one-to-one
Types of Matching
Types of Matching
Manuel Krebber | June 30, 2017 7/31
(A⇥ B)⇥ C
⇥
⇥
A B
C
=A⇥ (B ⇥ C )
⇥
A
⇥
B C
Canonical VariadicForm
Types of Matching
Associativity I
Manuel Krebber | June 30, 2017 8/31
(A⇥ B)⇥ C
⇥
⇥
A B
C
=A⇥ (B ⇥ C )
⇥
A
⇥
B C
Canonical VariadicForm
Types of Matching
Associativity I
Manuel Krebber | June 30, 2017 8/31
(A⇥ B)⇥ C
⇥
⇥
A B
C
=A⇥ (B ⇥ C )
⇥
A
⇥
B C
= A⇥ B ⇥ C
⇥
A B C
Canonical VariadicForm
Types of Matching
Associativity I
Manuel Krebber | June 30, 2017 8/31
X
X
X ⇥M3
⇥
X
X
X
M3
(M1 ⇥M2)⇥M3
⇥
⇥
M1 M2
M3
M1 ⇥M2 ⇥M3
⇥
M1 M2 M3
� = {XXX 7! (M1 ⇥M2)}
Types of Matching
Associativity II
Manuel Krebber | June 30, 2017 9/31
X
X
X ⇥M3
⇥
X
X
X
M3
(M1 ⇥M2)⇥M3
⇥
⇥
M1 M2
M3
M1 ⇥M2 ⇥M3
⇥
M1 M2 M3
� = {XXX 7! (M1 ⇥M2)}
Types of Matching
Associativity II
Manuel Krebber | June 30, 2017 9/31
X
X
X ⇥M3
⇥
X
X
X
M3
(M1 ⇥M2)⇥M3
⇥
⇥
M1 M2
M3
M1 ⇥M2 ⇥M3
⇥
M1 M2 M3
� = {XXX 7! (M1 ⇥M2)}
Types of Matching
Associativity II
Manuel Krebber | June 30, 2017 9/31
X
X
X ⇥M3
⇥
X
X
X
M3
(M1 ⇥M2)⇥M3
⇥
⇥
M1 M2
M3
M1 ⇥M2 ⇥M3
⇥
M1 M2 M3
� = {XXX 7! (M1 ⇥M2)}
Types of Matching
Associativity II
Manuel Krebber | June 30, 2017 9/31
Can match a sequence of terms
Notation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Can match a sequence of termsNotation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Can match a sequence of termsNotation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Can match a sequence of termsNotation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Can match a sequence of termsNotation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Can match a sequence of termsNotation: x
x
x
⇤⇤⇤ star variable, xxx+++ plus variablestar variables can match empty sequence
Example: �(f (a,xxx+++, d)) = f (a, b, c , d)� = {xxx+++ 7! (b, c)}
Associativity: �(fa(a,xxx , d)) = fa(a, b, c , d)� = {xxx 7! fa(b, c)}
Types of Matching
Sequence Variables
Manuel Krebber | June 30, 2017 10/31
Ia+ b = b + a
I Sort the arguments: d + a+ c + b ! a+ b + c + d
I Every permutation could match:n! with n = |subject|
Types of Matching
Commutativity
Manuel Krebber | June 30, 2017 11/31
Ia+ b = b + a
I Sort the arguments: d + a+ c + b ! a+ b + c + d
I Every permutation could match:n! with n = |subject|
Types of Matching
Commutativity
Manuel Krebber | June 30, 2017 11/31
Ia+ b = b + a
I Sort the arguments: d + a+ c + b ! a+ b + c + d
I Every permutation could match:n! with n = |subject|
Types of Matching
Commutativity
Manuel Krebber | June 30, 2017 11/31
Synt Assoc SeqVar Comm All
Max. # matches 1�n�1m�1
� �n+m�1m�1
�n! n
m
NP complete no yes yes yes yes
n = |subject|, m = |pattern|
Types of Matching
Complexity
Manuel Krebber | June 30, 2017 12/31
I Many patterns, one subject
I Speedup by simultaneous matchingI Use similarity between patterns
Types of Matching
Many-to-one Matching
Manuel Krebber | June 30, 2017 13/31
I Many patterns, one subjectI Speedup by simultaneous matching
I Use similarity between patterns
Types of Matching
Many-to-one Matching
Manuel Krebber | June 30, 2017 13/31
I Many patterns, one subjectI Speedup by simultaneous matchingI Use similarity between patterns
Types of Matching
Many-to-one Matching
Manuel Krebber | June 30, 2017 13/31
Algorithms
Table of Contents
Manuel Krebber | June 30, 2017 14/31
Algorithms - One-to-One
Table of Contents
Manuel Krebber | June 30, 2017 15/31
Example: Subject f (a, b) and pattern f (xxx⇤⇤⇤,yyy⇤⇤⇤)
I Try every possible distributionI Generate (weak) compositions:
0 + 2 = 2 {xxx⇤⇤⇤ 7! (),yyy⇤⇤⇤ 7! (a, b)}1 + 1 = 2 {xxx⇤⇤⇤ 7! (a),yyy⇤⇤⇤ 7! (b)}2 + 0 = 2 {xxx⇤⇤⇤ 7! (a, b),yyy⇤⇤⇤ 7! ()}
I Backtracking
Algorithms - One-to-One
Associative and Sequence Variables
Manuel Krebber | June 30, 2017 16/31
Example: Subject f (a, b) and pattern f (xxx⇤⇤⇤,yyy⇤⇤⇤)
I Try every possible distribution
I Generate (weak) compositions:
0 + 2 = 2 {xxx⇤⇤⇤ 7! (),yyy⇤⇤⇤ 7! (a, b)}1 + 1 = 2 {xxx⇤⇤⇤ 7! (a),yyy⇤⇤⇤ 7! (b)}2 + 0 = 2 {xxx⇤⇤⇤ 7! (a, b),yyy⇤⇤⇤ 7! ()}
I Backtracking
Algorithms - One-to-One
Associative and Sequence Variables
Manuel Krebber | June 30, 2017 16/31
Example: Subject f (a, b) and pattern f (xxx⇤⇤⇤,yyy⇤⇤⇤)
I Try every possible distributionI Generate (weak) compositions:
0 + 2 = 2 {xxx⇤⇤⇤ 7! (),yyy⇤⇤⇤ 7! (a, b)}1 + 1 = 2 {xxx⇤⇤⇤ 7! (a),yyy⇤⇤⇤ 7! (b)}2 + 0 = 2 {xxx⇤⇤⇤ 7! (a, b),yyy⇤⇤⇤ 7! ()}
I Backtracking
Algorithms - One-to-One
Associative and Sequence Variables
Manuel Krebber | June 30, 2017 16/31
Example: Subject f (a, b) and pattern f (xxx⇤⇤⇤,yyy⇤⇤⇤)
I Try every possible distributionI Generate (weak) compositions:
0 + 2 = 2 {xxx⇤⇤⇤ 7! (),yyy⇤⇤⇤ 7! (a, b)}1 + 1 = 2 {xxx⇤⇤⇤ 7! (a),yyy⇤⇤⇤ 7! (b)}2 + 0 = 2 {xxx⇤⇤⇤ 7! (a, b),yyy⇤⇤⇤ 7! ()}
I Backtracking
Algorithms - One-to-One
Associative and Sequence Variables
Manuel Krebber | June 30, 2017 16/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 6! = 720
Match: � = {zzz 7! e}
1. Constant terms2. Matched variables3. Terms containing variables4. Repeat step 25. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 6! = 720
Match: � = {zzz 7! e}1. Constant terms
2. Matched variables3. Terms containing variables4. Repeat step 25. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 4! = 24
Match: � = {zzz 7! e}1. Constant terms2. Matched variables
3. Terms containing variables4. Repeat step 25. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 3! = 6
Match: � = {zzz 7! e,xxx 7! b}1. Constant terms2. Matched variables3. Terms containing variables
4. Repeat step 25. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 2! = 6
Match: � = {zzz 7! e,xxx 7! b}1. Constant terms2. Matched variables3. Terms containing variables4. Repeat step 2
5. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 1! = 1
Match: � = {zzz 7! e,xxx 7! b}1. Constant terms2. Matched variables3. Terms containing variables4. Repeat step 25. Regular Variables
6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Pattern: fc(a, g(c , d), g(xxx),xxx ,yyy⇤⇤⇤, zzz)Subject: fc(a, b, g(b), c , g(c , d), e) Permutations: 1! = 1
Match: � = {zzz 7! e,xxx 7! b,yyy⇤⇤⇤ 7! HcI}1. Constant terms2. Matched variables3. Terms containing variables4. Repeat step 25. Regular Variables6. Sequence Variables
Algorithms - One-to-One
Steps of Commutative Matching
Manuel Krebber | June 30, 2017 17/31
Match fc(xxx+++,xxx+++,yyy⇤⇤⇤) and fc(a, a, a, b, b, c)
Solve linear diophantine equations (using Extended Euclidean Alg.):
3 = 2xa + ya
2 = 2xb + yb
1 = 2xc + yc
1 xa + xb + xc
Solutions: {x 7! {a, b}, y 7! {a, c}}{x 7! {a}, y 7! {a, b, b, c}}{x 7! {b}, y 7! {a, a, a, c}}
Algorithms - One-to-One
Commutativity + Sequence Variables
Manuel Krebber | June 30, 2017 18/31
Match fc(xxx+++,xxx+++,yyy⇤⇤⇤) and fc(a, a, a, b, b, c)
Solve linear diophantine equations (using Extended Euclidean Alg.):
3 = 2xa + ya
2 = 2xb + yb
1 = 2xc + yc
1 xa + xb + xc
Solutions: {x 7! {a, b}, y 7! {a, c}}{x 7! {a}, y 7! {a, b, b, c}}{x 7! {b}, y 7! {a, a, a, c}}
Algorithms - One-to-One
Commutativity + Sequence Variables
Manuel Krebber | June 30, 2017 18/31
Match fc(xxx+++,xxx+++,yyy⇤⇤⇤) and fc(a, a, a, b, b, c)
Solve linear diophantine equations (using Extended Euclidean Alg.):
3 = 2xa + ya
2 = 2xb + yb
1 = 2xc + yc
1 xa + xb + xc
Solutions: {x 7! {a, b}, y 7! {a, c}}{x 7! {a}, y 7! {a, b, b, c}}{x 7! {b}, y 7! {a, a, a, c}}
Algorithms - One-to-One
Commutativity + Sequence Variables
Manuel Krebber | June 30, 2017 18/31
Algorithms - Many-to-One
Table of Contents
Manuel Krebber | June 30, 2017 19/31
Patterns: f (1,xxx⇤⇤⇤), f (1), f (yyy , 0)
f (1))
f (1,xxx⇤⇤⇤))x
x
x
⇤⇤⇤1
f (yyy , 0))0y
y
y
f (
Subject: f (1, 0)Match: f (yyy , 0) with {yyy 7! 1}
Algorithms - Many-to-One
Discrimination Net
Manuel Krebber | June 30, 2017 20/31
Patterns: f (1,xxx⇤⇤⇤), f (1), f (yyy , 0)
f (1))
f (1,xxx⇤⇤⇤))x
x
x
⇤⇤⇤1
f (yyy , 0))0y
y
y
f (
Subject: f (1, 0)Match: f (yyy , 0) with {yyy 7! 1}
Algorithms - Many-to-One
Discrimination Net
Manuel Krebber | June 30, 2017 20/31
Patterns: f (1,xxx⇤⇤⇤), f (1), f (yyy , 0)
f (1))
f (1,xxx⇤⇤⇤))x
x
x
⇤⇤⇤1
f (yyy , 0))0y
y
y
f (
Subject: f (1, 0)Match: f (yyy , 0) with {yyy 7! 1}
Algorithms - Many-to-One
Discrimination Net
Manuel Krebber | June 30, 2017 20/31
Patterns: f (1,xxx⇤⇤⇤), f (1), f (yyy , 0)
f (1))
f (1,xxx⇤⇤⇤))x
x
x
⇤⇤⇤1
f (yyy , 0))0y
y
y
f (
Subject: f (1, 0)Match: f (1,xxx⇤⇤⇤) with {xxx⇤⇤⇤ 7! (0)}
Algorithms - Many-to-One
Discrimination Net
Manuel Krebber | June 30, 2017 20/31
Multi Layer Discrimination Net (MLDN)
5a
a
4g(a))
a
3g(b))
b
2g(xxx))
x
xx
g(
1x
x
x
x
xx
fc(a,xxx ,xxx)H1, 1, 5I
fc(a, g(xxx), g(a))
H2, 4, 5Ifc(g(b), g(xxx))
H2, 3Ifc
fc(a, g(a), g(a)) ) H1, 1, 1, 2, 2, 4, 4, 5I
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 21/31
Multi Layer Discrimination Net (MLDN)
5a
a
4g(a))
a
3g(b))
b
2g(xxx))
x
xx
g(
1x
x
x
x
xx
fc(a,xxx ,xxx)H1, 1, 5I
fc(a, g(xxx), g(a))
H2, 4, 5Ifc(g(b), g(xxx))
H2, 3Ifc
fc(a, g(a), g(a)) ) H1, 1, 1, 2, 2, 4, 4, 5I
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 21/31
1. Match subject arguments with nested DN
2. Build bipartite graph from matches3. Enumerate all maximum matchings (Hopcroft-Karp, Uno)4. Combine substitutions from matching5. Match sequence variables
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 22/31
1. Match subject arguments with nested DN2. Build bipartite graph from matches
3. Enumerate all maximum matchings (Hopcroft-Karp, Uno)4. Combine substitutions from matching5. Match sequence variables
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 22/31
1. Match subject arguments with nested DN2. Build bipartite graph from matches3. Enumerate all maximum matchings (Hopcroft-Karp, Uno)
4. Combine substitutions from matching5. Match sequence variables
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 22/31
1. Match subject arguments with nested DN2. Build bipartite graph from matches3. Enumerate all maximum matchings (Hopcroft-Karp, Uno)4. Combine substitutions from matching
5. Match sequence variables
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 22/31
1. Match subject arguments with nested DN2. Build bipartite graph from matches3. Enumerate all maximum matchings (Hopcroft-Karp, Uno)4. Combine substitutions from matching5. Match sequence variables
Algorithms - Many-to-One
Many-to-One for Commutative
Manuel Krebber | June 30, 2017 22/31
f (a, b)
f (a, a)
f (yyy , b)
f (xxx ,yyy)
Subjectfc(f (a, b), f (a, a))
Patternfc(f (yyy , b), f (xxx ,yyy))
{yyy 7! a}
{x
x
x 7!a,y
y
y 7!b}
{xxx 7! a,yyy 7! a}
Algorithms - Many-to-One
Bipartite Graph
Manuel Krebber | June 30, 2017 23/31
f (a, b)
f (a, a)
f (yyy , b)
f (xxx ,yyy)
Subjectfc(f (a, b), f (a, a))
Patternfc(f (yyy , b), f (xxx ,yyy))
{yyy 7! a}
{x
x
x 7!a,y
y
y 7!b}
{xxx 7! a,yyy 7! a}
Algorithms - Many-to-One
Bipartite Graph
Manuel Krebber | June 30, 2017 23/31
f (a, b)
f (a, a)
f (a,xxx)
f (xxx ,yyy)
Subjectfc(f (a, b), f (a, a))
Patternfc(f (a,xxx), f (xxx ,yyy))
{xxx 7! b}
{x
x
x 7!a,y
y
y 7!b}
{xxx 7! a,yyy 7! a}
Algorithms - Many-to-One
Bipartite Graph
Manuel Krebber | June 30, 2017 23/31
f (a, b)
f (a, a)
f (a,xxx)
f (xxx ,yyy)
Subjectfc(f (a, b), f (a, a))
Patternfc(f (a,xxx), f (xxx ,yyy))
{xxx 7! b}
{x
x
x 7!a,y
y
y 7!b}
{xxx 7! a,yyy 7! a}
Algorithms - Many-to-One
Bipartite Graph
Manuel Krebber | June 30, 2017 23/31
Experiments
Table of Contents
Manuel Krebber | June 30, 2017 24/31
I Python implementation
I Open source on Github:https://github.com/hpac/matchpy
Experiments
MatchPy
Manuel Krebber | June 30, 2017 25/31
I Python implementationI Open source on Github:
https://github.com/hpac/matchpy
Experiments
MatchPy
Manuel Krebber | June 30, 2017 25/31
I ⇠ 200 patterns for BLAS/LAPACK kernels, e.g. ↵↵↵⇥A
A
A
T⇥B
B
B
I Supported operations:
Operation Symbol Arity Properties
Multiplication ⇥ variadic associativeAddition + variadic associative, commutativeTransposition T unaryInversion �1 unaryInverse Transposition �T unary
Experiments
Linear Algebra Example
Manuel Krebber | June 30, 2017 26/31
I ⇠ 200 patterns for BLAS/LAPACK kernels, e.g. ↵↵↵⇥A
A
A
T⇥B
B
B
I Supported operations:
Operation Symbol Arity Properties
Multiplication ⇥ variadic associativeAddition + variadic associative, commutativeTransposition T unaryInversion �1 unaryInverse Transposition �T unary
Experiments
Linear Algebra Example
Manuel Krebber | June 30, 2017 26/31
50 100 150
0
20
40
60
Number of Patterns
SetupTim
e[m
s]
Setup Time
50 100 150
0
5
10
Number of Patterns
Match
Tim
e[m
s]
Match Time
matchMTOM
Experiments
Match Times
Manuel Krebber | June 30, 2017 27/31
50 100 1500
5
10
15
20
Number of Patterns
Speedup
Speedup
50 100 1500
2
4
6
8
Number of PatternsNumber
ofSubjects
Break Even
Experiments
Speedup
Manuel Krebber | June 30, 2017 28/31
Conclusions
Table of Contents
Manuel Krebber | June 30, 2017 29/31
I Generalized discrimination nets
I Many-to-one matching
Isequence variables
Iseparate associativity/commutativity
I Open source implementation
Conclusions
Contributions
Manuel Krebber | June 30, 2017 30/31
I Generalized discrimination netsI Many-to-one matching
Isequence variables
Iseparate associativity/commutativity
I Open source implementation
Conclusions
Contributions
Manuel Krebber | June 30, 2017 30/31
I Generalized discrimination netsI Many-to-one matching
Isequence variables
Iseparate associativity/commutativity
I Open source implementation
Conclusions
Contributions
Manuel Krebber | June 30, 2017 30/31
I Generalized discrimination netsI Many-to-one matching
Isequence variables
Iseparate associativity/commutativity
I Open source implementation
Conclusions
Contributions
Manuel Krebber | June 30, 2017 30/31
I Generalized discrimination netsI Many-to-one matching
Isequence variables
Iseparate associativity/commutativity
I Open source implementation
Conclusions
Contributions
Manuel Krebber | June 30, 2017 30/31
Project is on GitHub:https://github.com/hpac/matchpy
Conclusions
Repository
Manuel Krebber | June 30, 2017 31/31
Thank you for your attention!