Anda di halaman 1dari 10

Finite fields and string matching

Andrew MacFie Math 5900 X

String matching
Input
Text: = 0 1 1 Pattern: = 0 1 1

Objective
Find all occurrences of in as substring

Knuth-Morris-Pratt: +

Approximate string matching


What if matches dont have to be exact?
Allow up to mismatches

and if the alphabet contains wildcards? Clifford et al. approach: use finite field as alphabet

Algorithm
Encode input as finite field elements Set up systems of equations for mismatch positions For = 0 to do Compute =
=1

Find roots of End for Encode input as integers Verify that all mismatches are found for each position

Preliminary 1: Convolutions
Fourier Transform

= = 1

Polynomial multiplication

Convolutions


=0

Preliminary 2: 2 trick
1

takes log time

Compute each in log time

Equations for the output


For each position :

1 1 1 2 1 1
2 1 1

+ + +

2 2 2 2 2 2

2 + 2 2
1

+ + + +

+ + +

= = =

2 +

0 1 2 = 2

=
=0

+ + +

Equations for the output


For each position :

1 1 1 2 1 1
2 1 1

+ + +

2 2 2 2 2 2

2 + 2 2

+ + + +

+ + +

= = =

2 +
=1

0 1 2 = 2
1

0 , 1 , , 2 has minimal polynomial = Berlekamp-Massey!

Verification step
For each position :


=0

2 ? + + =


=1

Analysis
Running time: log 2 log 2 + log log Optimal:

Anda mungkin juga menyukai