Word (theoretical computer science)

from Wikipedia, the free encyclopedia

In theoretical computer science , a word is a finite sequence of symbols in an alphabet . In contrast to the natural language meaning of words , which always have an independent meaning, a word in theoretical computer science has no linguistic meaning. It's just another term for a string .

Words or words are the elements of a formal language . They are therefore important for mathematical modeling , for the theory of programming languages , for computability theory and other areas of theoretical computer science.

definition

It should be a given alphabet and a natural number from the set of natural numbers, including zero ( ). A word of length is a finite sequence with for all .

The length of a word is noted as; the number of times the character appears in the word with . A special word is the empty word , which does not consist of any symbol (has a length of 0) and is usually represented with the Greek letter ( epsilon ) (which is also found occasionally). The set of all words that can be formed from an alphabet is the clover ash and positive cover over this alphabet. This is the disjoint union

.

The non-empty words are then accordingly the 'positive envelope'

.

The simplified notation is often used to indicate a word , but this is only possible if the alphabet used allows the symbols used to be clearly assigned. This short spelling can not be used with the alphabet , for example, because the spelling does not clearly indicate whether the word , or is meant.

Words of length can be understood as follows:

  • as finite sequences (sequence) - since tuples can be understood as sequences of finite length
  • as elements of the -fold Cartesian product - since tuples can also be understood that way

Examples

Let it be the alphabet of Latin letters and . Then the words and examples of words are over and a word is over . You can see that and is.

Operations on words

Concatenation

The concatenation or chain is a combination of two words to form a new word that is created by connecting the two symbol sequences. The concatenation of the two words and above an alphabet is indicated with or and is defined by:

According to the definition of the word and with and for all and . According to the definition above, is a prefix and a suffix of the word created by the concatenation . The length of a concatenated word corresponds to the sum of the lengths of the individual (partial) words. So for every word and :

,

and for the absolute frequency of a character :

.

The neutral element of the concatenation is the empty word, since for any word it applies that:

In addition, since the concatenation is associative , the triple forms a monoid from the set of all words over any alphabet , the combination of the concatenation and the empty word as a neutral element . Associativity means that parentheses can easily be left out:

In contrast, the concatenation is not commutative ; H. not for all words and that is true . For example:

power

The -th power of a word is defined as the -fold concatenation of this word with itself. The definition of the power is usually given recursively:

   (for )

For example:

According to the definition of concatenation, the length of the -th power of any word is equal to the product of and the length of :

,

and for the absolute frequency of each character :

reflection

The mirroring or the reverse of a word is the result of writing backwards. So if is, then is the finite sequence with and for all . So the length of a word is equal to the length of its reflection:

For example, the following words apply:

The reverse of a word can also be defined with the help of structural induction over the structure of the word in question. To do this, one defines the reverse of the empty word as the empty word in the beginning of induction. In the induction step, the reverse of a word composed of a partial word and a symbol is defined as the concatenation of the symbol with the reverse of the partial word:

Induction start:

Induction step:

This is how the reverse of a word can be derived step by step:

A word like , which is identical to its reflection, is called a palindrome . Mathematically, this mirror-symmetrical words than the fixed points of reflection R viewed.

Prefix, infix and suffix

infix

An infix is an addition within a word. Every finite partial sequence of successive symbols of a word is called an infix or partial word of the word . An infix of a given word is therefore every word for which there is (at least) one , for which applies that on the one hand and on the other hand for each . Accordingly, a word is infix of a word if and only if it holds that there is at least one word and one word from Kleen's envelope over the alphabet of , such that :

is infix of

If the word with an infix of words , and , but not the words , or the empty word . In many computer languages, the English term substring is used for Infix .

Specifically, the empty word is an infix of any word, and each word is an infix of itself. An infix of any word that is not identical to this is called a real infix .

prefix

A prefix is an addition to the beginning of a word. A prefix of a word is therefore every infix , for which applies that and for each . Accordingly, the prefix of the word is if and only if there is at least one from Kleen's envelope above the alphabet from which it was generated, such that :

is prefix of

For prefixes, too, every word is a prefix of itself and the empty word is a prefix of any word. A prefix of a word that is not identical to it is called a real prefix .

example

Be , these are the real prefixes for :

  • .

suffix

A suffix , also called a postfix, is an addition to the end of a word. According to the definition of the infix, a suffix of a word is any partial word for which there is one , for which there is on the one hand and for each on the other . Accordingly, a word is a suffix of a word with if and only if there is at least one such that is:

is suffix of

As with prefixes and infixes, the same applies to suffixes that the empty word is a suffix of any word and any word is always a suffix of itself. A suffix of a word that is not the same as it is called a real suffix .

example

Be , these are the real suffixes for :

  • .

literature

  • John E. Hopcroft , Jeffry D. Ullman : Introduction to Automata Theory, Formal Languages, and Complexity Theory . 3rd corrected edition. Addison-Wesley, Bonn et al. 1994, ISBN 3-89319-744-3 ( International Computer Library ).
  • Katrin Erk, Lutz Priese: Theoretical Computer Science. A comprehensive introduction . 2nd expanded edition. Springer-Verlag, Berlin et al. 2002, ISBN 3-540-42624-8 , pp. 27-28 ( Springer textbook ).
  • Gottfried Vossen, Kurt-Ulrich Witt: Basic course in theoretical computer science. An application-oriented introduction - for students in all computer science courses . 4th improved and enlarged edition. Vieweg, Wiesbaden 2006, ISBN 3-8348-0153-4 , p. 15 ( online ).

Notes and individual references

  1. Both plural forms are common, cf. z. B. dtv-Atlas zur Mathematik , Vol. I, ISBN 3-423-03007-0 , p. 245 versus Bauer, Goos: Informatik. Vol. I, ISBN 3-540-06332-3 , p. 28.
  2. Klaus Reinhardt: Priority payment machines and the synchronization of half-track languages , Faculty of Computer Science at the University of Stuttgart; PhD thesis 1994 (PDF; 509 KB)
  3. This is .
  4. Yuri L. Ershov, Eugenii A. Palyutin: Mathematical Logic . Translated from the Russian by Vladimir Shokurov. Revised from the 1979 Russian edition. Mir Publishers, Moscow 1984, p. 16 ( mirtitles.org ).
  5. ^ Definition of tuple and its synonyms: Encyclopedia of Mathematics: Tuple
  6. The reflection of a word of length n is a special self-inverse permutation
    .
    The reflection of arbitrarily long words is then the union

Web links