src/HOL/ex/Serbian.thy
author wenzelm
Fri, 29 Nov 2024 17:40:15 +0100
changeset 81507 08574da77b4a
parent 80914 d97fdabd9e2b
permissions -rw-r--r--
clarified signature: shorten common cases;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40967
5eb59b62e7de avoid explicit encoding -- acknowledge UTF-8 as global default and Isabelle/jEdit preference of UTF-8-Isabelle;
wenzelm
parents: 30179
diff changeset
     1
(*  Author:     Filip Maric
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     2
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     3
Example theory involving Unicode characters (UTF-8 encoding) -- 
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
     4
Conversion between Serbian cyrillic and latin letters (српска ћирилица и латиница).
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     5
*)
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     6
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     7
section \<open>A Serbian theory\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     8
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
     9
theory Serbian
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
    10
  imports Main
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    11
begin
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    12
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
    13
text \<open>Serbian cyrillic letters.\<close>
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    14
datatype azbuka =
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    15
  azbA   (\<open>А\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    16
| azbB   (\<open>Б\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    17
| azbV   (\<open>В\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    18
| azbG   (\<open>Г\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    19
| azbD   (\<open>Д\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    20
| azbDj  (\<open>Ђ\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    21
| azbE   (\<open>Е\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    22
| azbZv  (\<open>Ж\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    23
| azbZ   (\<open>З\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    24
| azbI   (\<open>И\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    25
| azbJ   (\<open>Ј\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    26
| azbK   (\<open>К\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    27
| azbL   (\<open>Л\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    28
| azbLj  (\<open>Љ\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    29
| azbM   (\<open>М\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    30
| azbN   (\<open>Н\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    31
| azbNj  (\<open>Њ\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    32
| azbO   (\<open>О\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    33
| azbP   (\<open>П\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    34
| azbR   (\<open>Р\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    35
| azbS   (\<open>С\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    36
| azbT   (\<open>Т\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    37
| azbC'  (\<open>Ћ\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    38
| azbU   (\<open>У\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    39
| azbF   (\<open>Ф\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    40
| azbH   (\<open>Х\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    41
| azbC   (\<open>Ц\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    42
| azbCv  (\<open>Ч\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    43
| azbDzv (\<open>Џ\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    44
| azbSv  (\<open>Ш\<close>)
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    45
| azbSpc
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    46
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    47
thm azbuka.induct
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    48
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
    49
text \<open>Serbian latin letters.\<close>
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    50
datatype abeceda =
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    51
  abcA   (\<open>A\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    52
| abcB   (\<open>B\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    53
| abcC   (\<open>C\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    54
| abcCv  (\<open>Č\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    55
| abcC'  (\<open>Ć\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    56
| abcD   (\<open>D\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    57
| abcE   (\<open>E\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    58
| abcF   (\<open>F\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    59
| abcG   (\<open>G\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    60
| abcH   (\<open>H\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    61
| abcI   (\<open>I\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    62
| abcJ   (\<open>J\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    63
| abcK   (\<open>K\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    64
| abcL   (\<open>L\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    65
| abcM   (\<open>M\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    66
| abcN   (\<open>N\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    67
| abcO   (\<open>O\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    68
| abcP   (\<open>P\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    69
| abcR   (\<open>R\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    70
| abcS   (\<open>S\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    71
| abcSv  (\<open>Š\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    72
| abcT   (\<open>T\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    73
| abcU   (\<open>U\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    74
| abcV   (\<open>V\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    75
| abcZ   (\<open>Z\<close>)
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 66392
diff changeset
    76
| abcvZ  (\<open>Ž\<close>)
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    77
| abcSpc
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    78
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    79
thm abeceda.induct
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    80
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    81
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
    82
text \<open>Conversion from cyrillic to latin -- this conversion is valid in all cases.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    83
primrec azb2abc_aux :: "azbuka \<Rightarrow> abeceda list"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    84
where
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    85
  "azb2abc_aux А = [A]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    86
| "azb2abc_aux Б = [B]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    87
| "azb2abc_aux В = [V]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    88
| "azb2abc_aux Г = [G]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    89
| "azb2abc_aux Д = [D]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    90
| "azb2abc_aux Ђ = [D, J]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    91
| "azb2abc_aux Е = [E]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    92
| "azb2abc_aux Ж = [Ž]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    93
| "azb2abc_aux З = [Z]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    94
| "azb2abc_aux И = [I]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    95
| "azb2abc_aux Ј = [J]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    96
| "azb2abc_aux К = [K]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    97
| "azb2abc_aux Л = [L]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    98
| "azb2abc_aux Љ = [L, J]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
    99
| "azb2abc_aux М = [M]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   100
| "azb2abc_aux Н = [N]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   101
| "azb2abc_aux Њ = [N, J]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   102
| "azb2abc_aux О = [O]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   103
| "azb2abc_aux П = [P]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   104
| "azb2abc_aux Р = [R]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   105
| "azb2abc_aux С = [S]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   106
| "azb2abc_aux Т = [T]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   107
| "azb2abc_aux Ћ = [Ć]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   108
| "azb2abc_aux У = [U]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   109
| "azb2abc_aux Ф = [F]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   110
| "azb2abc_aux Х = [H]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   111
| "azb2abc_aux Ц = [C]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   112
| "azb2abc_aux Ч = [Č]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   113
| "azb2abc_aux Џ = [D, Ž]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   114
| "azb2abc_aux Ш = [Š]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   115
| "azb2abc_aux azbSpc = [abcSpc]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   116
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   117
primrec azb2abc :: "azbuka list \<Rightarrow> abeceda list"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   118
where
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   119
  "azb2abc [] = []"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   120
| "azb2abc (x # xs) = azb2abc_aux x @ azb2abc xs"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   121
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   122
value "azb2abc [Д, О, Б, А, Р, azbSpc, Д, А, Н, azbSpc, С, В, И, М, А]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   123
value "azb2abc [Љ, У, Б, И, Ч, И, Ц, А, azbSpc, Н, А, azbSpc, П, О, Љ, У]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   124
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   125
text \<open>
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   126
  The conversion from latin to cyrillic --
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   127
  this conversion is valid in most cases but there are some exceptions.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   128
primrec abc2azb_aux :: "abeceda \<Rightarrow> azbuka"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   129
where
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   130
   "abc2azb_aux A = А"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   131
|  "abc2azb_aux B = Б"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   132
|  "abc2azb_aux C = Ц"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   133
|  "abc2azb_aux Č = Ч"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   134
|  "abc2azb_aux Ć = Ћ"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   135
|  "abc2azb_aux D = Д"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   136
|  "abc2azb_aux E = Е"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   137
|  "abc2azb_aux F = Ф"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   138
|  "abc2azb_aux G = Г"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   139
|  "abc2azb_aux H = Х"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   140
|  "abc2azb_aux I = И"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   141
|  "abc2azb_aux J = Ј"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   142
|  "abc2azb_aux K = К"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   143
|  "abc2azb_aux L = Л"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   144
|  "abc2azb_aux M = М"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   145
|  "abc2azb_aux N = Н"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   146
|  "abc2azb_aux O = О"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   147
|  "abc2azb_aux P = П"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   148
|  "abc2azb_aux R = Р"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   149
|  "abc2azb_aux S = С"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   150
|  "abc2azb_aux Š = Ш"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   151
|  "abc2azb_aux T = Т"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   152
|  "abc2azb_aux U = У"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   153
|  "abc2azb_aux V = В"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   154
|  "abc2azb_aux Z = З"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   155
|  "abc2azb_aux Ž = Ж"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   156
|  "abc2azb_aux abcSpc = azbSpc"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   157
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   158
fun abc2azb :: "abeceda list \<Rightarrow> azbuka list"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   159
where
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   160
  "abc2azb [] = []"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   161
| "abc2azb [x] = [abc2azb_aux x]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   162
| "abc2azb (x1 # x2 # xs) = 
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   163
    (if x1 = D \<and> x2 = J then
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   164
        Ђ # abc2azb xs
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   165
     else if x1 = L \<and> x2 = J then
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   166
        Љ # abc2azb xs
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   167
     else if x1 = N \<and> x2 = J then
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   168
        Њ # abc2azb xs
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   169
     else if x1 = D \<and> x2 = Ž then
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   170
        Џ # abc2azb xs
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   171
     else
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   172
        abc2azb_aux x1 # abc2azb (x2 # xs))"
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   173
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   174
value "abc2azb [D, O, B, A, R, abcSpc, D, A, N, abcSpc, S, V, I, M, A]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   175
value "abc2azb [L, J, U, B, I, Č, I, C, A, abcSpc, N, A, abcSpc, P, O, L, J, U]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   176
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   177
text \<open>Here are some invalid conversions.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   178
lemma "abc2azb [N, A, D, Ž, I, V, E, T, I] = [Н, А, Џ, И, В, Е, Т, И]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   179
  by simp
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   180
text \<open>but it should be: НАДЖИВЕТИ\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   181
lemma "abc2azb [I, N, J, E, K, C, I, J, A] = [И, Њ, Е, К, Ц, И, Ј, А]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   182
  by simp
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   183
text \<open>but it should be: ИНЈЕКЦИЈА\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   184
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   185
text \<open>The conversion fails for all cyrillic words that contain НЈ ЛЈ ДЈ ДЖ.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   186
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   187
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   188
text \<open>Idempotency in one direction.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   189
lemma [simp]: "azb2abc_aux (abc2azb_aux x) = [x]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   190
  by (cases x) auto
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   191
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   192
lemma [simp]: "abc2azb (Ž # xs) = Ж # abc2azb xs"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   193
  by (cases xs) auto
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   194
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   195
lemma [simp]: "abc2azb (J # xs) = Ј # abc2azb xs"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   196
  by (cases xs) auto
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   197
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   198
theorem "azb2abc (abc2azb x) = x"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   199
proof (induct x)
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   200
  case Nil
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   201
  then show ?case by simp
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   202
next
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   203
  case (Cons x1 xs)
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   204
  then show ?case
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   205
  proof (cases xs)
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   206
    case Nil
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   207
    then show ?thesis by simp
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   208
  next
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   209
    case (Cons x2 xss)
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   210
    with \<open>azb2abc (abc2azb xs) = xs\<close> show ?thesis
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   211
      by auto
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   212
  qed
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   213
qed
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   214
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   215
text \<open>Idempotency in the other direction does not hold.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   216
lemma "abc2azb (azb2abc [И, Н, Ј, Е, К, Ц, И, Ј, А]) \<noteq> [И, Н, Ј, Е, К, Ц, И, Ј, А]"
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   217
  by simp
66392
c1a9bcbeeec2 misc tuning and modernization;
wenzelm
parents: 61343
diff changeset
   218
text \<open>It fails for all cyrillic words that contain НЈ ЛЈ ДЈ ДЖ.\<close>
30179
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   219
c703c9368c12 A Serbian theory, by Filip Maric.
wenzelm
parents:
diff changeset
   220
end