Balanced flow

From formulasearchengine
Revision as of 14:58, 28 June 2013 by en>ChrisGualtieri (General Fixes + MOS + DMY changes using AWB)
Jump to navigation Jump to search

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.

Strings and languages

A string is a finite sequence of characters. The empty string is denoted by ε. The concatenation of two string s and t is denoted by st, or shorter by st. Concatenating with the empty string makes no difference: sε=s=εs. Concatenation of strings is associative: s(tu)=(st)u.

For example, (bl)(εah)=blah=blah.

A language is a finite or infinite set of strings. Besides the usual set operations like union, intersection etc., concatenation can be applied to languages: if both S and T are languages, their concatenation ST is defined as the set of concatenations of any string from S and any string from T, formally ST={stsStT}. Again, the concatenation dot is often omitted for shortness.

The language {ε} consisting of just the empty string is to be distinguished from the empty language {}. Concatenating any language with the former doesn't make any change: S{ε}=S={ε}S, while concatenating with the latter always yields the empty language: S{}={}={}S. Concatenation of languages is associtive: S(TU)=(ST)U.

For example, abbreviating D={0,1,2,3,4,5,6,7,8,9}, the set of all three-digit decimal numbers is obtained as DDD. The set of all decimal numbers of arbitrary length is an example for an infinite language.

Alphabet of a string

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

Alph(s)

The alphabet of a language S is the set of all characters that occur in any string of S, formally: Alph(S)=sSAlph(s).

For example, the set {a,c,o} is the alphabet of the string cacao, and the above D is the alphabet of the above language DDD as well as of the language of all decimal numbers.

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Σ, one has f(a)=La where LaΔ* is some language whose alphabet is Δ. This mapping may be extended to strings as

f(ε)=ε

for the empty string ε, and

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

for string sL. String substitution may be extended to the entire language as

f(L)=sLf(s)

Regular languages are closed under string substitution. That is, if each letter of a regular language is substituted by another regular language, the result is still a regular language.

A simple example is the conversion fuc() to upper case, which may be defined e.g. as follows:

letter mapped to language remark
x fuc(x)
a {A} map lower-case char to corresponding upper-case char
A {A} map upper-case char to itself
ß {SS} no upper-case char available, map to two-char string
0 {ε} map digit to empty string
! {} forbid punctuation, map to empty language
similar for other chars

For the extension of fuc to strings, we have e.g.

For the extension of fuc to languages, we have e.g.


Another example is the conversion of an EBCDIC-encoded string to ASCII.

String homomorphism

A string homomorphism (often referred to simply as a homomorphism in formal language theory) 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 monoid morphisms on the free monoid, 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

f1(s)={w|f(w)=s}

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

f1(L)={s|f(s)L}

Note that, in general, f(f1(L))L, while one does have

f(f1(L))L

and

Lf1(f(L))

for any language L.

A string homomorphism is said to be ε-free (or e-free) if f(a)ε for all a in the alphabet Σ. Simple single-letter substitution ciphers are examples of (ε-free) string homomorphisms.

An example string homomorphism guc can also be obtained by defining similar to the above substitution: guc(a)=A, ..., guc(0)=ε, but letting guc undefined on punctuation chars. Besides this restriction of its input domain, guc differs from fuc by returning strings, while the latter returned singleton sets of strings. Examples for inverse homomorphic images are

For the latter language, guc(guc1({A,bb}))=guc({a})={A}{A,bb}. The homomorphism guc is not ε-free, since it maps e.g. 0 to ε.

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 πΣ(s). It is formally defined by removal of letters from the right hand side:

πΣ(s)={εif s=ε the empty stringπΣ(t)if s=ta and aΣπΣ(t)aif s=ta and aΣ

Here ε 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

πΣ(L)={πΣ(s)|sL}

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={sif a=bεif ab

The quotient of the empty string may be taken:

ε/a=ε

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

S/a={sM|saS}

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

Syntactic relation

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

S={(s,t)M×M|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|mM}

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.

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÷a and is recursively defined as

(sa)÷b={sif a=b(s÷b)aif ab

The empty string is always cancellable:

ε÷a=ε

Clearly, right cancellation and projection commute:

πΣ(s)÷a=πΣ(s÷a)

Prefixes

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

PrefL(s)={t|s=tu for t,uAlph(L)*}

here sL.

The prefix closure of a language is

Pref(L)=sLPrefL(s)={t|s=tu;sL;t,uAlph(L)*}

Example:
L={abc} then Pref(L)={ε,a,ab,abc}

A language is called prefix closed if Pref(L)=L.

The prefix closure operator is idempotent:

Pref(Pref(L))=Pref(L)

The prefix relation is a binary relation such that st if and only if sPrefL(t). This relation is a particular example of a prefix order.

See also

References

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

  • 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534 (See chapter 3.)