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.

Example 191 If A = {a, b, c}, then A ∗ = {ɛ, a, b, c, aa, ab, ac, ba, . . ., aaa, . . .}.<br />

Definition 192 A set L ⊆ A ∗ is called a formal language in A.<br />

Definition 193 We use c [n] for the string that consists of n times c.<br />

Example 194 # [5] = 〈#, #, #, #, #〉<br />

Example 195 The set M = {ba [n] | n ∈ N} of strings that start with character b followed<br />

by an arbitrary numbers of a’s is a formal language in A = {a, b}.<br />

Definition 196 The concatenation conc(L1, L2) of two languages L1 and L2 over the same<br />

alphabet is defined as conc(L1, L2) := {s1s2 | s1 ∈ L1 ∧ s2 ∈ L2}.<br />

c○: Michael Kohlhase 117<br />

There is a common misconception that a formal language is something that is difficult to understand<br />

as a concept. This is not true, the only thing a formal language does is separate the “good”<br />

from the bad strings. Thus we simply model a formal language as a set of stings: the “good”<br />

strings are members, and the “bad” ones are not.<br />

Of course this definition only shifts complexity to the way we construct specific formal languages<br />

(where it actually belongs), and we have learned two (simple) ways of constructing them by<br />

repetition of characters, and by concatenation of existing languages.<br />

Substrings and Prefixes of Strings<br />

Definition 197 Let A be an alphabet, then we say that a string s ∈ A ∗ is a substring of a<br />

string t ∈ A ∗ (written s ⊆ t), iff there are strings v, w ∈ A ∗ , such that t = vsw.<br />

Example 198 conc(/, 1, h) is a substring of conc(/, /, 1, h, 1), whereas conc(/, 1, 1) is not.<br />

Definition 199 A string p is a called a prefix of s (write p s), iff there is a string t, such<br />

that s = conc(p, t). p is a proper prefix of s (write p ⊳ s), iff t = ɛ.<br />

Example 200 text is a prefix of textbook = conc(text, book).<br />

Note: A string is never a proper prefix of itself.<br />

c○: Michael Kohlhase 118<br />

We will now define an ordering relation for formal languages. The nice thing is that we can induce<br />

an ordering on strings from an ordering on characters, so we only have to specify that (which is<br />

simple for finite alphabets).<br />

Lexical Order<br />

Definition 201 Let A be an alphabet and

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

Saved successfully!

Ooh no, something went wrong!