0% found this document useful (0 votes)
90 views

Unit - 1

The document provides an overview of topics covered in a theory of computation course, including an introduction to automata theory, formal languages, and computational models like Turing machines. Key concepts discussed include sets, logic, proofs, formal languages over alphabets, strings, the empty set, set operations, partitions of sets, and power sets. The course will examine mathematical models of computation and their capabilities and limitations.

Uploaded by

Third Semester
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)
90 views

Unit - 1

The document provides an overview of topics covered in a theory of computation course, including an introduction to automata theory, formal languages, and computational models like Turing machines. Key concepts discussed include sets, logic, proofs, formal languages over alphabets, strings, the empty set, set operations, partitions of sets, and power sets. The course will examine mathematical models of computation and their capabilities and limitations.

Uploaded by

Third Semester
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/ 139

Unit: 1

Theory of Basic
Foundation
Computation
Presented by: Loknath
Regmi
TOPICS COVERED
• Introduction
• Review of Set
• Review of Logic
• Review of Proof
• Automata Theory
• Symbols and alphabet
• Language
• Valid/invalid computation
RESOURSES
• TEXT BOOK:
• J.E.Hopcroft, R.Motwani and J.D Ullman, ―Introduction to Automata
Theory, Languages and Computationsǁ, Second Edition, Pearson
Education, 2003.
• REFERENCES:
• H.R.Lewis and C.H.Papadimitriou, ―Elements of the theory
Computation,
of Second Edition, PHI, 2003.
• J.Martin, ―Introduction to Languages and the Theory of Computation,
Third Edition, TMH, 2003.
• Micheal Sipser, ―Introduction of the Theory and
Computation,
Thomson Brokecole, 1997.
Theory of Computation
❖ Computation is calculation, solving, making decision or
any task done by computer/calculator/ any machine.
❖ The term Theory defines capabilities, limitations of those
machines.

❖ “Develop formal mathematical models of computation


that reflect real-world computers.”
INTRODUCTION
• Mathematicalmodels of computer
– To complete various tasks
– What can’t a computer do?
– What can a computer do?
– How efficiency can a computer solve?
– Turing Machine
INTRODUCTION
• Automata Theory
– FSA/FSM
– Pushdown Automata
– Linerbounded Automata
– Turing Machine
• Computability Theory
– Kind of problem solved by a model
• Complexity Theory
– Efficiency of problem
APPLICATION
• Compiler Design
– FSA/ FSM
• Pattern Matching
– Online Filling Forms
• Linux /Unix OS Command 🡪 grep
• Syntax Testing
– Pushdown Automata
Basic Definitions
🡪 A Set is a collection of items,
called elements.
🡪 {1, 2, 3}
🡪 {x ∈ R | x2 > 5}
🡪 S = {Tom, Sue, Jim}
Basic Definitions
🡪 We use ellipses to simplify things:
🡪 {1, 2, 3, …, 10}
🡪 {1, 2, 3, …}
🡪 {…, -2, -1, 0, 1, 2, …}
🡪 Be careful! ({1, 2, …}???)
Basic Definitions
🡪 We relate an item in the set with the set using
the “∈ (element of)” relation.
🡪 x ∈ {x, y, z}
🡪 {1, 2} ∈ {{1, 2}, {1, 2, 3}}.
Special Sets
🡪 We refer to specific sets of numbers so
often that we give them special names.
🡪 These sets, and their corresponding
symbols, will be referenced throughout
this course.
Natural Numbers
🡪 We define the Natural Numbers to be:

N = {0, 1, 2, 3, …}

🡪 Note that the Naturals are “closed” under


addition and multiplication.
The Integers
🡪 We define the Integers to be:

Z = {…, -2, -1, 0, 1, 2, 3, …}

🡪 Note that Z is “closed” under addition,


subtraction, and multiplication.
The Rational Numbers
🡪 We define the Rationals to be:

Q = {p/q | p,q Î Z and q ¹ 0}

🡪 Note that Q is “closed” under addition,


subtraction, multiplication, and non-zero division.
🡪 Alternatively, we can view Q as the set of all
infinite, repeating decimal expansions.
🡪 7.35 = 7.3500000… ∈ Q
🡪 1.234234234… ∈ Q
🡪 However, π ∉ Q
The Irrational Numbers
🡪 I = {all infinite, nonrepeating decimals}
🡪 Obviously, irrational numbers are impossible to
write down exactly.
🡪 We use symbols to represent special values such
as π, e, and √2.
🡪 The Irrationals are not closed under + or ×.
The Real Numbers
🡪 R = {all decimal expansions}
🡪 The Real Numbers are created by adjoining the
Rationals with the Irrationals.
🡪 The Reals are closed under all operations and
satisfy the Field Axioms (see Appendix A, p. 695).
🡪 The Reals form a continuum: we use the Real
Number Line to represent this.
The Complex Numbers
🡪 The Reals fall short when solving simple
polynomial equations like x2 + 1 = 0.
🡪 The Complex Numbers patch this hole.
🡪 C = {a + bi | a,b ∈ R and i = √ (−1)}
🡪 Use the Complex Plane to represent these
numbers.
🡪 The Complex Numbers are also a field.
Subsets
🡪 If A and B are sets, A is called a subset of B,
denoted A ⊆ B, provided every element of A is
an element of B.
🡪 So, A ⊆ B means ∀x, if x ∈ A, then x ∈ B.
🡪 We also say, “A is contained in B” or
“B contains A” to show this relationship.
🡪 Equivalently, we denote A ⊄ B provided
∃x ∍ x ∈ A and x ∉ B.
Examples of Subsets
🡪 If A = {1, 2, 3} and B = {0, 1, 2, 3, 4}, then clearly A ⊆
B.

🡪 {{1}, {2}} ⊆ {{1}, {2}, {1,2}}.


🡪 Q ⊆ R and Z ⊆ Q and N ⊆ Z.
🡪 {a, b, c} is a proper subset of {a, b, c, d}.
🡪 {a, b, c} is an improper subset of {a, b, c}.
🡪 We denote interval subsets of R as
[a, b) = {x ∈ R | a ≤ x < b}. So [2, 5) ⊆ [0,5].
Set Equality
🡪 We say sets A and B are equal (A = B) if every
element of A is in B and every element of B is in A.
🡪 Thus, A = B means A ⊆ B and B ⊆ A.
🡪 For example {1, 2, 3} = {1, 2, 3}, but
A = {1, 2, 3} ≠ {1, 2, 3, 4} = B, since 4 ∈ B but 4 ∉ A.
🡪 Also, [a, b) ≠ [a, b] since b is only in [a, b].
Operations on Sets
🡪 Given sets A and B, which are subsets of a universal
set, U, we define the following:
🡪 (Union) A ∪ B = {x ∈ U | x ∈ A or x ∈ B}.
🡪 (Intersection) A ∩ B = {x ∈ U | x ∈ A and x ∈ B}.
🡪 (Difference or Relative Complement)
A − B = {x ∈ U | x ∈ A and x ∉ B}.
🡪 (Complement) Ac = {x ∈ U | x ∉ A}.
🡪 Note that Ac = U − A.
Examples of Set Operations
🡪 Let U = R, A = [1, 3] and B = (2, 4).
🡪 A ∪ B = [1, 4)
🡪 A ∩ B = (2, 3]
🡪 A − B = [1, 2]
🡪 B − A = (3, 4)
🡪 Ac = (−∞, 1) ∪ (3, ∞)
🡪 Bc = (−∞, 2] ∪ [4, ∞)
Cartesian Products
🡪 Given two sets, A and B, we define the Cartesian
Product, A × B = {(a, b) | a ∈ A and b ∈ B}.
🡪 The element (a, b) is called an ordered pair, since (a,
b) and (b, a) are distinct if a ≠ b.
🡪 If A = {1, 2, 3} and B = {8, 9}, then:
A × B = {(1, 8), (1, 9), (2, 8), (2, 9), (3, 8), (3, 9)}
B × A = {(8, 1), (8, 2), (8, 3), (9, 1), (9, 2), (9, 3)}
Generalized Cartesian Products
🡪 Given three sets, A, B, and C, we define their Cartesian
Product by
A × B × C = {(a, b, c) | a ∈ A, b ∈ B and c ∈ C}.
🡪 Although similar, we note that A × B × C and
(A × B) × C are not, technically, the same since one
contains (a, b, c) and the other ((a, b), c).
🡪 In general, we define A1×A2×A3×...×An to be
{(a1,a2,a3,…,an) | a1∈A1,a2∈A2,a3∈A3,…, an∈An}
5.1.
25

Formal Languages
🡪 Let Σ be a finite set, which we will, henceforth, call an
alphabet.
🡪 A string of characters of the alphabet Σ (or a string
over Σ ) is either: (1) an ordered n-tuple of elements of
Σ written without parentheses or commas, or (2) the
null string ε, which has no characters.
5.1.
26

Formal Languages (cont’d.)


🡪 If Σ = {1, 2, 3}, then 131221 is a string of length 6 over Σ.
🡪 131221 → (1, 3, 1, 2, 2, 1) ∈ Σ×Σ×Σ×Σ×Σ×Σ.
🡪 Clearly, the length of a string, s, over an alphabet Σ, is
the number of characters of Σ that are in s.
🡪 We denote the function L(s) to be this length.
🡪 Hence, if Σ = {0, 1}, then L(101100111) = 9.
5.1.
27

Formal Languages (cont’d.)


🡪 Any set of strings over an alphabet is called a formal
language over the alphabet.
🡪 Let Σ be an alphabet and n ∈ N :
Σn = {strings over Σ with L(s) = n};
Γn = {strings over Σ with L(s) ≤ n};
Σ* = {strings over Σ of finite length}.
5.1.2
8

Examples
Let Σ = {0, 1}:
Σ3 = {000, 001, 010, 011, 100, 101, 110, 111}
Γ3 = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100,
101, 110, 111}
Σ* = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100,
101, 110, 111, …, 000000, …, 111111, ...}.
5.3.
29

The Empty Set


🡪 The unique set containing no elements is
called the empty set, denoted ∅ or {}.
🡪 Theorem: If A is a set, then ∅ ⊆ A.
🡪 Corollary: ∅ is unique.
🡪 Why? Since ∅1 ⊆ ∅2 and ∅2 ⊆ ∅1 we
conclude ∅1 = ∅2 .
5.3.
30

Set Operations With ∅


🡪 For any set A from a universal set U:
A∩∅=∅
A∪∅=A
A ∩ Ac = ∅
A ∪ Ac = U
Uc = ∅ and ∅c = U.
5.3.
31

Partitions of a Set
🡪 Two sets are called disjoint if they have no
elements in common. That is, A and B are
disjoint provided A ∩ B = ∅.
🡪 Theorem: If A and B are any sets, then (A − B)
and B are disjoint.
🡪 A collection of sets {A1,A2,…,An} is called
mutually or pairwise disjoint if
Ai ∩ Aj = ∅ whenever i ≠ j.
5.3.
32

Partitions of a Set (cont’d.)


🡪 A collection of sets {A1,A2,…,An} is called a
partition of a set A provided:

1. {A1,A2,…,An} is mutually disjoint;


2. A1 ∪ A2 ∪ ... ∪ An = A.

🡪 {{1, 2, 3},{4, 5},{6, 7, 8}} partitions?


🡪 {{1,2,3,...},{-1,-2,-3,...},{0}} partitions?
🡪 {Q, I} partitions?
5.3.
33

Power Sets
🡪 If A is a set, the Power Set of A, denoted P (A),
is the set of all subsets of A.
🡪 Since ∅ ⊆ A, we conclude ∅ ∈ P (A), and A ⊆
A implies A ∈ P (A).
🡪 If A = {0,1}, P (A) = {∅,{0},{1},{0,1}}
🡪 Theorem: If A and B are sets with A ⊆ B, then P
(A) ⊆ P (B).
🡪 Theorem: If |A| = n, then | P (A) | = 2n.
5.3.3
4

Boolean Algebras
🡪 If A is a set, the collection {A, +, ⋅} is called a
Boolean Algebra if:
1. ∀ a,b∈A, a + b = b + a and a ⋅ b = b ⋅ a
2. ∀ a,b,c∈A, (a + b) + c = a + (b + c)
and (a ⋅ b) ⋅ c = a ⋅ (b ⋅ c)
3. ∀ a,b,c∈A, a + (b ⋅ c) = (a + b) ⋅ (a + c)
and a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
4. ∃! 0,1∈A ∍ ∀ a∈A, a + 0 = a and a ⋅ 1 = a
5. ∀ a∈A, ∃ b∈A ∍ a + b = 1 and a ⋅ b = 0
1.1.3
5

Logic of Compound Statements


🡪 A statement (or proposition) is a sentence that is true
(T) or false (F), but not both or neither.
🡪 Examples:
Today is Monday.
x is even and x > 7.
If x2 = 4, then x = 2 or x = −2.
1.1.3
6

Counterexamples
🡪 If a sentence cannot be judged to be T or F or is not
even a sentence, it cannot be a statement.
🡪 Examples:
Open the door! (imperative)
Did you open the door? (interrogative)
If x2 = 4. (fragment)
1.1.3
7

Compound Statements
🡪 Denote statements using the symbols p, q, r, ...
🡪 Denote the operations ∧, ∨, ~, → (to be defined
shortly), where:
p ∧ q - conjunction of p and q (p and q);
p ∨ q - disjunction of p and q (p or q);
~ p - negation of p (not p);
p → q - implication of p and q (p implies q);
1.1.3
8

Compound Statements (cont’d.)


🡪 A Compound statement (or statement form) is a
statement which includes at least one operation and
one other “atomic” statement.
🡪 For example, “x = 7 and y = 2” is a compound
statement based on the “atomic” statements
p = “x = 7” and q = “y = 2”.
🡪 In this instance, we can symbolize the compound
statement as r = p ∧ q.
1.1.3
9

Compound Statements (cont’d.)


🡪 The Truth Table of a compound statement is the
collection of all the output truth values corresponding
to all possible combinations of input truth values of the
atomic statements.
🡪 Since each atomic statement can take on 1 of 2
values, 2 inputs have 4 combinations, 3 inputs have 8,
4 inputs have 16, 5 inputs have 32, etc.
1.1.4
0

Logical Operations
🡪 Negation:p ~p
T F
F T
🡪 Conjunction: • Disjunction:
p q (p ∧ q) p q (p ∨ q)
T T T T T T
T F F T F T
F T F F T T
F F F F F F
1.1.4

Example: (p ∨ q) ∧ ~r 1

🡪 Proceed from left to right:


p q r (p ∨ q) ~r (p ∨ q) ∧ ~r
T T T T F F
T T F T T T
T F T T F F
T F F T T T
F T T T F F
F T F T T T
F F T F F F
F F F F T F
1.1.4
2
Logical Equivalence
🡪 Two compound statements are logically equivalent if
they have the same truth table. We denote this as p ≡
q.
🡪 p ~p ~(~p)
T F T
F T F hence p ≡ ~(~p).
🡪 ~(p ∧ q) ≡ ~p ∧ ~q ?
No, since ~(T ∧ F) ≡ T, but (~T ∧ ~F) ≡ F.
1.1.4
3
Tautology & Contradiction
🡪 A statement whose truth table is all “T” is called a
tautology, denoted as p ≡ t.
🡪 A statement whose truth table is all “F” is called a
contradiction, denoted as p ≡ c.
🡪 Clearly, ~t ≡ c and ~c ≡ t.
🡪 Are all logical statements either tautology or
contradiction?
1.1.4
4
Algebra of Symbolic Logic
🡪 Commutative Laws:
p∧q≡q∧p
p∨q≡q∨p
🡪 Associative Laws:
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
🡪 Distributive Laws:
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
1.1.4
5
Algebra of Symbolic Logic
🡪 Identity Laws:
p∧t≡p
p∨c≡p
🡪 Negation Laws:
p ∧ ~p ≡ c
p ∨ ~p ≡ t
🡪 Double Negative Laws: ~(~p) ≡ p
🡪 Negations of t and c: ~t ≡ c ~c ≡ t
1.1.4
6
Algebra of Symbolic Logic
🡪 Idempotent Laws: p ∧ p ≡ pp ∨ p ≡ p
🡪 DeMorgan’s Laws:
~(p ∧ q) ≡ ~p ∨ ~q
~(p ∨ q) ≡ ~p ∧ ~q
🡪 Universal Bound Laws: p ∧ c ≡ c p ∨ t ≡ t
🡪 Absorption Laws:
p ∧ (p ∨ q) ≡ p
p ∨ (p ∧ q) ≡ p
1.2.4
7
Conditional Statements
🡪 If p and q are statement variables, the conditional or
implication of q by p is “If p then q” or
“p implies q” and is denoted by p → q.
🡪 The truth table of the implication operator is:
p q p→q
T T T
T F F
F T T
F F T
🡪 Example: If you mow my lawn, I’ll pay $20.
1.2.4
8
Hypotheses & Conclusions
🡪 In the form “If p then q” the statement p is called the
hypothesis and the statement q is the conclusion.
🡪 Conditionals form the basis of “deductive” reasoning.
(Aristotilean Logic)
🡪 In looking at the truth table, we consider the cases
where the hypothesis is false to yield vacuous results.
The interesting cases are when the hypothesis is true.
1.2.4
9
Logical Equivalences
🡪 In the framework of symbolic logic, the implication
operator would seem to be a new and distinct
process.
🡪 However, this is not the case!
🡪 Theorem: p → q ≡ ~p ∨ q.
🡪 Thus, we can always rewrite an implication as a
disjunction.
🡪 Corollary: ~(p → q) ≡ p ∧ ~q.
1.2.5
0
Negation of a Conditional
🡪 From the previous corollary, the negation of
p → q is p ∧ ~q.
🡪 For example, the negation of
If today is Sunday, then I wash my car.
is:
Today is Sunday and I do not wash my car.
1.2.5
1
Converse of a Conditional
🡪 Given the statement p → q, we define its converse to
be the statement q → p.
🡪 For example, the converse of
If today is Sunday, then I wash my car.
is:
If I wash my car, then today is Sunday.
1.2.5
2
Contrapositive of a Conditional
🡪 Given the statement p → q, we define its
contrapositive to be the statement ~q → ~p.
🡪 For example, the contrapositive of
If today is Sunday, then I wash my car.
is:
If I do not wash my car, then today is not Sunday.
1.2.5
3
Inverse of a Conditional
🡪 Given the statement p → q, we define its inverse to be
the statement ~p → ~q.
🡪 For example, the inverse of
If today is Sunday, then I wash my car.
is:
If today is not Sunday, then I do not wash my car.
1.2.5
4
Equivalent Forms
🡪 Theorem: Given the statement p → q, we have that p
→ q ≡ ~q → ~p.
🡪 Corollary: Given the statement p → q, we have that q
→ p ≡ ~p → ~q.
🡪 Therefore from the above, we see that a conditional
and its contrapositive are logically equivalent.
🡪 Moreover, the statement’s converse and inverse forms
are logically equivalent to each other.
1.2.5
5
Biconditional Statements
🡪 Definition: Given the statement variables p and q, the
biconditional of p and q is read, “p if and only if q,”
denoted p ↔ q and means that both
p → q and q → p .
🡪 By direct calculation: p q p ↔ q
T T T
T F F
F T F
F F T
1.2.5
6
Using the Biconditional
🡪 Looking closely at the truth table, we see that
p ↔ q is T whenever p and q have the same truth
value.
🡪 Theorem: p ↔ q is a tautology implies p ≡ q and
conversely, p ≡ q implies p ↔ q is a tautology.
🡪 This gives us a systematic way to calculate logical
equivalence, rather then just scan the matches of
truth values by eye.
1.3.
57
Valid and Invalid Arguments
🡪 An argument (or argument form) is a sequence of
statements.
🡪 All statements but the final one are called premises,
assumptions, or hypotheses.
🡪 The final statement is called the conclusion.
🡪 An argument form is valid provided its conclusion is
always true whenever all of its premises are true.
1.3.
58

Valid and Invalid Arguments


🡪 An argument (or argument form) is a sequence of
statements.
🡪 All statements but the final one are called premises,
assumptions, or hypotheses.
🡪 The final statement is called the conclusion.
🡪 An argument form is valid provided its conclusion is
always true whenever all of its premises are true.
🡪 The truth of the conclusion follows inescapably from
the truth of the hypotheses.
5.2.
59

Some Subset Relations


🡪 For all sets A, B, and C:
1. A ∩ B ⊆ A and A ∩ B ⊆ B
2. A ⊆ A ∪ B and B ⊆ A ∪ B
3. If A ⊆ B and B ⊆ C, then A ⊆ C.
5.2.
60

Procedural Versions
of the Set Operations
🡪 x ∈ A ∪ B means x ∈ A or x ∈ B.
🡪 x ∈ A ∩ B means x ∈ A and x ∈ B.
🡪 x ∈ A − B means x ∈ A and x ∉ B.
🡪 x ∈ Ac means x ∉ A.
🡪 (x, y) ∈ A × B means x ∈ A and y ∈ B.
5.2.
61

Example: Show A ∩ B ⊆ A
🡪 Let x ∈ A ∩ B. Show x ∈ A.
🡪 x ∈ A ∩ B means x ∈ A and x ∈ B.
🡪 In particular, this means x ∈ A.
🡪 Hence, given x ∈ A ∩ B, we deduce that x
∈ A.
🡪 Therefore A ∩ B ⊆ A.
5.2.
62

Basic Method to Show Set


Equality
🡪 Let sets A and B be given. Show A = B.
🡪 First, show A ⊆ B.
🡪 Second, show B ⊆ A.
🡪 If the “⊆” holds in both directions, then we can
conclude that A = B.
5.2.
63

Example 1:
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)

First, show A ∪ (B ∩ C) ⊆ (A ∪ B) ∩ (A ∪ C).

Then, show (A ∪ B) ∩ (A ∪ C) ⊆ A ∪ (B ∩ C).


5.2.
64

Example 2: If A ⊆ B, then
A ∪ B = B and A ∩ B = A

First, show A ∩ B ⊆ A.

Then, show A ⊆ A ∩ B.
2.1.
65

Predicates
🡪 To study these types of logical arguments, we turn to
predicate calculus.
🡪 A predicate is a sentence that contains a finite
number of variables and becomes a statement when
specific values are substituted for the variables.
🡪 The domain of a predicate variable is the set of all
values that may be substituted in place of the
variable.
2.1.
66

Predicate Notation
🡪 If P(x) is a predicate and x has a domain D, the truth
set of P(x) is the set of all elements of D that make P(x)
true when substituted for x.
🡪 The truth set is denoted {x ∈ D | P(x)}.
🡪 If P(x) and Q(x) are predicates and the common
domain of x is D, then the notation P(x) ⇒ Q(x)
denotes that the truth set of P(x) is a subset of the
truth set of Q(x).
🡪 If P(x) and Q(x) have the same truth set, we denote
this as P(x) ⇔ Q(x).
2.1.
67

The Universal Quantifier


🡪 We often find predicates involved when we are
making claims about properties that some or all the
elements of a set obey. This leads us to look at
statements using one of two quantifiers.
🡪 The Universal Quantifier: If P(x) is a predicate over a
domain D, we say a universal statement is one of the
form “∀x ∈ D, P(x).”
🡪 This universal statement is true provided P(x) is true for
every x in D.
🡪 Any x ∈ D with P(x) false, is a counterexample.
2.1.
68

Examples
🡪 Example 1: Let D = {1,2,3,4,5} and let P(x) be the
predicate x2 ≥ x. Using the Method of Exhaustion, we
find that 12 ≥ 1, 22 ≥ 2, 32 ≥ 3,
42 ≥ 4, and 52 ≥ 5 are all true, hence the universal
statement ∀x ∈ {1,2,3,4,5}, x2 ≥ x is true.
🡪 Example 2: If we change this universal statement to:
∀x ∈ R, x2 ≥ x, it is no longer true since x = 1/2 is a
counterexample.
2.1.
69

The Existential Quantifier


🡪 The Existential Quantifier: If P(x) is a predicate over a
domain D, we say an existential statement is one of
the form “∃x ∈ D ∍ P(x).”
🡪 This existential statement is true provided P(x) is true
for at least one x in D, and is false if P(x) is false for
every x in D.
🡪 From this, we see that the negation of an existential
statement is a universal statement, and, likewise, the
negation of a universal statement is an existential
one.
2.1.
70

More Examples
🡪 Consider: ∃x ∈ D ∍ x < 0.
2

🡪 Example 1: If D = C (the Complex numbers), then x = i


yields i2 = (−1) < 0, hence the existential statement is
true.
🡪 Example 2: If D = R, then by the properties of R, we
know that x2 ≥ 0 for all x in R, hence the existential
statement is false.
🡪 This second example show us the negation of
∃ x ∈ R ∍ x2 < 0 is the universal statement
∀x ∈ R, x2 ≥ 0.
2.1.
71

Negations of Quantifiers
🡪 As seen in the previous example, the negation of an
existential statement is a universal statement.
🡪 Formally, we denote:
~[∃x ∈ D ∍ P(x)] ≡ ∀x ∈ D, ~P(x).
🡪 By the same process, we have that:
~[∀x ∈ D, P(x)] ≡ ∃x ∈ D ∍ ~P(x).
🡪 Intuitively, the first says the opposite of at least one
thing satisfying a property is that none do, and the
opposite of all things satisfying the property is that at
least one does not.
2.1.
72

Examples of Negations
🡪 The negation of:
Some people are sad.
is
All people are not sad.
🡪 The negation of:
All integers are rational.
is
At least one integer is irrational.
🡪 Which of each pair is true?
2.1.
73
Universal Conditional
🡪 The statement:
∀x, if P(x), then Q(x)
is called the universal conditional.
🡪 Many mathematical statements are universal
conditionals.
🡪 Example: ∀x ∈ R, if x > 2 then x2 > 4 (formal)
is equivalent to: (informally)
🡪 Every real number greater than 2 has a square greater
than 4.
🡪 The square of any real number greater than 2 is greater
than 4.
2.1.74

Negation of Quantified Conditionals


🡪 Since we see the properties of symbolic logic carry
over when dealing with quantified logic, we deduce
that:
~[∀x ∈ D, if P(x), then Q(x)]
is ∃x ∈ D ∍ P(x) and ~Q(x).
🡪 Similarly, ~[∃x ∈ D ∍ if P(x), then Q(x)]
is ∀x ∈ d, P(x) and ~Q(x).
🡪 Negate: 1. Every CS student studies CMSC203.
2. Some CS students study CMSC203.
2.2.
75

Negation of Universal Existentials


🡪 What is the negation of the statement:
∀ people x, ∃ a person y such that x loves y?
🡪 Recall this is “Everybody loves somebody,” so its
negation would be the case of “Somebody who
does not love anybody.”
🡪 In formal terms:
∃ a person x ∍ ∀ people y, x does not love y.
🡪 Thus:
~ [∀ x, ∃ y ∍ P(x,y) ] ≡ ∃ x ∍ ∀ y, ~P(x,y)
2.2.
76

Negation of Existential Universals


🡪 What is the negation of the statement:
∃ a person x such that ∀ people y, x loves y?
🡪 Recall this is “Somebody loves everybody,” so its
negation would be the case of “Everybody has at
least one person they do not love.”
🡪 In formal terms:
∀ people x, ∃ person y ∍ x does not love y.
🡪 Thus:
~ [∃ x ∍ ∀ y, P(x,y) ] ≡ ∀ x, ∃ y ∍ ~P(x,y)
2.2.
Equivalent Forms of 77

Universal Conditionals
🡪 Given the statement:
∀ x∈D, if P(x), then Q(x)
analogous to our definitions from propositional
calculus, we can construct the following.
🡪 Contrapositive: ∀ x∈D, if ~Q(x), then ~P(x).
🡪 Converse: ∀ x∈D, if Q(x), then P(x).
🡪 Inverse: ∀ x∈D, if ~P(x), then ~Q(x).
🡪 Negation: ∃ x∈D ∍ P(x), and ~Q(x).
3.1.
78

Even and Odd Integers


🡪 Definition: An integer n is even provided there exists
an integer k such that n = 2k.
🡪 Definition: An integer n is odd provided there exists an
integer k such that n = 2k + 1.
🡪 38 is even since 38 = 2(19) and 19 is an integer.
🡪 417 is odd since 417 = 2(208) + 1 and 208 ∈ Z.
🡪 417 is not even since 417 = 2(208.5) but
208.5 ∉ Z.
3.1.
79

Prime and Composite Integers


🡪 Definition: An integer n is prime if, and only if, n > 1,
and for all positive integers r and s, if
n = r⋅s, then r = 1 or s = 1.
🡪 Definition: An integer n is composite if, and only if, n >
1, and for all positive integers
r and s, if n = r⋅s, then r ≠ 1 and s ≠ 1.
🡪 Every natural number > 1 is either prime or composite.
🡪 2 is the only even prime number.
3.1.
80

Proving Existential Statements


🡪 To show: There exists an a such that P(a).
🡪 Demonstrate an Example:
Prove there is an even integer that can be written in
two ways as the sum of two primes.
Proof: 10 = 3 + 7 = 5 + 5.
🡪 Construct an Example:
Prove if r,s ∈ Z, then 4r + 6s is even.
Proof: Let r,s ∈ Z. Thus 2r + 3s = k ∈ Z, and
4r + 6s = 2k, therefore (4r + 6s) is even.
3.1.
81

Proving Universal Statements


🡪 Most theorems are of the form:
∀ x∈D, if P(x), then Q(x).
🡪 If D is a finite set, we can just exhaust over each
element n to verify that Q(n) holds.
🡪 Example: Prove all n ∈ {4, 6, 8, 10, 12} can be written
as the sum of two primes.
Proof: 4 = 2 + 2 6=3+3
8=3+5 10 = 3 + 7
12 = 5 + 7.
3.1.
82

Method of Direct Proof


🡪 Express the statement to be proved in the form:
∀ x∈D, if P(x), then Q(x)
if possible. (Often, this is done mentally)
🡪 Start the proof by supposing that n is a particular but
arbitrary element of D for which P(n) is true. (Suppose
n∈D and P(n))
🡪 Show that the conclusion Q(n) follows from P(n) by
using definitions, axioms, previously established results,
and the rules for logical inference.
3.1.
83
Example:
Prove: If the sum of two integers is even, then
so is their difference.
Proof: Let m and n be any integers with (m + n) even.
This means there is an integer k such that (m + n) = 2k.
Now, (m − n) = (m + n) − 2n = 2k − 2n
= 2 (k − n) = 2p,
where k − n = p is an integer. Thus (m − n) is even.
Also, (n − m) = −(m − n) = 2(−p),
so (n − m) is also even. Therefore, the difference of m
and n is even. QED
3.1.
84

Directions for Writing Proofs


🡪 Write the statement to be proved.
🡪 Clearly mark the beginning of your proof with the
word Proof.
🡪 Make your proof self-contained:
🡪 Identify each variable used in the body of the proof;
🡪 Introduce only necessary variables and notation;
🡪 Use Lemmas to show significant but related ideas.
🡪 Write proofs in complete (English) sentences.
3.1.85

Common Mistakes
🡪 Arguing from examples;
🡪 Using the same letter to mean different things;
🡪 Jumping to a conclusion;
🡪 Begging the question (i.e. assuming true that which
you want to prove);
🡪 Using if when you mean since, hence, thus, therefore,
hencely, thusly, hereforthwith, etc.
3.6.
Proof by Contradiction 86

🡪 Instead of the Universal Modus Ponens argument form:


∀x, [P(x) → Q(x) AND P(x)] ⇒ Q(x), a Proof by
Contradiction (reductio ad absurdum) follows the
Universal Modus Tollens form: ∀x, [P(x) → Q(x) AND
~Q(x)] ⇒ ~P(x).
🡪 We obtain a contradiction when the conclusion of this
form is combined with our standard assumption in a
direct proof the P(x) holds.
🡪 This differs marginally from the Method of
Contraposition which proves directly the validity of the
comtrapositive statement.
3.6.
87

Method of Proof By Contradiction


🡪 Suppose the statement to be proved is FALSE;
🡪 Show this supposition leads logically to a
contradiction (either to the original hypotheses or to
some other statement of fact);
🡪 Conclude that the original statement to be proved is
TRUE.
3.6.
88

Example: No Greatest Integer


Theorem: There is no greatest integer.
Proof: (Contradiction) Suppose there is a greatest
integer N. Thus for every integer k, k ≤ N.
Now, since N is an integer, by closure, (N+1) is an
integer. Thus: N+1≤N,
hence 1 ≤ 0.*
Therefore, there is no greatest integer. QED
3.6.
89

Sums of Rationals and Irrationals


Theorem: The sum of a rational and an irrational is
irrational.
Proof: (Contradiction) Let r be rational, s be irrational,
and assume (r + s) is rational. Thus there exist a,b,c,d
∈ Z, with r = a/b,
(r + s) = c/d and b,d ≠ 0.
Now, s = (r + s) − r = c/d − a/b
= (bc − ad)/bd.
Since a,b,c,d ∈ Z and b,d ≠ 0, we have s ∈ Q.*
Therefore (r + s) is irrational. QED
3.6.
90

Method of Proof by Contraposition


🡪 Express the statement to be proved in the form
∀x, if P(x) then Q(x).
🡪 Rewrite this as its contrapositive
∀x, if ~Q(x) then ~P(x).
🡪 Prove the contrapositive form directly:
🡪 Suppose x is such that Q(x) is FALSE.
🡪 Show that P(x) is FALSE.
3.6.91

Example of Contraposition
Theorem: Given any integer n, if n2 is even, then
n is even.
(Contrapositive: If n is odd, then n2 is odd.)
Proof: (Contraposition) Let n be an integer and assume
that n is odd. Thus, there is an integer k such that n =
2k + 1. Show that n2 is odd.
Now, n2 = (2k + 1)2 = 4k2 + 4k + 1
= 2(2k2 + 2k) + 1.
Since k is an integer, (2k2 + 2k) is an integer.
Therefore n2 is odd. QED
4.2.92

What Is Induction
🡪 One of the more recently developed proof
techniques;
🡪 Used to verify conjectures about processes that
occur repeatedly, according to definite patterns;
🡪 Used to prove statements indexed on the Natural
Numbers (i.e. For all integers n ≥ 0, ...)
4.2.93

Climbing Infinite Staircases


🡪 Consider the problem of trying to climb an infinitely
tall staircase.
🡪 How can I know that this staircase is climbable?
🡪 First, show the staircase exists. (Basis)
🡪 Second, show standing at any arbitrary step implies I
can climb to the next step. (Induction)
🡪 The basis shows there is an initial step.
🡪 The induction validates a rule of motion from one
step to another.
4.2.94

In Pictures
Induction

Induction

Induction

Induction

Basis
4.2.95

Principle of Mathematical Induction


🡪 Let P(n) be a predicate that is defined for integers n,
and let a be a fixed integer.
🡪 Suppose the following two statements are true:
1. P(a) is true;
2. For all integers k ≥ a, if P(k) is true, then P(k + 1) is true.
🡪 Then, for all integers n ≥ a, P(n) is true.
4.2.96

Outline of an Inductive Proof


🡪 Basis step says to show P(initial value) is true.
🡪 Inductive step says:
🡪 Assume P(k) is true for an arbitrary k.
🡪 Use this to show P(k + 1) is true.
🡪 This assumption of P(k) is called the inductive
hypothesis.
4.2.97

Tuppence and Nickels


🡪 Show that any monetary value of 4 cents or more
can be composed of tuppence (a two-cent coin)
and nickels.
🡪 BASIS: 4 cents = tuppence + tuppence.
🡪 INDUCTION: Assume k-cents can be made up from
tuppence and nickels (k = 2t + 5n). Show (k+1) can
too.
4.2.98

Tuppence and Nickels (cont’d.)


🡪 Case 1: (At least one of each coin: k = 2t + 5n)
k + 1 = 2t + 5n + 1 = 2t + 5n + 6 − 5
= (2t + 6) + (5n − 5) = 2(t + 3) + 5(n − 1).

🡪 Case 2: (No tuppence: k = 5n)


k + 1 = 5n + 1 = 5n + 6 − 5 = 2(3) + 5(n − 1).

🡪 Case 3: (No nickels and t > 2: k = 2t)


k + 1 = 2t + 1 = 2t + 5 − 4 = 2(t − 2) + 5(1).
4.2.99

Sum of the First n Integers


🡪 Carl Friederich Gauss is bored in school.
🡪 Teach instructs him to add together the numbers from 1
to 100.
🡪 Zip! Carl is done. Sum is 5050. How?
🡪 1 + 2 + 3 + ... + 100
= (1 + 100) + (2 + 99) + (3 + 98) +...+ (50 + 51)
= 101 + 101 + 101 +...+ 101
= 50(101)
= 5050.
4.2.10
0
Sum of the First n Integers (cont’d.)
Prove: n
Σ k = n(n + 1) / 2 .
k =1
Proof: (Induction)
Basis: Show: 1
Σ k = 1(2) / 2 .
k =1
1
Σ k = 1 and 1(2)/2 = 2/2 = 1, so they are equal.
k =1
10.1.10
1
Functions
🡪 A function from A to B is a relation that satisfies the
properties:
1. For each x in A, there is a y in B such that (x,y)
is in the function;
2. If (x,y) and (x,z) are in the function, then y = z.
10.1.10
2
Examples of Functions (Not)
🡪 To understand functions, it is easier to study what are
not:
Violates Property 1
1
2 a
3 b
4
Violates Property 2

1
2 a
3 b
4
10.1.10
3
Inverse Relations
🡪 Definition: If R is a relation from set A to set B, then the
inverse relation of R, denoted R−1, is
R−1 = {(y,x) | (x,y) ∈ R}.
🡪 For example, if R = {(1,3), (2,1), (4,5), (6,6)}, then R −1 =
{(3,1), (1,2), (5,4), (6,6)}.
🡪 Could R = R−1?
🡪 Sure - let R = {(1,2), (2,1), (2,3), (3,2), (4,4)}.
10.1.10

Directed Graph of a Relation 4

🡪 When R is a relation on a set A, we draw it using a


directed graph. For example, if
R = {(1,1), (2,4), (3,2), (4,1), (4,3)},
then its directed graph is:

2
1 3
4
10.2.10
Reflexivity, 5

Symmetry, and Transitivity


🡪 Definition: Let R be a binary relation on A.
🡪 R is reflexive if for all x ∈ A, (x,x) ∈ R.
(Equivalently, for all x e A, x R x.)
🡪 R is symmetric if for all x,y ∈ A, (x,y) ∈ R implies (y,x) ∈
R. (Equivalently, for all x,y ∈ A, x R y implies that y R x.)
🡪 R is transitive if for all x,y,z ∈ A, (x,y) ∈ R and (y,z) ∈ R
implies (x,z) ∈ R. (Equivalently, for all x,y,z ∈ A, x R y
and y R z implies x R z.)
Examples
🡪 Reflexive: The relation R on {1,2,3} given by
R = {(1,1), (2,2), (2,3), (3,3)} is reflexive. (All loops
are present.)
🡪 Symmetric: The relation R on {1,2,3} given by
R = {(1,1), (1,2), (2,1), (1,3), (3,1)} is symmetric.
(All paths are 2-way.)
🡪 Transitive: The relation R on {1,2,3} given by
R = {(1,1), (1,2), (2,1), (2,2), (2,3), (1,3)} is transitive.
(If I can get from one point to another in 2 steps,
then I can get there in 1 step.)
Violations of the Properties
🡪 Why is R = {(1,1), (2,2), (3,3)} not reflexive on
{1,2,3,4}?
Because (4,4) is missing.
🡪 Why is R = {(1,2), (2,1), (3,1)} not symmetric?
Because (1,3) is missing.
🡪 Why is R = {(1,2), (2,3), (1,3), (2,1)} not transitive?
Because (1,1) and (2,2) are missing.
🡪 Is {(1,1), (2,2), (3,3)} symmetric? transitive?
Yes! Yes!
10.2.10
The Transitive Closure 8

🡪 Definition: Let R be a binary relation on a set A. The


transitive closure of R is the binary relation Rt on A
satisfying the following three properties:
1. Rt is transitive;
2. R is a subset of Rt;
3. If S is any other transitive relation that
contains R, then S contains Rt.
🡪 In other words, the transitive closure of R is the smallest
transitive relation containing R.
10.2.10
9
Example of the Transitive Closure
🡪 Given the relation R on {1,2,3,4},
1 2

its transitive closure4 is: 3

1 2

4 3
10.2.11
Properties of Equality 0

🡪 Consider the Equality (=) relation on R:


Equality is reflexive since for each x ∈ R, x = x.
Equality is symmetric since for each x,y ∈ R, if x = y,
then y = x.
Equality is transitive since for each x,y,z ∈ R, if x = y and
y = z, then x = z.
🡪 As a graph, the relation contains only loops, so
symmetry and transitivity are vacuously satisfied!
10.2.11
1
Properties of Congruence Mod p
🡪 Let p be an integer greater than 1, and consider the
relation on Z given by:
R = {(x,y) | x,y ∈ Z and x ≡ y mod p}.
🡪 When we say x ≡ y mod p, this means (x − y) = kp for
some integer k.
🡪 Now, R is reflexive since (x − x) = 0 = 0p, for all integers
x.
🡪 Moreover, R is symmetric, since if x ≡ y mod p, then (x −
y) = kp, thus (y − x) = (−k)p, implying that y ≡ x mod p.
10.2.11

Congruence Mod p (cont’d.) 2

🡪 Finally, R is transitive. Why?


🡪 Let x ≡ y mod p and y ≡ z mod p. This means there are
integers k and j such that (x − y) = kp and (y − z) = jp.
Hence, (x − z) = (x − y) + (y − z)
= kp + jp = (k + j)p. Therefore, x ≡ z mod p.
Properties of Inequality
🡪 Consider the Inequality (< or >) relation on R:
Inequality is not reflexive since for no x ∈ R is it true that
x < x.
Inequality is not symmetric since for each
x,y ∈ R, if x < y is true, then y < x is false.
Inequality is transitive since for each x,y,z ∈ R, if x < y
and y < z, then x < z.
🡪 Inequality is so pathelogically unsymmetric, that we
define a special property to describe it.
10.2.11
4
The Anti-symmetry Property
🡪 Definition: A relation R on a set A is called
anti-symmetric if (x,y) ∈ R and (y,x) ∈ R implies x
= y.
🡪 This is equivalent to requiring that if x ≠ y and
(x,y) ∈ R, then (y,x) ∉ R. (All streets are one-way.)
🡪 Example: R = {(1,1), (1,2), (3,2), (3,3)} is
anti-symmetric.
🡪 Is every relation symmetric or anti-symmetric?
🡪 No! Consider R = {(1,2), (2,1), (1,3)}.
10.3.11
5
Equivalence Relations
🡪 Definition: Let R be a binary relation on A. R is an
equivalence relation on A if R is reflexive,
symmetric, and transitive.
🡪 From the last section, we demonstrated that
Equality on the Real Numbers and Congruence
Modulo p on the Integers were reflexive,
symmetric, and transitive, so we can describe
them as equivalence relations.
Examples
🡪 What is the “smallest” equivalence relation on a
set A?
R = {(a,a) | a ∈ A}, so that n(R) = n(A).

🡪 What is the “largest” equivalence relation on a


set A?
R = A × A, so that n(R) = [n(A)]2.
Equivalence Classes 10.3.11
7
🡪 Definition: If R is an equivalence relation on a set A,
and a ∈ A, then the equivalence class of a is defined
to be:
[a] = {b ∈ A | (a,b) ∈ R}.
🡪 In other words, [a] is the set of all elements which relate
to a by R.
🡪 For example: If R is congruence mod 5, then
[3] = {..., −12, −7, −2, 3, 8, 13, 18, ...}.
🡪 Another example: If R is equality on Q, then
[2/3] = {2/3, 4/6, 6/9, 8/12, 10/15, ...}.
🡪 Observation: If b ∈ [a], then [b] = [a].
10.3.11
A String Example 8

🡪 Let Σ = {0,1} and denote L(s) = length of s, for any string


s ∈ Σ*. Consider the relation:
R = {(s,t) | s,t ∈ Σ* and L(s) = L(t)}
🡪 R is an equivalence relation. Why?
🡪 REF: For all s ∈ Σ*, L(s) = L(s);
SYM: If L(s) = L(t), then L(t) = L(s);
TRAN: If L(s) = L(t) and L(t) = L(u), L(s) = L(u).
🡪 What are the equivalence classes of R?
🡪 [θ], [0], [00], [000], [0000], ...
in other words, Σ0, Σ1, Σ2, Σ3, Σ4, ...
10.3.11
Relations and Partitions 9
🡪 Recall that a partition of a set is a collection of
mutually disjoint subsets whose union is the original set.
🡪 Equivalence relations and partitions are tied together
by the following:
🡪 Definition: Given a partition of a set A, the binary
relation induced by the partition is
R = {(x,y) | x and y are in the same partition set}.
🡪 Theorem: If A is a set with a partition and R is the
relation induced by the partition, then R is an
equivalence relation.
10.3.12
Making Equivalence Relations 0
🡪 This example shows how to apply this theorem to create
the induced equivalence relation.
🡪 The collection {{1,2,3}, {4,5}, {6}} is a partition of
{1,2,3,4,5,6}. To find the induced equivalence relation,
observe:
🡪 {1,2,3} × {1,2,3} = {(1,1), (1,2), (1,3), (2,1), (2,2),
(2,3), (3,1), (3,2), (3,3)}
{4,5} × {4,5} = {(4,4), (4,5), (5,4), (5,5)}
{6} × {6} = {(6,6)}
🡪 R = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3),
(4,4), (4,5), (5,4), (5,5), (6,6)}
Automata Fundamentals

• Definitions and properties of mathematical models of


computation.
• These models playa role in several applied areas of
computer science.
• Finite automata, is used in text processing, compilers, and
hardware design.
• Another model, called the context-free grammar, is used
in programming languages and artificial intelligence.
BASIC MATHEMATICAL NOTATION
AND TECHNIQUES
Symbol: Anything by(lower case and upper case letters,
digits, operators etc).
• Example: a, b, c, 0, 1, 2, . . .
Alphabet : It is a finite, non – empty set of symbols .
It is denoted by ∑.
• Examples:
• ∑ = {0,1} : Binary alphabet
• ∑ = {A~Z, 0~9} : Alphanumeric alphabet
• ∑ = {a,b,c, ….,z} : Alphabet of small letters
BASIC MATHEMATICAL NOTATION
AND TECHNIQUES
• String
• A string or word is a finite sequence/group of
symbols chosen from the alphabet (∑)

• Example:

i. 01001 , 101, 11001 over Σ ={0,1}

ii. aaabbbbccc, abc, aabcc over Σ ={a,b,c}


Operations on Strings
• Length of a string:
“length of the string |w|” 🡪 the number of symbols composing
the string.
Count of symbols in that string.
• Examples: i. if w = abcd then |w| = 4
• ii. if x = 0101101011 then | x | = 10
• Empty or NULL Strings 𝝐 :
▪ The String consisting of zero symbols.
▪ Length of empty string is | 𝜖 | = 0.
Operations on Strings
• Concatenation of String
xy 🡪 appending the symbols of y to the rights end of symbols of x. i.e.,
❑ x = a 1, a 2, . . . , a n
❑ y = b1, b2, . . ., bm
then xy = a1, a2, . . . , an b1, b2, . . ., bm
• Examples:
i. u = 010 v = 1
uv = 0101 vu = 1010
ii. x = PAS y = CAL xy=PASCAL
iii.Empty string is the identity element for concatenation operator.
w𝝐=𝝐𝒘=w
Operations on Strings
• Reverse a string
It is obtained by writing the symbols in reverse order. Let
w be a string. Then its reverse is wR.
i.e., w = a 1, a 2, . . . , a n
wR = an, , . . . ,a2, a1.
Example: Let u = 0101110
uR = 0111010
Operations on Strings
• Powers of an alphabet (Number of elements in a set):
Let ∑ be an alphabet.
∑* denotes the set of all string over the alphabet ∑.
∑m denotes the set of all string over the alphabet ∑ of length m.
Examples: If ∑ = {0, 1} then
∑0 = 1={ 𝜖 } empty string
∑1 =2= { 0,1} set of all strings of length one over ∑= { 0,1 }
∑2 =4= {00,01,10,11} set of all strings of length two over ∑= { 0,1 }
∑3 =8= {000,001,010,011,100,101,110,111} set of all strings of
length three over ∑= { 0,1 }
The cardinality of ∑n =2n is if over ∑= { 0,1 }
Operations on Strings
• Kleene Closure:
Let ∑ be an alphabet. Then “Kleene Closure ∑*” denotes the
set of all strings ( including 𝜖 , empty string) over the alphabet ∑.
∑* = ∑0 U ∑1 U ∑2 U , . . .
Examples:
i. If ∑ = {0,1} then
🡺 ∑0 = { 𝜖 } ∑1 = { 0,1 }
🡺∑2 = { 00, 01, 10, 11}
🡺∑3= { 000, 001, 010, 011,100,101,110,111}. . .
then ∑*= { 𝜖 , 0, 1, 00, 01, 10, . . . }
ii. If ∑ = {0 } then ∑*= { 𝜖 , 0, 00, 000, . . . }
Operations on Strings
• Positive Closure:
Let ∑ be an alphabet. Then “Positive Closure
∑+” denotes the set of all strings ( excluding 𝜖)over
the alphabet ∑.
∑+ = ∑1 U ∑2 U ∑3 U , . . .
Examples: i. If ∑ = {0,1} then
• ∑1 = { 0,1 }
• ∑2 = { 00, 01, 10, 11}
• ∑3= { 000, 001, 010, 011,100,101,110,111}
. . . then ∑+= { 0, 1, 00, 01, 10, . . . }
Operations onStrings
• Substring:
A string v appears within another string w (w = uv) is called
“substring of w”. If w = uv, then substrings u & v are said to be
prefix and suffix of w respectively.
• Examples:
i. w = abbab be a string over an alphabet
∑ = {a, b} then a, ab, abb, ba, bab, . . . are all
substrings of w.
ii. w = 674
Prefixes = { 𝜖, 6, 67, 674}
Suffixes = { 𝜖, 4, 74, 674}
Operations on Strings
• Palindrome:
A palindrome is a string, which is same whether written
forward (or) backward.
• Examples:
i. mam, noon, nun, Malayalam, 11211.
ii. If the length of a palindrome is even , then it can be
obtained by concatenation of a string and its reverse.
• Example:
If u = 01 uR = 10 then even palindrome = 0110
Language
• Language is a set of strings chosen from the alphabet ∑
• Language L could be finite or infinite
• Example: Suppose ∑ = { a,b }
L1 = Set of all strings of length 2
= { aa, ab, ba, bb } [Finite] L2
= Set of all strings of length 3
= { aaa, aab, aba, abb, baa, bab, bba, bbb }[Finite] L3 =
Set of all strings where each string starts with “a”
= { a, aa, ab, aaa, aab, aba, abb,…….. } [Infinite]
Implication
• Where we use those theorem, idea form
computation?
• C Programming language.

void main ()
{
int a,b;
etc; etc;
}
Valid / Invalid Computation:

• Check the given string is present in the language


or not ?
• Given,
L is a Finite language; ∑ = { a, b }
L1 = { aa, ab, ba, bb } String, S = aaa
• Here, S = aaa is not present in the language and
we can calculate this and thus is invalid operation
for computation.
Valid / Invalid Computation
• Example
Given,
L is a infinite language; ∑ = { a, b } L2
= { a, aa, aaa, ab, aab, abb,…. } String, S
= baba
• Here, S = baba , present in the language So this is an
example of valid operation for computation.
Automata
• The term "Automata" is derived from the Greek
word which means "self-acting".
• An automaton is an abstract self-propelled
computing device which follows a predetermined
sequence of operations automatically.
• A algorithm or program that automatically
recognizes if a particular string belongs to the
language or not, by checking the grammar of the
string.
Automata
• There are different verities of abstract machines
which can be defined mathematically.
• Some of them are as powerful as today's real
computers,
while the simpler ones are less powerful.
• Some models are considered even more powerful
than any real computers as they have infinite
memory.
FINITE AUTOMATA
• An automaton with a finite number of states is called a Finite
Automaton (FA) or Finite State Machine (FSM).
• It is act as a recognizer for specific a language/pattern.
• Any problem can be presented in form of decidable problem
that can be answered by Yes/No.
• FA (machine with limited memory) can solve any problem.
• Read an input string from tape
• Determine if the input string is in a language
• Determine if the answer for the problem is “YES” or “”NO for
the given input on the tape
8

You might also like