Metamath Proof Explorer


Table of Contents - 5.7. Words over a set

This section is about words (or strings) over a set (alphabet) defined as finite sequences of symbols (or characters) being elements of the alphabet. Although it is often required that the underlying set/alphabet be nonempty, finite and not a proper class, these restrictions are not made in the current definition df-word, see, for example, s1cli: . Note that the empty word (i.e. the empty set) is the only word over an empty alphabet, see 0wrd0.

The set of words over is the free monoid over , where the monoid law is concatenation and the monoid unit is the empty word.

Besides the definition of words themselves, several operations on words are defined in this section: <table border="1" id="word-operations"> <tr> <th>Name</th><th>Reference</th><th>Explanation</th><th>Example</th> <th>Remarks</th></tr> <tr> <td>Length (or size) of a word </td><td> df-hash: </td> <td>Operation which determines the number of the symbols within the word.</td> <td> </td> <td> This is not a special definition for words, but for arbitrary sets.</td></tr> <tr> <td>First symbol of a word </td><td> df-fv: </td> <td>Operation which extracts the first symbol of a word. The result is the symbol at the first place in the sequence representing the word.</td> <td> </td> <td> This is not a special definition for words, but for arbitrary functions with a half-open range of nonnegative integers as domain.</td></tr> <tr> <td>Last symbol of a word </td><td> df-lsw: </td> <td>Operation which extracts the last symbol of a word. The result is the symbol at the last place in the sequence representing the word.</td> <td> </td> <td> Note that the index of the last symbol is less by 1 than the length of the word.</td></tr> <tr> <td>Subword (or substring) of a word </td> <td> df-substr: </td> <td>Operation which extracts a portion of a word. The result is a consecutive, reindexed part of the sequence representing the word.</td> <td> </td> <td> Note that the last index of the range defining the subword is greater by 1 than the index of the last symbol of the subword in the sequence of the original word.</td></tr> <tr> <td>Concatenation of two words </td> <td> df-concat: </td> <td>Operation combining two words to one new word. The result is a combined, reindexed sequence build from the sequences representing the two words.</td> <td> </td> <td> Note that the index of the first symbol of the second concatenated word is the length of the first word in the concatenation.</td></tr> <tr> <td>Reversal of a word </td> <td> df-reverse: </td> <td>Operation which reverses the order of symbols in a word.</td> <td> </td> <td> </td></tr> <tr> <td>Cyclical shift of a word </td> <td> df-csh: </td> <td>Operation cyclically shifting the symbols by a number of positions.</td> <td> </td> <td> </td></tr> <tr> <td>Splicing of a word </td> <td> df-splice: </td> <td>Operation which replaces portions of words.</td> <td> </td> <td> </td></tr> <tr> <td>Singleton word </td> <td> df-s1: </td> <td>Constructor building a word of length 1 from a symbol.</td> <td> </td> <td> </td></tr> </table> Conventions: <ul> <li>Words are usually represented by class variable , if two words are involved by and , or by and .</li> <li>The alphabets are usually represented by class variable (because any arbitrary set can be an alphabet), sometimes also by (especially as codomain of the function representing a word, because the alphabet is the set of symbols).</li> <li>The symbols are usually represented by class variables or , if two symbols are involved by and , or by and .</li> <li>The indices of the sequence representing a word are usually represented by class variable , if two indices are involved (especially for subwords) by and , or by and .</li> <li>The length of a word is usually represented by class variables or .</li> <li>The number of position to cyclically shift a word is usually represented by class variables or .</li></ul>

  1. Definitions and basic theorems
    1. cword
    2. df-word
    3. iswrd
    4. wrdval
    5. iswrdi
    6. wrdf
    7. iswrdb
    8. wrddm
    9. sswrd
    10. snopiswrd
    11. wrdexg
    12. wrdexb
    13. wrdexi
    14. wrdsymbcl
    15. wrdfn
    16. wrdv
    17. wrdlndm
    18. iswrdsymb
    19. wrdfin
    20. lencl
    21. lennncl
    22. wrdffz
    23. wrdeq
    24. wrdeqi
    25. iswrddm0
    26. wrd0
    27. 0wrd0
    28. ffz0iswrd
    29. wrdsymb
    30. nfwrd
    31. csbwrdg
    32. wrdnval
    33. wrdmap
    34. hashwrdn
    35. wrdnfi
    36. wrdnfiOLD
    37. wrdsymb0
    38. wrdlenge1n0
    39. len0nnbi
    40. wrdlenge2n0
    41. wrdsymb1
    42. wrdlen1
    43. fstwrdne
    44. fstwrdne0
    45. eqwrd
    46. elovmpowrd
    47. elovmptnn0wrd
    48. wrdred1
    49. wrdred1hash
  2. Last symbol of a word
    1. clsw
    2. df-lsw
    3. lsw
    4. lsw0
    5. lsw0g
    6. lsw1
    7. lswcl
    8. lswlgt0cl
  3. Concatenations of words
    1. cconcat
    2. df-concat
    3. ccatfn
    4. ccatfval
    5. ccatcl
    6. ccatlen
    7. ccatlenOLD
    8. ccat0
    9. ccatval1
    10. ccatval1OLD
    11. ccatval2
    12. ccatval3
    13. elfzelfzccat
    14. ccatvalfn
    15. ccatsymb
    16. ccatfv0
    17. ccatval1lsw
    18. ccatval21sw
    19. ccatlid
    20. ccatrid
    21. ccatass
    22. ccatrn
    23. ccatidid
    24. lswccatn0lsw
    25. lswccat0lsw
    26. ccatalpha
    27. ccatrcl1
  4. Singleton words
    1. cs1
    2. df-s1
    3. ids1
    4. s1val
    5. s1rn
    6. s1eq
    7. s1eqd
    8. s1cl
    9. s1cld
    10. s1prc
    11. s1cli
    12. s1len
    13. s1nz
    14. s1dm
    15. s1dmALT
    16. s1fv
    17. lsws1
    18. eqs1
    19. wrdl1exs1
    20. wrdl1s1
    21. s111
  5. Concatenations with singleton words
    1. ccatws1cl
    2. ccatws1clv
    3. ccat2s1cl
    4. ccats1alpha
    5. ccatws1len
    6. ccatws1lenp1b
    7. wrdlenccats1lenm1
    8. ccat2s1len
    9. ccat2s1lenOLD
    10. ccatw2s1cl
    11. ccatw2s1len
    12. ccats1val1
    13. ccats1val1OLD
    14. ccats1val2
    15. ccat1st1st
    16. ccat2s1p1
    17. ccat2s1p2
    18. ccat2s1p1OLD
    19. ccat2s1p2OLD
    20. ccatw2s1ass
    21. ccatw2s1assOLD
    22. ccatws1n0
    23. ccatws1ls
    24. lswccats1
    25. lswccats1fst
    26. ccatw2s1p1
    27. ccatw2s1p1OLD
    28. ccatw2s1p2
    29. ccat2s1fvw
    30. ccat2s1fvwOLD
    31. ccat2s1fst
    32. ccat2s1fstOLD
  6. Subwords/substrings
    1. csubstr
    2. df-substr
    3. swrdnznd
    4. swrdval
    5. swrd00
    6. swrdcl
    7. swrdval2
    8. swrdlen
    9. swrdfv
    10. swrdfv0
    11. swrdf
    12. swrdvalfn
    13. swrdrn
    14. swrdlend
    15. swrdnd
    16. swrdnd2
    17. swrdnnn0nd
    18. swrdnd0
    19. swrd0
    20. swrdrlen
    21. swrdlen2
    22. swrdfv2
    23. swrdwrdsymb
    24. swrdsb0eq
    25. swrdsbslen
    26. swrdspsleq
    27. swrds1
    28. swrdlsw
    29. ccatswrd
    30. swrdccat2
  7. Prefixes of a word
    1. cpfx
    2. df-pfx
    3. pfxnndmnd
    4. pfxval
    5. pfx00
    6. pfx0
    7. pfxval0
    8. pfxcl
    9. pfxmpt
    10. pfxres
    11. pfxf
    12. pfxfn
    13. pfxfv
    14. pfxlen
    15. pfxid
    16. pfxrn
    17. pfxn0
    18. pfxnd
    19. pfxnd0
    20. pfxwrdsymb
    21. addlenrevpfx
    22. addlenpfx
    23. pfxfv0
    24. pfxtrcfv
    25. pfxtrcfv0
    26. pfxfvlsw
    27. pfxeq
    28. pfxtrcfvl
    29. pfxsuffeqwrdeq
    30. pfxsuff1eqwrdeq
    31. disjwrdpfx
    32. ccatpfx
    33. pfxccat1
    34. pfx1
  8. Subwords of subwords
    1. swrdswrdlem
    2. swrdswrd
    3. pfxswrd
    4. swrdpfx
    5. pfxpfx
    6. pfxpfxid
  9. Subwords and concatenations
    1. pfxcctswrd
    2. lenpfxcctswrd
    3. lenrevpfxcctswrd
    4. pfxlswccat
    5. ccats1pfxeq
    6. ccats1pfxeqrex
    7. ccatopth
    8. ccatopth2
    9. ccatlcan
    10. ccatrcan
    11. wrdeqs1cat
    12. cats1un
    13. wrdind
    14. wrd2ind
  10. Subwords of concatenations
    1. swrdccatfn
    2. swrdccatin1
    3. pfxccatin12lem4
    4. pfxccatin12lem2a
    5. pfxccatin12lem1
    6. swrdccatin2
    7. pfxccatin12lem2c
    8. pfxccatin12lem2
    9. pfxccatin12lem3
    10. pfxccatin12
    11. pfxccat3
    12. swrdccat
    13. pfxccatpfx1
    14. pfxccatpfx2
    15. pfxccat3a
    16. swrdccat3blem
    17. swrdccat3b
    18. pfxccatid
    19. ccats1pfxeqbi
    20. swrdccatin1d
    21. swrdccatin2d
    22. pfxccatin12d
    23. reuccatpfxs1lem
    24. reuccatpfxs1
    25. reuccatpfxs1v
  11. Splicing words (substring replacement)
    1. csplice
    2. df-splice
    3. splval
    4. splcl
    5. splid
    6. spllen
    7. splfv1
    8. splfv2a
    9. splval2
  12. Reversing words
    1. creverse
    2. df-reverse
    3. revval
    4. revcl
    5. revlen
    6. revfv
    7. rev0
    8. revs1
    9. revccat
    10. revrev
  13. Repeated symbol words
    1. creps
    2. df-reps
    3. reps
    4. repsundef
    5. repsconst
    6. repsf
    7. repswsymb
    8. repsw
    9. repswlen
    10. repsw0
    11. repsdf2
    12. repswsymball
    13. repswsymballbi
    14. repswfsts
    15. repswlsw
    16. repsw1
    17. repswswrd
    18. repswpfx
    19. repswccat
    20. repswrevw
  14. Cyclical shifts of words
    1. ccsh
    2. df-csh
    3. cshfn
    4. cshword
    5. cshnz
    6. 0csh0
    7. cshw0
    8. cshwmodn
    9. cshwsublen
    10. cshwn
    11. cshwcl
    12. cshwlen
    13. cshwf
    14. cshwfn
    15. cshwrn
    16. cshwidxmod
    17. cshwidxmodr
    18. cshwidx0mod
    19. cshwidx0
    20. cshwidxm1
    21. cshwidxm
    22. cshwidxn
    23. cshf1
    24. cshinj
    25. repswcshw
    26. 2cshw
    27. 2cshwid
    28. lswcshw
    29. 2cshwcom
    30. cshwleneq
    31. 3cshw
    32. cshweqdif2
    33. cshweqdifid
    34. cshweqrep
    35. cshw1
    36. cshw1repsw
    37. cshwsexa
    38. 2cshwcshw
    39. scshwfzeqfzo
    40. cshwcshid
    41. cshwcsh2id
    42. cshimadifsn
    43. cshimadifsn0
  15. Mapping words by a function
    1. wrdco
    2. lenco
    3. s1co
    4. revco
    5. ccatco
    6. cshco
    7. swrdco
    8. pfxco
    9. lswco
    10. repsco
  16. Longer string literals
    1. cs2
    2. cs3
    3. cs4
    4. cs5
    5. cs6
    6. cs7
    7. cs8
    8. df-s2
    9. df-s3
    10. df-s4
    11. df-s5
    12. df-s6
    13. df-s7
    14. df-s8
    15. cats1cld
    16. cats1co
    17. cats1cli
    18. cats1fvn
    19. cats1fv
    20. cats1len
    21. cats1cat
    22. cats2cat
    23. s2eqd
    24. s3eqd
    25. s4eqd
    26. s5eqd
    27. s6eqd
    28. s7eqd
    29. s8eqd
    30. s3eq2
    31. s2cld
    32. s3cld
    33. s4cld
    34. s5cld
    35. s6cld
    36. s7cld
    37. s8cld
    38. s2cl
    39. s3cl
    40. s2cli
    41. s3cli
    42. s4cli
    43. s5cli
    44. s6cli
    45. s7cli
    46. s8cli
    47. s2fv0
    48. s2fv1
    49. s2len
    50. s2dm
    51. s3fv0
    52. s3fv1
    53. s3fv2
    54. s3len
    55. s4fv0
    56. s4fv1
    57. s4fv2
    58. s4fv3
    59. s4len
    60. s5len
    61. s6len
    62. s7len
    63. s8len
    64. lsws2
    65. lsws3
    66. lsws4
    67. s2prop
    68. s2dmALT
    69. s3tpop
    70. s4prop
    71. s3fn
    72. funcnvs1
    73. funcnvs2
    74. funcnvs3
    75. funcnvs4
    76. s2f1o
    77. f1oun2prg
    78. s4f1o
    79. s4dom
    80. s2co
    81. s3co
    82. s0s1
    83. s1s2
    84. s1s3
    85. s1s4
    86. s1s5
    87. s1s6
    88. s1s7
    89. s2s2
    90. s4s2
    91. s4s3
    92. s4s4
    93. s3s4
    94. s2s5
    95. s5s2
    96. s2eq2s1eq
    97. s2eq2seq
    98. s3eqs2s1eq
    99. s3eq3seq
    100. swrds2
    101. swrds2m
    102. wrdlen2i
    103. wrd2pr2op
    104. wrdlen2
    105. wrdlen2s2
    106. wrdl2exs2
    107. pfx2
    108. wrd3tpop
    109. wrdlen3s3
    110. repsw2
    111. repsw3
    112. swrd2lsw
    113. 2swrd2eqwrdeq
    114. ccatw2s1ccatws2
    115. ccatw2s1ccatws2OLD
    116. ccat2s1fvwALT
    117. ccat2s1fvwALTOLD
    118. wwlktovf
    119. wwlktovf1
    120. wwlktovfo
    121. wwlktovf1o
    122. wrd2f1tovbij
    123. eqwrds3
    124. wrdl3s3
    125. s3sndisj
    126. s3iunsndisj
    127. ofccat
    128. ofs1
    129. ofs2