0% found this document useful (0 votes)
43 views3 pages

2022 CSC 353 2.0 2 Alphabets and Languages

The document defines basic concepts related to strings, alphabets, languages and regular expressions. It defines an alphabet as a set of symbols, a string as a sequence of symbols from an alphabet, and concepts like the empty string, length of a string, concatenation and reversal of strings. A language is defined as a set of strings over an alphabet. Operations on languages like complement, concatenation and Kleene closure are introduced. Regular expressions are defined as a way to represent regular languages using operators like concatenation, union and Kleene star applied to symbols of an alphabet. The class of regular languages is the set of languages representable by regular expressions.

Uploaded by

Chavini Hewage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

2022 CSC 353 2.0 2 Alphabets and Languages

The document defines basic concepts related to strings, alphabets, languages and regular expressions. It defines an alphabet as a set of symbols, a string as a sequence of symbols from an alphabet, and concepts like the empty string, length of a string, concatenation and reversal of strings. A language is defined as a set of strings over an alphabet. Operations on languages like complement, concatenation and Kleene closure are introduced. Regular expressions are defined as a way to represent regular languages using operators like concatenation, union and Kleene star applied to symbols of an alphabet. The class of regular languages is the set of languages representable by regular expressions.

Uploaded by

Chavini Hewage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Definition 2.1.

1
An alphabet is a finite set of symbols.
Definition 2.1.2
A string over an alphabet is a finite sequence of symbols from the alphabet.
We usually use u, v, w, x, y, z and Greek letters to denote strings.
Definition 2.1.3
Alphabets and Languages The empty string, denoted by e, is the string containing no symbols at all.
Note:
Set of all strings, including empty string, over an alphabet  is denoted by *.
Example:
 = {a, b}
 * = {e, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, … }
Definition 2.1.4
The length of a string w, denoted by w, is defined as its length as a sequence.
1
2

Definition 2.1.5 Definition 2.1.8


The concatenation, w, of two strings x and y over a same alphabet is defined as The reversal of a string w  *, denoted by wR, is defined inductively as
the string x followed by string y, and is denoted by w = x o y or w = xy. 1. If w= 0, then wR = w = e
Note: 2. If w > 0, then w = ua for some a  , u  *, and, wR = auR
• x o y = x + y
Note
• w o e = e o w = w for any string w
Reversal of a string is the string spell backwardly.
• Concatenation is associative. i.e. x o (y o z) = (x o y) o z for any strings x, y
and z 2.2 Languages
Definition 2.1.6 Definition 2.2.1
A string v is a substring of a string w if and only if there exists strings x and y Any set of strings over an alphabet  is called a language.
such that w = xvy.
Note
Definition 2.1.7
• *, , and  are languages over 
For each string w  *, w i is defined as follows
• * is infinite
w0=e
w i+1 = w i o w for each i  0 Operations on languages
Definition 2.2.2
The complement of a language L over , denoted by L , is defined as * - L.
3 4
Definition 2.2.3 Note
If L1 and L2 are languages over , their concatenation L, denoted by L • * = {e}
= L1 o L2 (or L1L2), is defined as
• For any languages L1, L2, L1  L2,  L1*  L2*
L = { w  * w = x o y for some x  L1, y  L2}
Definition 2.2.5
Example:
Let  = {0, 1}, L+ = L L* = {w  *w = w1 o … o wk; k  1, and some w1, …, wk  L}
L1 = { w  *w has an even no. of 0s} 2.3 Finite representation of languages
L2 = { w  *w starts with 0 and rest are 1s}  Finite language  Can list all the strings in the language
 L1 o L2 = {w  *w has an odd no. of 0s}  Infinite language (most languages)  Need to represent them finitely
Desired properties in representation
Definition 2.2.4
The Kleene star of a language L, denoted by L*, is the set of all strings  representation should be by a string, a sequence of symbols over an
obtained by concatenating zero or more strings from L. i.e. alphabet
L* = {w  *w = w1 o … o wk ; k  0, and some w1, …, wk  L}  different languages should have different representations
Example 2.2.3
Let L = {00, 01, 10, 11}
 1000111110 = 10 o 00 o 11 o 11 o 10  L* 5 6

Note Definition 2.4.1


• Set * of strings over an alphabet  is countably infinite
The regular expressions over an alphabet  are all strings over alphabet
no. of possible representations is countable   {(, ), , , *} satisfying the following properties
• 2*, set of all possible languages over an alphabet , is uncountable
•  is a regular expression
 We cannot represent all languages finitely • Every member of  is a regular expression
2.4 Regular languages • If  and  are regular expressions, then so are (), (  ), and *

Consider the language • Every regular expression represents a language


L = { w  {0,1}* w has 2 or 3 occurrences of 1, the 1st and 2nd of which are • Relation between regular expressions and the language they represent is
not consecutive} established by a function L
L can be described by using only singleton sets and language operators; L() - language represented by the regular expression 
concatenation, Kleene star, and union (set union):
L = {0}* o {1} o {0}* o {0} o {1} o {0}* o (({1} o {0}*)  *)
= 0*10*010* (10*  *)

Regular expression 7
8
Definition 2.4.2 Example:
• L() =  Let  = c*(a  (bc*))*
• L(a) = {a} for any a    L() is the set of all strings over {a, b, c} that do not contain the
substring ac
• If  and  are regular expressions, then
L() = L() L() Definition 2.4.3
L(  ) = L()  L() Class of regular languages over an alphabet  is defined as the set of all
languages L() for some regular expression  over .
L(*) = L()*
Example: Regular languages can be defined in terms of closures.
Let  {a, b}. The language represented by the regular expression (a  b)*a Class of regular languages over  is the closure of the set of languages
is
{ {}     }  {} under union, concatenation, and Kleene star.
L((a  b)*a) = L((a  b)*) L(a)
i.e., the class of regular languages is the set of languages satisfying the
= L((a  b)*) {a}
following properties:
= L(a  b)* {a}
= (L(a)  L(b))* {a} • Empty language () is regular
= ({a}  {b})* {a} = {a, b}* {a} • {} ;    is a regular language
= {w  {a, b} w ends with an a} • If L1 and L2 are regular languages, then L1*, L1  L2, and L1 o L2
9 are also regular 10

Note Alternative method (language generators)


• Not possible to describe all languages by regular expressions
Ex: {0n1n  n  0} is not regular Example:
• Regular expressions are an inadequate method of language specification Let  = (e  b  aa) (a  ab  aab)*
Language recognition device Members of L() can be generated as:
An algorithm that is designed to check whether a certain string is a member • Write down either nothing, or b, or aa
of the language. • Write down a or ab, or aab, and do this any number of times,
Example: including zero
L = {w  {0, 1}* w does not have 111 as a string} Note
A device for recognizing L Such language generators are not algorithms.
• Read strings, one symbol at a time, from left to right
• Keep a count (initially zero)
• Add 1 to count when a 1 is encountered in input. Set count to zero
when a 0 is encountered
• Stop with answer “No” if count reaches three, or stop with answer
“Yes” if the whole string is read without count reaching the value of
three 11 12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy