ebooksgratis.com

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
String operations - Wikipedia, the free encyclopedia

String operations

From Wikipedia, the free encyclopedia

In computer science, in the area of formal language theory, frequent use is made of a variety of string functions; however, the notation used is different from that used on computer programming, and some commonly used functions in the theoretical realm are rarely used when programming. This article defines some of these basic terms.

Contents

[edit] Alphabet of a string

The alphabet of a string is a list of all of the letters that occur in a particular string. If s is a string, its alphabet is denoted by

\operatorname{Alph}(s)

[edit] String substitution

Let L be a language, and let Σ be its alphabet. A string substitution or simply a substitution is a mapping f that maps letters in Σ to languages (possibly in a different alphabet). Thus, for example, given a letter a\in \Sigma, one has f(a) = La where L_a\subset\Delta^* is some language whose alphabet is Δ. This mapping may be extended to strings as

f(\varepsilon)=\varepsilon

for the empty string \varepsilon, and

f(sa) = f(s)f(a)

for string s\in L. String substitution may be extended to the entire language as

f(L)=\bigcup_{s\in L} f(s)

An example of string substitution occurs in regular languages, which are closed under string substitution. That is, if the letters of a regular language are substituted by other regular languages, the result is still a regular language.

[edit] String homomorphism

A string homomorphism is a string substitution such that each letter is replaced by a single string. That is, f(a) = s, where s is a string, for each letter a. String homomorphisms are homomorphisms, preserving the binary operation of string concatenation. Given a language L, the set f(L) is called the homomorphic image of L. The inverse homomorphic image of a string s is defined as

f^{-1}(s)=\{w\vert f(w)=s\}

while the inverse homomorphic image of a language L is defined as

f^{-1}(L)=\{s\vert f(s)\in L\}

Note that, in general, f(f^{-1}(L))\ne L, while one does have

f(f^{-1}(L)) \subseteq L

and

L \subseteq f^{-1}(f(L))

for any language L. Simple single-letter substitution ciphers are examples of string homomorphisms.

[edit] String projection

If s is a string, and Σ is an alphabet, the string projection of s is the string that results by removing all letters which are not in Σ. It is written as \pi_\Sigma(s)\,. It is formally defined by removal of letters from the right hand side:

\pi_\Sigma(s) = \begin{cases} 
\varepsilon & \mbox{if } s=\varepsilon \mbox{ the empty string} \\
\pi_\Sigma(t) & \mbox{if } s=ta \mbox{ and } a \notin \Sigma \\ 
\pi_\Sigma(t)a & \mbox{if } s=ta \mbox{ and } a \in \Sigma   
\end{cases}

Here \varepsilon denotes the empty string. The projection of a string is essentially the same as a projection in relational algebra.

String projection may be promoted to the projection of a language. Given a formal language L, its projection is given by

\pi_\Sigma (L)=\{\pi_\Sigma(s) \vert s\in L \}

[edit] Right quotient

The right quotient of a letter a from a string s is the truncation of the letter a in the string s, from the right hand side. It is denoted as s / a. If the string does not have a on the right hand side, the result is the empty string. Thus:

(sa)/ b = \begin{cases} 
s & \mbox{if } a=b \\
\varepsilon & \mbox{if } a \ne b
\end{cases}

The quotient of the empty string may be taken:

\varepsilon / a = \varepsilon

Similarly, given a subset S\subset M of a monoid M, one may define the quotient subset as

S/a=\{s\in M \vert sa\in S\}

Left quotients may be defined similarly, with operations taking place on the left of a string.

[edit] Syntactic relation

The right quotient of a subset S\subset M of a monoid M defines an equivalence relation, called the right syntactic relation of S. It is given by

\sim_S \;\,=\, \{(s,t)\in M\times M \vert S/s = S/t \}

The relation is clearly of finite index (has a finite number of equivalence classes) if and only if the family right quotients is finite; that is, if

\{S/m \vert m\in M\}

is finite. In this case, S is a recognizable language, that is, a language that can be recognized by a finite state automaton. This is discussed in greater detail in the article on syntactic monoids.

[edit] Right cancellation

The right cancellation of a letter a from a string s is the removal of the first occurrence of the letter a in the string s, starting from the right hand side. It is denoted as s\div a and is recursively defined as

(sa)\div b = \begin{cases} 
s & \mbox{if } a=b \\
(s\div b)a & \mbox{if } a \ne b
\end{cases}

The empty string is always cancellable:

\varepsilon \div a = \varepsilon

Clearly, right cancellation and projection commute:

\pi_\Sigma(s)\div a = \pi_\Sigma(s \div a )

[edit] Prefixes

The prefixes of a string is the set of all prefixes to a string, with respect to a given language:

\operatorname{Pref}_L(s) = \{t \vert s=tu \mbox { for } u\in L\}

The prefix closure of a language is

\operatorname{Pref} (L) = \bigcup_{s\in L} \operatorname{Pref}_L(s)

A language is called prefix closed if \operatorname{Pref} (L) = L. Clearly, the prefix closure operator is idempotent:

\operatorname{Pref} (\operatorname{Pref} (L)) =\operatorname{Pref} (L)

The prefix relation is a binary relation \sqsubseteq such that s\sqsubseteq t if and only if s \in \operatorname{Pref}_L(t).

Prefix grammars generate languages that are prefix-closed.

[edit] See also

[edit] References

  • John E. Hopcroft and Jeffrey D. Ullman, Introduction to Automata Theory, Languages and Computation, Addison-Wesley Publishing, Reading Massachusetts, 1979. ISBN 0-201-029880-X. (See chapter 3.)
Languages


aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -