Lably
Skip to content

String operations

Operations in formal language theory

  • 6 min read
  • 9 chapters

Related on Lably

Through Computer science, Computer programming and Associative property

Strings and languages

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

For example, (⟨b⟩⋅⟨l⟩)⋅(ε⋅⟨ah⟩)=⟨bl⟩⋅⟨ah⟩=⟨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 S⋅T is defined as the set of concatenations of any string from S and any string from T, formally S⋅T={s⋅t∣s∈S∧t∈T}. Again, the concatenation dot ⋅ is often omitted for brevity.

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 associative: S⋅(T⋅U)=(S⋅T)⋅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 D⋅D⋅D. The set of all decimal numbers of arbitrary length is an example for an infinite language.

Sign in to keep reading

8 more chapters are free with a Lably account.

More in Computing and communication