DOC PREVIEW
UCF COT 3100 - Lecture Notes

This preview shows page 1-2-22-23 out of 23 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 231Strings• A string over a set A is a finite sequence of elements from A.Definition. An alphabet is a nonempty, finite set of indivisible symbols. We are going to denote it by . • Any program is a string of keywords, variable names, and permissible symbols. • The set of elements from which the strings are built is called an alphabet. • A programming language should satisfy general rules (grammar) to be understood by computer (compiler). These rules are studied by the formal theory of programming languages.2Definition. A string w over an alphabet  is a sequence of symbols, w = a1 a2… an, where each ai , 1 i  n. • The number of symbols is called the length of the string, |w|=n.There is one special string that has zero length (contains no symbols).It is called the empty string and has special notation , .|w|=0  w = . is not an element of any alphabet,  .Example. Let  = {a, b, c}. Find all possible strings with length less or equal 3 built from . Length 0: Length 1: a b cLength 2: aa ab ac ba bb bc ca cb ccLength 3: aaa aab aac aba abb abc aca acb acc …3• Two strings u and v can be concatenated to form a singlestring uv, that consists of the symbols of string u, followed by symbols of of string v. The length | uv | = | u|+| v |.• u = u = u • Concatenation is associative: (uv)w = u(vw),but not commutative: uv  vu (the order is important!).4Definition. Any set of strings over some alphabet is called a language. Alphabet itself is a language as well (the language of all one-symbol words). Since languages are sets, we can apply all set operations to languages: union, intersection and set difference. There is one operation specific for languages: concatenation of two languages : L1L2 ={uv | u  L1 and v  L2 } Q : L1L2 = L2L1 ? A: L1L2  L2L1 Examples: Set of all executable computer programs is a language.5Example. Take the alphabet  = {a, b, c}. Consider two languagesover alphabet : L1 ={a, ab} and L2 ={b, bc, c}. Find L1L2 and L2L1.We need to take every string from L1 and concatenate with everystring from L2 . In this way we get |L1| |L2 | strings: ab, abc, ac, abb, abbc, abc.Note, that not all strings are distinct, like abc. L1L2 = {ab, abc, ac, abb, abbc} . The cardinality | L1L2 | is the number of distinct strings,resulting from concatenation . In general, | L1L2 |  | L1|  |L2 |and | L1L2 |  | L2L1 | In the example | L1L2 | = 5< | L1|  |L2 |=6. In the same way: L2L1 = {ba, bab, bca, bcab, ca, cab}.6In particular, we can consider the concatenation of an alphabet  with itself:  is the language of all two-symbol words. Notation:   = 2 What is   2? Similarly, 3 = 2, the language that consists of all 3-symbolwords: 3 ={aaa, aba, baa, bba, aab, abb, bab, bbb}. To make this recursive definition agree with the basis case n =1,  = 0 , zero power 0 is defined as 0 = {}, (no matter what is  ). Then {} ={ x | x  } = { x | x   }=  What is   2  3  …  n ?Example: ={a, b},  = 2 = {aa, ab, ba, bb} So, we can define recursively for any n>1: n = n-17‘Kleene star’ notation: * = 0  1  2  … So, * is the (infinite) set of all possible words over alphabet ,including empty string . Example.  = {0, 1}. * is an infinite set of all possible bit strings.(or all binary numbers including numbers with leading 0’s and empty string).Any language L over alphabet  is a subset of  *, L   *. Note that {} , because  ={}  {}| { }|=1, ||=|{}|=0.A language L may contain  , or may not.8Example. Consider two languages over alphabet  = {a}: L1={aa}, L2={, aa, aaaa}. What is L1*? By definition of Kleene star L1* = L10  L11  L12  … ={}{aa} {aaaa} {aaaaaa} …What is L2*? L2* = L20  L21  L22  … ={}{, aa, aaaa} {, aa, aaaa, aaaaaa, aaaaaaaa}…={, aa, aaaa, aaaaaa, …} = L1* = {, aa, aaaa, aaaaaa, …}infinite set of strings of even length build from symbol a.9Definition. A string u is called a substring of v if there exist twostrings x and y, such that v = xuy, and x, y  * Definition. A string u is called a prefix of v if there exists a string x  *, such that v = ux. Similarly, a string u is called a suffix of v if there exists a string y  *, such that v = yu.10Theorem 1. Let A, B and C be sets of strings. Then (AB)C = ACBC Proof. a) We need to prove the equality of two sets of strings. We can do it by double-inclusion, i. e. to show that i) (AB)C  ACBC andii) ACBC  (AB)C11i) To prove (AB) C  ACBC, it’s suffices to show that for any string w, w(AB)C  w A C BC Take any w (AB)C … (xA or xB) and y C (dfn of  )(dfn of concat)x, y, such that w = xy and x(AB) and yC … (xA and yC) or (xB and yC) (distributive property) w AC or wBC (dfn of concat)  w AC BC (dfn of  )12ii) To prove that ACBC (AB)C, we need to show that for any string w, w ACBC  w (AB)CTake any w  AC BC  w AC or w BC (dfn of )x, y, such that w = xy and (x A and y C) or (x  B and y C) (dfn of concat) w (AB)C (dfn of concat)So, we proved ACBC (AB)C and (AB)CACBC,that means (AB)C = A CBC So we can have two cases. In the first case, (x A and y C) implies that (x AB and y C) because A (AB).In the second case, (x B and y C) implies that (x AB and y C) because B (AB). So, in either case we have13Proof. To prove subset relation we need to show that for any string w, w(AB)C  wAC BC. Why not to prove ACBC  (AB)C as well? Let’s try. Take arbitrary


View Full Document

UCF COT 3100 - Lecture Notes

Documents in this Course
Lab 1

Lab 1

11 pages

Functions

Functions

10 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?