Concatenating Two Formal Words

Concatenation joins strings in order and adds their lengths. Changing word order can change the resulting sequence.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace two small words
  2. State the separator rule
  3. Append ordered symbols and count their positions
  4. Distinguish grouping from order

Trace two small words

Joining ab and ba in that order gives abba. Reversing them gives baab. Both results have length four. See order-sensitive reduction.

State the separator rule

Formal word concatenation itself adds no delimiter. A practical format needing to recover original fields may supply boundaries. Escaping and delimiters describe that additional representation work.[1]

Append ordered symbols and count their positions

Concatenating ab with bba gives abbba. Reversing the order gives bbaab. Both have length five because lengths add although the resulting words differ. See sequences versus sets.

u=ab, v=bba
uv=abbba, length 2+3=5
vu=bbaab, length 3+2=5
Concatenating the empty word preserves u

Distinguish grouping from order

Concatenation is associative, so grouping three words differently preserves their total sequence. It is generally noncommutative. Check that a program building words preserves operand order.

References

  1. Michael Sipser, Introduction to the Theory of Computation ↩