Designing IA for AI - Information Architecture Conference 2024
Theory of computation
1. 1
Chapter one
Introduction to theory of computation(ToC)
Chapter programme
ToC
Mathematical introductions
Basic ideas and terminologies of formal langue and
automata theory
automata
2. 2
Introduction to the theory of computation
The Theory of Computation, which tries to answer the Following questions:
What are the mathematical properties of computer hardware and software?
What is a computation and what is an algorithm? Can we give rigorous
mathematical definitions of these notions?
What are the limitations of computers? Can “everything” be computed?
Purpose of the Theory of Computation: Develop formal mathematical models of
computation that reflect real-world computers.
Nowadays, the Theory of Computation can be divided into the following three areas:
Complexity Theory, Computability Theory, and Automata Theory.
Mathematical preliminaries
A set is an unordered collection of different elements.
A set of all the planets in the solar system
A set of all the states in India
A set of all the lowercase letters of the alphabet
N − the set of all natural numbers = {1, 2, 3, 4, .....}
Z − the set of all integers = {....., −3, −2, −1, 0, 1, 2, 3, .....}
Z+ − the set of all positive integers
Q − the set of all rational numbers
R − the set of all real numbers
W − the set of all whole numbers
Sets can be represented in two ways −
Roster or Tabular Form
Set Builder Notation
3. 3
Set Builder Notation
The set is represented by listing all the elements comprising it. The elements are enclosed
within braces and separated by commas. Example :Set of vowels in English alphabet, A
= {a,e,i,o,u}
Roster or Tabular Form
If we are given a set A such that x is in A iff x has property P, then we write A = {x | x
has property P}A = { x : p(x)}. Example: Thus, P = {x | x is a prime number} is the
set of prime numbers. Similarly, if we want to only look at prime numbers of the form
n2
+1 we could write {x ∈ P | there exists a natural number n, such that x = n2 + 1.}
A more compact way of denoting this set is {x ∈ P | (∃n ∈ N) ∋ (x = n2 + 1)} or even
simply {x ∈ P | (∃n ∈ N)(x = n2 + 1)}.
Example − The set {a,e,i,o,u} is written as − A = { x : x is a vowel in English alphabet}.
Cardinality of a set S, denoted by |S|, is the number of elements of the set. If a set has an
infinite number of elements, its cardinality is ∞.
Example − |{1, 4, 3, 5}| = 4, |{1, 2, 3, 4, 5,…}| = ∞
Sets can be classified into many types. Some of which are finite, infinite, subset,
universal, proper, etc. A set which contains a definite number of elements is called a
finite set. Example − S = {x | x N and 70 > x > 50}. A set which contains infinite
number of elements is called an infinite set. Example − S = {x | x N and x > 10}
An empty set contains no elements. It is denoted by . As the n umber of elements in an
empty set is finite, empty set is a finite set. The cardinality of empty set or null set is zero.
If two sets contain the same elements they are said to be equal.
Example − If A = {1, 2, 6} and B = {6, 1, 2}, they are equal as every element of set A is
an element of set B and every element of set B is an element of set A.
If the cardinalities of two sets are same, they are called equivalent sets.
Example − If A = {1, 2, 6} and B = {16, 17, 22}, they are equivalent as cardinality of A
is equal to the cardinality of B. i.e. |A| = |B| = 3
4. 4
If two sets C and D are disjoint sets as they do not have even one element in common.
The intersection of any two distinct sets is empty.
A relation associates elements of one set called the domain, with elements of another set
called the co domain (both sets are non-empty set) example: One set: set of students.
Another set: set of subjects.Functions are especial relations.
A graph is a pictorial representation of a set of objects where some pairs of objects are
connected by links. The interconnected objects are represented by points termed as
vertices, and the links that connect the vertices are called edges.
Formally Definition − A graph (denoted as G = (V, E)) consists of a non-empty set of
vertices or nodes V and a set of edges E.
Example − Let us consider, a Graph is G = (V, E) where V = {a, b, c, d} and E = {{a, b},
{a, c}, {b, c},{c, d}}
Take a look at the following graph –
a b
c d e
In the above graph,
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}
Tree
Tree is a special form of graph having no loops, no circuits and no self-loops. A
connected acyclic graph is called a tree. In other words, a connected graph with no cycles
is called a tree. The edges of a tree are known as branches. Elements of trees are called
their nodes. The nodes without child nodes are called leaf nodes.
5. 5
Basic concepts of automata and Language Theory
Formal language theory, the discipline which studies formal grammars and languages,
is a branch of applied mathematics computer science. Its applications are found in
theoretical computer science, theoretical linguistics, formal semantics, mathematical
logic, and other areas.
A formal grammar (sometimes simply called a grammar) is a set of rules for forming
strings in a formal language. The rules describe how to form strings from the language's
alphabet that are valid according to the language's syntax. A grammar does not describe
the meaning of the strings or what can be done with them in whatever context – only their
Form, i.e. their internal structural patterns.
An alphabet is any finite, non-empty set of symbols, usually denoted by the symbol ∑
(sigma) and write Σ = {a1, . . . , ak}. The ai are called the symbols of the alphabet.
Examples:
Binary: ∑ = {0,1}
All lower case letters: ∑ = {a,b,c,..z}
Alphanumeric: ∑ = {a-z, A-Z, 0-9}
A string (sometimes a word) is a finite sequence of symbols chosen from ∑. Length of a
string w, denoted by “|w|”, is equal to the number of (non- ) characters in the string(or
positions). The empty string, denoted by (or “epsilon”), is the string having length zero.
For example, if the alphabet is equal to {0, 1}, then 10, 1000, 0, 101, and are strings
over, having lengths 2, 4, 1, 3, and 0, respectively.
E.g., x = 010100 |x| = 6
x = 01 0 1 00 |x| = ?
If w=„cabcad‟, |w|= 6
If |w|= 0, it is called an empty string (Denoted by λ or ε)
6. 6
The set of all strings over Σ of length n is denoted n
. For example, if Σ = (0, 1), then
2
= {00, 01, 10, 11}. Note that 0
= {ε} for any alphabet Σ, power of an alphabet
Examples:
If ={0,1}, then
0
:{} regardless what the alphabet is.
1
= {0, 1}.
2
= {00, 01, 10, 11}.
3
= {000, 001, 010, 011, 100, 101, 110, 111}.
Kleene star (or Kleene operator or Kleene closure)
The set of all strings over Σ of any length is the Kleene star of Σ and Is denoted Σ*.
Representation: Σ*= Σ0
∪Σ1
∪Σ2
∪. . .
For example, if Σ = (0, 1), Σ* = (ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011 …).
Example − If Σ = {a, b}, Σ*= { ε, a, b, aa, ab, ba, bb,………..}
Languages: “A language is a collection of sentences (words) of finite length all
constructed from a finite alphabet of symbols”.
A language L is a possibly infinite set of strings over a finite alphabet Σ. If Σ is an
alphabet, and L ⊆ Σ *, then L is a formal language over Σ. (formal definition)
Operations on Languages
Operations that can be used to construct languages from other languages are language
operations. Since languages are sets, we can use the usual set operations, Union, L1∪L2,
Intersection, L1∩L2, Complement, Lc, Set difference, L1-L2. The intersection L1 ∩ L2
of L1 and L2 consists of all strings which are contained in both languages and the
complement ¬L of a language with respect to a given alphabet consists of all strings over
the alphabets that are not in the language.
7. 7
We also have new operations defined especially for sets of strings:
Concatenation, L1◦L2 or justL1L2
Star, L*
Concatenation
L1◦L2 = { x y | x ∈L1and y ∈L2 } x and y are strings
–Pick one string from each language and concatenate them.
•Example: Σ= { 0, 1 }, L1= { 0, 00 }, L2 = { 01, 001 }
L1◦L2 = { 001, 0001, 00001 }
•Notes: | L1◦L2 | ≤| L1| ×|L2 |, not necessarily equal.
L ◦L does not mean { x x | x ∈L }, but rather, { x y | x and y are both in L}.
Example: Σ= { 0, 1 }, L1= { 0, 00 }, L2 = { 01, 001
L1◦L2 = { 001, 0001, 00001 }
L2◦L2 = { 0101, 01001, 00101, 001001 }
Example: ∅◦L= { x y | x ∈∅and y ∈L} = ∅
_____ { ε} ◦L={ x y | x ∈{ ε} and y ∈L} = L
______L1◦L2 = { x y | x ∈L1and y ∈L2 }
Write L ◦L as L2
, L ◦L ◦…◦L as Ln
, which is { x1x2…xn| all x‟s are in L }
Example: L = { 0, 11 },L3
= { 000, 0011, 0110, 01111, 1100, 11011, 11110, 111111 }
Example: L = { 0, 00 },L3
= { 000, 0000, 00000, 000000 }
Boundary cases: L1 = L
Define L
0
= { ε}, for every L__Implies that L0
Ln
={ ε} Ln
= Ln
, Special case of general
rule La
Lb
= La+b
.
The Star Operation
•L* = { x | x = y1y2…yk for some k ≥0, where every y is in L }
= L0
∪L1
∪L2
∪…
8. 8
Note: ε is in L* for every L, since it‟s in L0
.
Example: What is ∅* ? –Apply the definition: ∅* = ∅0
∪ ∅1
∪ ∅2
∪…= { ε}.
∅0
is { ε},by the convention that L0
=
{ ε}.
The rest of these are just
∅.
Example: What is { a }* ?
–Apply the definition:
{ a }*= { a }
0
∪{ a }
1
∪{ a }
2
∪…
= { ε} ∪{ a } ∪{ a a } ∪…
= { ε, a, a a, a a a, …}
–Abbreviate this to just a*.
–Note this is not just one string, but a set of strings---any number of a‟s
Example: What is Σ*?
–We‟ve already defined this to be the set of all finite strings over Σ.
–But now it has a new formal definition: Σ*= Σ0
∪Σ1
∪Σ2
∪…
= {ε} ∪ {strings of length 1 over Σ}
∪ {strings of length 2 over Σ}
∪…
= { all finite strings over Σ}
L is a said to be a language over alphabet ∑, only if L∑* this is because ∑* is the set
of all strings (of all possible length including 0) over the given alphabet ∑
Examples:
1. Let L be the language of all strings consisting of n 0‟s followed by n 1‟s: L =
{,01,0011,000111,…}
2. Let L be the language of all strings of with equal number of 0‟s and 1‟s:
L{,01,10,0011,1100,0101,1010,1001,…}
Definition: Ø denotes the Empty language
Let L = {}; Is L=Ø? NO, why?
9. 9
Automata theory
Automata theory is the study of abstract machines (or more appropriately, abstract
„mathematical‟ machines or systems) and the computational problems that can be solved
Using these machines. These abstract machines are called automata (singular
,automaton).
Automata Theory deals with definitions and properties of different types of
“Computation models”. Examples of such models are:
Finite Automata. These are used in text processing, compilers, and hardware
design.
Context-Free Grammars. These are used to define programming languages and in
Artificial Intelligence.
Turing Machines. These form a simple abstract model of a “real” computer, such
as your PC at home.
The above figure illustrates a finite state machine, which is one well-known variety of
automata. This automaton consists of states (represented in the figure by circles), and
transitions (represented by arrows). As the automaton sees a symbol of input, it makes a
transition (or jump) to another state, according to its transition function (which takes the
current state and the recent symbol as its inputs).