Chapter 1&2
Chapter 1&2
Language: Language is defined as set of strings which are generated from sequence of symbols.
Regular Language:---language which are accepted/identified by finite automata…
or
To define language if we are using three set of operations:
1) Union(+,/): (0+1) (0/1)==at a time we can take either 0 or 1
2) Concatenation(.): 0.1====== 01=====both the symbol at a time
3) kleenes star(*): 0*========^ or more occurenece={^,0,00,000,0000,….}
1*={^,1,11,111,1111,11111,……}
a*={^,a,aa,aaa,….} b*={^,b,bb,bbb,bbbb,…}-SET---collection of elements
Regular Expression: It is used to express or define the regular language.
Alphabet / input symbol: It is used as finite sequence of non empty symbols.
11) binary string that have even length of string.- (0+1)*-- 11 , 01010,11101
(00+11+10+01)*
12) binary string contain exactly two 0’s.- 00 , 1010 , 11001, 10101 ,111001111111
1*0 1*0 1*
character=letter=l Digit=d _
(L + _)(L+d+_)*
00
11 1+ ={1,11,111,1111,…} / 1*={^,1,11,111,1111,…}
10 1+= 1.1*
01 (1+01)+ = (1+01)(1+01)*
(00+11)(0+1)* + (0+1)*(00+11)
Finite automata
1) Deterministic Finite Automata(DFA)
2) Non- Deterministic Finite Automata(NFA)
M=(Q, q0, A , ∑ , δ)
(11+10)*- minimum string : {11,10,^}--- note: intial state is also becomes accepted.
(00)*(11)* - {00,11,^, 000011,0011,1111}
(0+1)*(01+110) {01,110}
(1+110)*0{0, 10,1100}
▲*(q,ya)= ▲(▲(q,y),a)
traverse 001
▲*(A,001)= ▲(▲(A,00),1)
▲(A,00)=▲(▲(A,0),0)
= ▲(A, 0)= A
▲*(A,001)= ▲(▲(A,00),1)
= ▲(A,1)=B
string1011
For-{1}……A For-{3}-H
δ(A,a)={2}…….B δ(H,a)=φ….C
δ(A,b)=φ…….C—Dead state δ(H,b)={3}…..H
For-{2}-B
δ(B,a)={3,4}…..D
δ(B,b)={5}……E
For-{3,4}-D
δ(D,a)=δ(3,a)Uδ(4,a)={4}…..F
δ(D,b)={3,5}……G
For-{5}-E
δ(E,a)=φ…..C
δ(E,b)=φ……C
For-{4}-F
δ(F,a)={4}……F
δ(F,b)={5}……E
For-{3,5}-G
δ(G,a)=φ…..C
δ(G,b)={3}……H
For-{1}…..A For-{3,4}-D
δ(A,a)= {2,3}….B δ(D,a)={4}…..C
δ(A,b)={4}……C δ(D,b)={3}…….F
For-{2,3}=B For-{3}-F
δ(B,a)={4}…..C δ(F,a)={4}….C
δ(B,b)={3,4}…..D δ(F,b)={3}…..F
For-{4}-C
δ(C,a)=φ…….E
δ(C,b)=φ…..E
Q a b - defines initial state , + ,*,circle defines accepting state transition table
-A B C
B C D
+C* E E
+D* C F
E E E
F C F
Convert the following NFA into DFA using subset construction method.
Q a b
1 2 5
2 φ 3
3 4 3
4 3,5 φ
5* φ 1
For-{1}…..A For-{3,5}-G
δ(A,a)={2}…..B δ(G,a)={4}……F
δ(A,b)={5}….C δ(G,b)={1,3}={3,1}……H
For-{2}-B For-{1,3}-H
δ(B,a)=φ…..D δ(H,a)={2,4}…….I
δ(B,b)={3}….E δ(H,b)={3,5}………G
For-{5}-C For-{2,4}-I
δ(C,a)=φ…….D δ(I,a)={3,5}……..G
δ(C,b)={1}……..A δ(I,b)={3}……..E
For-{3}-E
δ(E,a)={4}……F
δ(E,b)={3}……E
For-{4}-F
δ(F,a)={3,5}….G
δ(F,b)=φ…..D
Q a b
1 2 5
2 φ 3
3 4 3
4 3,5 φ
5* φ 1
each input symbol contain one each input symbol multiple transiton each input symbol multiple transiton &
transition also contain null transion
Examples:
1) Union : a+b
Convert NFA-^ to DFA: NFA-^ to NFA - Subset construction method to convert NFA- DFA
Convert The following NFA-^ into DFA:
Transition table:
Q 0 1 ^
A A φ B
B C φ D
C φ B φ
+D* D φ φ
that already given. Accepting state in NFA === Accepting state NFA-^
(0) (1)
A {A,B,D,C φ
}
B {C,D} φ
C φ {B,D}
D* {D} φ
intial state of NFA becomes initial state in DFA
Q 0 1
A=q0 {A,B,C,D}=q1 φ=q5
{A,B,C,D}=q1 {A,B,C,D}=q1 {B,D}=q2
{B,D}=q2 {C,D}=q3 φ=q5
{C,D}=q3 {D}=q4 {B,D}=q2
{D}=q4 {D}=q4 φ=q5
φ=q5 q5 q5
NFA-^ to NFA : total no states are same
NFA---- accepting state? ----4
Q ^(Q) a ^(a) b ^(b)
1 {1,4} φ φ {2,3,5} {2,3,5}
2 {2} {3} {3} φ φ
3 {3} φ φ φ φ
4 {4} φ φ {5} {5}
5 {5} {4} {4} φ φ
NFA:
Q ^(a) ^(b)
1 φ {2,3,5}
2 {3} φ
3 φ φ
4* φ {5}
5 {4} φ
Q a b
1 2 3
2 3 5
3 4 3
4 3 5
5* 2 5
0 th : {q0,q1,q2,q4}{q3,q5}
Q 0
q0 q1
q1 q0
q2 q1
q4 q3
{q0,q1,q2}{q4} 1st partition is complete when all group a’s & b’s transition are completed.
Q 1
q0 q3
q1 q3
q2 q4
{q0,q1}{q2}{q4}{q3,q5}
2nd partition:
Q 0
q0 q1
q1 q0
Q 1
q0 q3
q1 q3
Furthur partition is not possible: Final: {q0,q1}{q2}{q4}{q3,q5}
Convert the following DFA into minimized DFA
Q 0 1 0th partition: {q2,q5,q8} {q0,q1,q3,q4,q6,q7}
q0 q1 q4
q1 q2 q5
q2* q3 q7
q3 q4 q7
q4 q5 q8
q5* q6 q1
q6 q7 q1
q7 q8 q2
q8* q0 q4
q2,q5,q8} {q0,q1,q3,q4,q6,q7}
1st partition:
Q 0 1
q2* q3 q7
q5* q6 q1
q8* q0 q4
Q 0 1
q0 q1 q4
q1 q2 q5
q3 q4 q7
q4 q5 q8
q6 q7 q1
q7 q8 q2
{q0,q3,q6}{q1,q4,q7}{q2,q5,q8}
2nd partition:
Furthur partition is not possible: {q0,q3,q6}{q1,q4,q7}{q2,q5,q8}
Chapter:1:
F(x)= 2x+3
RR+
one to one??? yes
given fuction onto
Set A Set B
1 5
-1 1
2 7
Relation:
A={1,2,3}
={(1,1),(1,2),(1,3)..}
Equivalence:
1) Reflexive: R aRa: {(1,1),(2,2),(3,3)}
2) Symmetric: if aRb then bRa : (1,2) ---- > (2,1)
3) Transitive:if aRb, bRc then aRc: (1,2) & (2,3) -(1,3)
4) all the properties satisfied then R becomes equi.
A*B={(1,3),(1,2),(2,2),(2,3)}
1)={(1,1),(3,3)}
2) ={(3,1),(2,1),(3,2)}
3)={ (1,3),(1,2),(2,2),(2,3), (1,1),(3,3), (3,1),(2,1),(3,2)}
(1,2) & (2,3) = (1,3)
(2,3) & (3,1)=(2,1)
(3,1) & (1,2)=(3,2)
R={(1,2),(1,1),(2,1)(2,2),(3,2),(3,3)}
1: reflexive
2: (2,3)
={(1,2),(1,1),(2,1)(2,2),(3,2),(3,3),(2,3)}
3: (1,2)(2,3)(1,3)
(3,2)(2,1)(3,1)
Logic:
AND OR NOT
By contradiction :
Assumption: multiplication of this number is even:
2z even number = (2x+1)(2y+1)
2z=4xy+2x+2y+1
2z=2(2xy+x+y) + 1
cancel out 2 from both sides
z= 2xy + x + y +(1/2)
assumption becomes wrong, so by contradiction we can prove that….
Contradiction :
1) Output contradict first that becomes our assumption
2) proving state true: assumption becomes false or input changed
1) Prove that for any set A,B,C if A∩B=φ and C ⊆ B then A∩C=φ.
Assumption: suppose A∩C = x
3) mathematical induction
it has 3 steps:
1) basic step: show that the statement is true for some integer
2) hypothesis step: assume the statement is true for some integer variable k
3) Induction step: statement is true for K+1
1) Prove that p( n)=1+2+…+n= n(n+1)/2
basic step:
n=0
p(n)=1+2+…+n
p(0)=0=LHS
n(n+1)/2 =0=RHS
basic step is true
Hyothesis step:
p(n)=1+2+…+n=n(n+1)/2
let n=k
p(k)=1+2+…+k=k(k+1)/2 this is also true.
Induction step:
LHS:1+2+….+(K+1)
RHS=(k+1)(k+2)/2
LHS= 1+2+….+(K+1)
= 1+2+….+k+ (k+1)
= k(K+1)/2 + (k+1)
Prove that for integer n>=0 p(n)=12+22+…+n2= n(n+1)(2n+1)/6
basic step: n=0
p(0)=lhs=rhs=0
basic step is true
-------
Hyposthesis step:
let n=k
p(k)= 12+22+…+k2= k(k+1)(2k+1)/6 is also true.
Induction step:
lhs: 12+22+…+(k+1)2
rhs= (K+1)(k+2)(2K+3)/6
lhs= 12+22+…+(k+1)2
=12+22+…+k2+(k+1)2
Prove that for n>=0 6n-1 is divisible by 5.
n=0
60-1=1-1=0 which is divisible by 5.
-----
hypothe: 6k-1 is also divisible by 5====5x
induction step:
n=k+1
6k+1 -1
6k . 6 -1
6k .(5+1) -1
6k .5 + 6k - 1
6k .5+ 5x
5 (6k+1) which is already divisible by 5.
so the …..
Prove that 5n-2n is divisible by 3
n=0 basic step is true
n=k : 5k – 2k ===3x is also true
n=k+1
5k+1 – 2 k+1
5k.5 – 2k 2
5k.(3+2) – 2k 2
5 k 3 + 5 k 2 - 2k 2
5k 3 + 2(5k - 2k )
5k 3 + 2(3x )
3(5k+ 2x) is also divisible by 3.
Prove that for all integer n>=1 P(n)=1+4+7+…+(3n-2)=n(3n-1) / 2