140 likes | 232 Views
On special families of morphisms related to δ - matching and don ’ t care symbols. Information Processing Letters (2003) Richard Cole et al. δ -matching problem. Σ is an interval of integers Pattern P, |P| = m Text T, |T| = n For a, b Σ , a = δ b if |a-b|≤ δ
E N D
On special families of morphisms related to δ-matching and don’t care symbols Information Processing Letters (2003) Richard Cole et al
δ-matching problem • Σ is an interval of integers • Pattern P, |P| = m • Text T, |T| = n • For a, b Σ, a =δb if |a-b|≤δ • A δ-matching occurs in position j when • |P[i] - T[i+j-1]| ≤δ for 1≤i≤n • P =δT[j…j+m-1] T 2 3 3 4 2 3 4 3 1 P 1 4 3 2
Pattern-matching with don’t care symbols T * 2 2 2 * 2 2 1 1 • Σ* = Σ {*} • a≈b if a=b or a=* or b=* • Two strings u, w with |u|=|w|, u≈w iff u[i]≈w[i] for all I • Find all positions j such that P≈T[i…j+m-1] P 1 2 2 *
Lemma 1. The problem of pattern-matching with don’t cares for a pattern P and a text T of length n over an alphabet Σ can be solved in time O(log|Σ| * IntMult(n))
Relation between δ-matching and pattern matching with don’t cares • For small alphabet δ-matching is at least as difficult as matching with don’t cares • Theorem 2. String matching with don’t cares for binary alphabets {a, b} is reducible to δ-matching for the alphabet Σ={1, 2, 3} a b * a b c * ??
Reduction from δ-matching to pattern matching with don’t cares • Given P, T, δ, find k symbol-to-symbol encodings h1,…,hk to reduce it T 2 3 3 4 2 3 4 3 1 P 1 4 3 2 T * 2 2 2 * 2 2 1 1 P 1 2 2 * T 1 * * 2 1 * 2 * 1 P 1 2 * 1 P 1 2 * 1 P 1 2 * 1 P 1 2 * 1
δ- distinguishing families of morphisms • H = {h1, h2, …, hk}, hi:ΣΣi{*} • H is δ-distingushingiff a, b Σ [a =δb] ≡[(hH) h(a)≈h(b)] • Mδ(P,T)={j | P=δT[j…j+m-1]} • D(P,T)={j | P≈T[j…j+m-1]} • Mδ(P,T)=D(h1(P),h1(T))∩…∩D(hk(P), hk(T))
δ-regular family • H is a δ- regular family iff it satisfies • P1: each morphism is a form h=**…*11…1**…*22…2**…*33…**.. The internal blocks of *’s are exactly of length δ, the boundary blocks of *’s are of length at most δ • P2 : For p, q Σsuch that q – p > δ there exists hH such that h(p)=i, h(q)=j > i, and h(r)=* for some p < r <q δ=1
Lemma 3. If a family is δ- regular then it is a δ-distinguishing family <proof idea>δ-distingushing iff a, b Σ[a =δb] ≡[(hH) h(a)≈h(b)] • <proof>: consider p, q Σ and p < q • case 1 : if p =δq • case 2 : if p≠δq
δ=3 • Theorem 4. The size of minimal δ-distinguising family of morphisms is at most 2δ+1:α(δ)≤2δ+1 • # * in each column is at most δ • if p-q>δ then for every i there is a symbol between p, q in hi
Lemma 5. The size of a minimal 3-distinguishing family of morphisms is at most 6:α(3)≤6 • F={{1,2,3},{1,2,4},{1,3,5},{1,4,6},{2,3,4},{2,3,6},{2,4,5},{2,5,6},{3,4,5},{3,4,6}}
Special case • Theorem 6. If k is divisible by 3, then α(δ)≤ 2δ • α(r *δ)≤ r *α(δ) • Expand hi to r times • Cyclically shift by j, 1≤j<r • By Lemma, α(3*r)≤6r
Lower bound • Theorem 7. The size of a minimal δ-distinguishing family of morphisms is at least δ+2:α(δ) ≥δ+ 2
Claim. If there is a δ-distinguishing family of size k, then there exists a δ-regular family of k morphisms