Finite Fields and String Matching presentation

10
Finite fields and string matching Andrew MacFie Math 5900 X

description

See "Finite Fields and String Matching" document

Transcript of Finite Fields and String Matching presentation

Page 1: Finite Fields and String Matching presentation

Finite fields and string matching

Andrew MacFieMath 5900 X

Page 2: Finite Fields and String Matching presentation

String matching

• Input– Text: – Pattern:

• Objective – Find all occurrences of in as substring

Knuth-Morris-Pratt:

Page 3: Finite Fields and String Matching presentation

Approximate string matching

• What if matches don’t have to be exact?– Allow up to mismatches

• …and if the alphabet contains wildcards?

Clifford et al. approach: use finite field as alphabet

Page 4: Finite Fields and String Matching presentation

Algorithm

Encode input as finite field elementsSet up systems of equations for mismatch positionsFor to do

Compute Find roots of

End forEncode input as integersVerify that all mismatches are found for each position

Page 5: Finite Fields and String Matching presentation

Preliminary 1: Convolutions

Fourier Transform

Polynomial multiplication

Convolutions (𝑡⊗𝑝 ) [ 𝑖 ]≝∑𝑗=0

𝑚− 1

𝑝 𝑗 𝑡𝑖+ 𝑗

ℱ {𝑋 ∗𝑌 }=ℱ {𝑋 }⋅ℱ {𝑌 }

Page 6: Finite Fields and String Matching presentation

• takes time

Preliminary 2: trick

𝑝

𝑡

𝑡⊗𝑝

Compute each in time

Page 7: Finite Fields and String Matching presentation

Equations for the output

𝑟1 +¿𝑟 2 +¿⋯ +¿𝑟𝑘′ ¿ 𝑠0𝑟1 𝑥1 +¿𝑟2𝑥2 +¿⋯ +¿𝑟𝑘′ 𝑥𝑘′ ¿ 𝑠1𝑟1 𝑥1

2 +¿𝑟2𝑥22 +¿⋯ +¿𝑟𝑘′ 𝑥𝑘′

2 ¿ 𝑠2⋮ ¿ ¿ ¿ 𝑟1𝑥1

2𝑘 ¿

+¿⋯ ¿+¿𝑟𝑘′𝑥𝑘′2𝑘 ¿=¿ 𝑠2𝑘 ¿

𝑠𝑙=∑𝑗=0

𝑚−1

(𝑝 𝑗−𝑡 𝑖+ 𝑗 ) (𝑖+ 𝑗 )𝑙𝑝 𝑗′ 𝑡𝑖+ 𝑗

For each position :

Page 8: Finite Fields and String Matching presentation

has minimal polynomial

Berlekamp-Massey!

Equations for the output

𝑟1 +¿𝑟 2 +¿⋯ +¿𝑟𝑘′ ¿ 𝑠0𝑟1 𝑥1 +¿𝑟2𝑥2 +¿⋯ +¿𝑟𝑘′ 𝑥𝑘′ ¿ 𝑠1𝑟1 𝑥1

2 +¿𝑟2𝑥22 +¿⋯ +¿𝑟𝑘′ 𝑥𝑘′

2 ¿ 𝑠2⋮ ¿ ¿ ¿ 𝑟1𝑥1

2𝑘 ¿

+¿⋯ ¿+¿𝑟𝑘′𝑥𝑘′2𝑘 ¿=¿ 𝑠2𝑘 ¿

For each position :

Page 9: Finite Fields and String Matching presentation

Verification step

∑𝑗=0

𝑚−1

(𝑝 𝑗−𝑡 𝑖+ 𝑗 )2𝑝 𝑗

′ 𝑡𝑖+ 𝑗′ =∑

𝑗=1

𝑘′

(𝑝𝑥 𝑗−𝑖−𝑡𝑥 𝑗 )

2?

For each position :

Page 10: Finite Fields and String Matching presentation

Analysis

• Running time: • Optimal: