0% found this document useful (0 votes)
12 views24 pages

Computation Theory Lec

Uploaded by

Mahdi Last
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)
12 views24 pages

Computation Theory Lec

Uploaded by

Mahdi Last
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/ 24

BASICS OF LANGUAGE

(ALPHABET, STRING, SET, OPERATIONS)

‫ داليا سامي جاسم‬.‫م‬.‫م‬


ALPHABETS
• An alphabet is a finite non empty set of symbols, which used to
represent the input of a machine. Alphabets are typically thought of as
represented by letters, characters, digits, signs, punctuation, etc.
Conventionally we use the symbol ∑(sigma) for an alphabet. Common
alphabets include:
• ∑ = {0, 1}: The binary alphabets.
• ∑ = {a, b, c, ……, z}: The set of all lower-case letters.
• ∑ = {The sets of all ASCII characters or the set of all printable ASCII
characters}.
Strings:
A string is a finite ordered sequence of symbols chosen from
some set of alphabet or ∑. For example, ‘aababbbbaa’ is a
valid string from the alphabet ∑ = {a, b}, similarly
‘001111000101’ is a valid string form the alphabet
∑ = {0, 1}.
Empty string:
Every alphabet ∑ has a special string called empty string
which means the string with zero occurrences of symbols. This
string represented by λ (Lambda), e or ε. It is the string that
may be chosen from any alphabet whatsoever.
Length of a string:
The finite occurrence of input symbols form ∑ present
the length of a string. If s denotes the string over
alphabet ∑ then length of a string is represented by
|S|. For instance, ‘001110’ is a string from the
alphabets ∑= {0, 1} has length 6. Similarly if ∑ =
{a, b} and S = ‘aabbabbba’ then |S| = 9.
Note: The length of empty string | ε| = 0.
Power of an alphabet:

If ∑ is an alphabet, we can express the set of all strings of a


certain length form that alphabet by using an exponential
notation. We denoted it ∑n to be the set of strings of length
n, each of those symbols is in given input alphabet ∑.
For example: ∑0 = {ε} regardless of what alphabet ∑ is, i.e.
ε is the only string whose length is zero.
If ∑ = {0, 1}, then ∑1 = {0, 1}, similarly ∑2 = {00, 01, 10,
11} or
∑3 = {000, 001, 010, 011, 100, 101, 110, 111} and so on.
String Length
W = a1a2 an (an is letter)

Length: w =n

Examples: abba = 4
aa = 2
a =1
EMPTY STRING
A string with no letters:

Observations:  =0

w = w = w

abba = abba = abba


SUBSTRING
Substring of string:
a subsequence of consecutive characters

String Substring
abbab ab
abbab abba
abbab b
abbab bbab
Prefix and Suffix
abbab
Prefixes Suffixes
 abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab 
Another Operation
wn =
ww

w

n

Example: (abba) = abbaabba


2

Definition: w0 =

(abba)0 = 
The * Operation
* : THE SET OF ALL POSSIBLE
STRINGS FROM ALPHABET 

 = a,b
* = ,a,b, aa,ab,ba,bb,aaa,aab,
The + Operation
+
 : the set of all possible strings from alphabet 
except

 = a,b
* = ,a,b, aa,ab,ba,bb,aaa,aab,

+ = * −
 + = a,b,aa,ab,ba,bb,aaa,aab,
Languages
A language is any subset of *

Example:  = a,b
* = ,a,b, aa,ab,ba,bb,aaa,

Languages: 
a,aa,aab
{, abba,baba, aa, ab, aaaaaa}
Note that:

Sets  = {}  {} ( IS NULL→ NO STRING)

Set size {} =  = 0
Set size {} = 1
String length
 =0
Operations on Languages
In computation theory, operations on languages
refer to various transformations or combinations of
languages. These operations play a crucial role in
understanding the behavior of different classes of
languages, such as regular languages, context-free
languages, and recursively enumerable languages.
The operations typically modify or combine existing
languages to produce new ones.
Operations on Languages
1. Union (L₁ ∪ L₂)
The union of two languages L₁ and L₂ consists of all strings that are
in L₁ or L₂ or in both.
•Definition:
L1∪L2={w∣w∈L1 or w∈L2}
•Example:
If L₁ = {"ab", "ba"} and L₂ = {"aa", "bb"}, then
L1∪L2={"ab", "ba", "aa", "bb"}
Operations on Languages
2. Concatenation (L₁ · L₂)
The concatenation of two languages L₁ and L₂ consists of all strings
that can be formed by taking a string from L₁ followed by a string from
L₂.
•Definition:
L1⋅L2={xy∣x∈L1,y∈L2}
•Example:
If L₁ = {"ab", "cd"} and L₂ = {"xy", "yz"}, then
L1⋅L2={"abxy", "abyz", "cdxy", "cdyz"}
Operations on Languages
3. Kleene Star (L*)
The Kleene star of a language L consists of all possible
strings that can be formed by concatenating zero or more
strings from L, including the empty string.
•Definition:
L∗={x1x2…xn∣xi∈L,n≥0}
•Example:
If L = {"a", "b"}, then
L∗={ϵ,"a", "b", "aa", "bb", "ab", "ba", "aaa", …}
Operations on Languages

4. Intersection (L₁ ∩ L₂)


The intersection of two languages L₁ and L₂ consists of all
strings that are in both L₁ and L₂.
•Definition:
L1∩L2={w∣w∈L1 and w∈L2}}
•Example:
If L₁ = {"ab", "bc", "de"} and L₂ = {"bc", "de", "ef"}, then
L1∩L2={"bc", "de"}
Operations on Languages
5. Complement (L̅)
The complement of a language L is the set of all strings
over the alphabet that are not in L.
•Definition:
L‾={w∣w∉L}
•Example:
If L = {"ab", "bc"}, and the alphabet is Σ = {a, b, c}, the
L‾ includes all strings over Σ that are not "ab" or "bc",
such as "aa", "bb", "cc", "abc", etc.
Operations on Languages
6. Difference (L₁ - L₂)
The difference of two languages L₁ and L₂ (also called
relative complement) consists of all strings that are in L₁
but not in L₂.
•Definition:
L1−L2={w∣w∈L1 and w∉L2}
•Example:
If L₁ = {"ab", "bc", "cd"} and L₂ = {"bc", "de"}, then
L1−L2={"ab", "cd"}
Operations on Languages
7. Reversal (L^R)
The reversal of a language L is the set of strings where
each string in L is reversed.
•Definition:
LR={wR∣w∈L}
•Example:
If L = {"ab", "cd"}, then
LR={"ba", "dc"}
closure
The concept of closure in automata theory refers to the idea that a set of
languages (recognized by a type of automaton) is closed under a
specific operation if, when you apply that operation to languages from
the set, the result is also a language within the same set.
In simpler terms:
• If you take two languages that can be recognized by a certain type of
automaton and apply an operation to them (like union, concatenation,
etc.), the new language that results from this operation should still be
recognizable by the same type of automaton.
• Closure properties help us understand how robust certain classes of
languages are with respect to different operations.
closure
Closure in Regular Languages (Finite Automata):
Regular languages are languages that can be recognized by finite
automata. A key feature of regular languages is that they are closed
under many operations.
Regular languages are closed under:
• Union: If two regular languages are combined using the union
operation, the resulting language is also regular.
Example:
If L₁ = {"a", "aa"} and L₂ = {"b", "bb"}, then
L1∪L2={"a","aa","b","bb"} The result is still regular.

You might also like