15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Even though the definition of the lexical ordering is relatively involved, we know it very well, it is<br />

the ordering we know from the telephone books.<br />

The next task for understanding programs as mathematical objects is to understand the process<br />

of using strings to encode objects. The simplest encodings or “codes” are mappings from strings<br />

to strings. We will now study their properties.<br />

2.4.2 Elementary Codes<br />

The most characterizing property for a code is that if we encode something with this code, then<br />

we want to be able to decode it again: We model a code as a function (every character should<br />

have a unique encoding), which has a partial inverse (so we can decode). We have seen above,<br />

that this is is the case, iff the function is injective; so we take this as the defining characteristic of<br />

a code.<br />

Character Codes<br />

Definition 204 Let A and B be alphabets, then we call an injective function c: A → B +<br />

a character code. A string c(w) ∈ {c(a) | a ∈ A} := B + is called a codeword.<br />

Definition 205 A code is a called binary iff B = {0, 1}.<br />

Example 206 Let A = {a, b, c} and B = {0, 1}, then c: A → B + with c(a) = 0011,<br />

c(b) = 1101, c(c) = 0110 c is a binary character code and the strings 0011, 1101, and 0110<br />

are the codewords of c.<br />

Definition 207 The extension of a code (on characters) c: A → B + to a function c ′ : A ∗ →<br />

B ∗ is defined as c ′ (〈a1, . . . , an〉 = 〈c(a1), . . . , c(an)〉).<br />

Example 208 The extension c ′ of c from the above example on the string ”b, b, a, b, c”<br />

Morse Code<br />

c ′ (”b, b, a, b, c”) =<br />

<br />

1101,<br />

1101<br />

<br />

, 0011<br />

<br />

, 1101<br />

<br />

, 0110<br />

<br />

c(b) c(b) c(a) c(b) c(c)<br />

c○: Michael Kohlhase 120<br />

In the early days of telecommunication the “Morse Code” was used to transmit texts, using<br />

long and short pulses of electricity.<br />

Definition 209 (Morse Code) The following table gives the Morse code for the text<br />

characters:<br />

A .- B -... C -.-. D -.. E .<br />

F ..-. G –. H .... I .. J .—<br />

K -.- L .-.. M – N -. O —<br />

P .–. Q –.- R .-. S ... T -<br />

U ..- V ...- W .– X -..- Y -.–<br />

Z –..<br />

1 .—- 2 ..— 3 ...– 4 ....- 5 .....<br />

6 -.... 7 –... 8 —.. 9 —-. 0 —–<br />

Furthermore, the Morse code uses .−.−.− for full stop (sentence termination), −−..−− for<br />

comma, and ..−−.. for question mark.<br />

65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!