Cmsc 141
Proof - a sequence/series of formal statements
Direct Proof - a sequence of statements which are either givens or deductions from previous statements
Proof by counterexample - a proof by giving one example or instance that disproves the case
Proof by contradiction - a proof that assumes that the opposite proposition is true then show or arrive at a contradiction.
Proof by mathematical induction - Given a propositional function P(n) defined for integers n, and a fixed integer a. Then, if these two conditions are true;
P(a) is true.
if P(k) is true for some integer k≥a, then P(k+1) is also true.
then P(n) is true for all integers n≥a.
Set - a collection (unordered) of objects
Subset - Set A is a subset of Set B, A⊆B, if each element of A is also an element of B.
Proper Subset - A is a proper subset of B, A ⊂ B, If A is a subset of B but not the same as B(if each element of A is also an element of B but not the same as B)
Cardinality of Set |S|- the measure of the number of elements within a set.
Powerset P(S) - the set of all subsets of S.
Union: A∪B = {x : x ∈ A or x ∈ B}
Intersection: A∩B = {x : x ∈ A and x ∈ B}
Difference:A-B = {x : x ∈ A and x ∉ B}
Idempotency:
❏ A∪A = A
❏ A∩A = A
Commutativity:
❏ A∪B = B∪A
❏ A∩B = B∩A
Associativity:
❏ (A∪B)∪C = A∪(B∪C)
❏ (A∩B)∩C = A∩(B∩C)
Distributivity:
❏ (A∪B)∩C = (A∩C) ∪ (B∩C)
❏ (A∩B)∪C = (A∪C) ∩ (B∪C)
Absorption:
❏(A∪B)∩A = A
❏ (A∩B)∪A = A
DeMorgan’s:
❏ A - (B∪C) = (A-B)∩(A-C)
❏ A - (B∩C) = (A-B)∪(A-C)
A partition of a non-empty set A is a subset Π of 2^A such that ∅ is not an element of Π and such that each element of A is in one and only one set in Π.
Function ‘f’ is a relation on X and Y such that for each x ∊ X, there exists a unique y ∊ Y such that (x,y) ∊ R. ‘x’ is called pre-image and ‘y’ is called image of function f.
Symbol - An atomic unit, such as a digit, character, lower-case letter, etc. Sometimes a word.
Alphabet - A finite set of symbols, denoted by Σ.
Length- string w ∈ Σ* is a function w: {1, 2, …, |w|} → Σ
Substring -
Concatenation of languages
If L1 and L2 are languages over Σ, their concatenation is L = L1○L2 where
L = {w ∈ Σ* : w = xy for some x∈L1 and y∈L2 }
Kleene Star
denoted by L*, the set of all strings obtained by concatenating zero or more strings from L.
{w ∈ Σ* : w = w1○…○wk for some k ≥ 0 and some w1 ,…, wk ∈ L}
Expressions
regular expressions over an alphabet Σ are all strings over the alphabet Σ U {(,),∅,U,*} that can be obtained as follows:
❏ ∅ and each member of Σ is a regular expression
❏ if α and β are regular expressions, then so is (αβ)
❏ if α and β are regular expressions, then so is (αUβ)
❏ if α is a regular expression, then so is α*
❏ nothing is a regular expression unless it follows from (1) through (4)
regular languages - the class of regular languages over an alphabet Σ is defined to consist of all languages L such that L = ℒ (α) for some regular expression α over ΣAn algorithm that is specifically designed, for some language L, to answer questions of the form "Is string w a member of L?" will be called a language recognition device.
❏ L = {w ∈ {O, 1} * : w does not have 111 as a substring}.
Deterministic Finite Automaton (DFA)
The DFA:
A deterministic finite automaton is a quintuple M = (K, Σ, δ, s, F) where
K is a finite set of states
Σ is an alphabet
s ∈ K is the initial state
F ⊆ K is the set of final states
δ, the transition function, is a function from K x Σ to K
If M is in state q ∈ K and the symbol read is a ∈ Σ, then δ(q,a) ∈ K.
The binary relation ├M in DFA:
If (q, w) and (q', w') are configurations of M, then (q, w) ├M (q', w') if and only if w=aw' for some symbol a ∈ Σ, and δ (q,a) = q'
(q, w) yields (q', w') in one step
├M is a function from K x Σ+to K x Σ*
String accepted by M:
A string w ∈ Σ* is said to be accepted by M if and only if there is a state q ∈ F such that (s, w) ├*M (q, e).
Language L(M):
The language accepted by M, L(M), is the set of all strings accepted or recognized by M.
Dead state:
A dead state is some state qi ∈ K for some 0 ≤ i ≤ |K|-1 such that qi ∉ F and δ(qi,a) = qi for all a ∈ Σ
Non-deterministic Finite Automaton (NFA)
The NFA:
A nondeterministic finite automaton is a quintuple M = (K, Σ, Δ, s, F) where
K is a finite set of states
Σ is an alphabet combination of current state and input symbol
s ∈ K is the initial state
F ⊆ K is the set of final states
Δ, the transition function, is a function from K x (Σ U {e}) x K (or K x Σ* x K for string transitions)
The binary relation ├M in NFA:
If (q, w) and (q', w') are configurations of M, then (q, w) ├M (q', w') if and only if w=aw' for some symbol a ∈ Σ U {e}, and (q,a,q') ∈ Δ
NFA and DFA Equivalence
Theorem:
For each nondeterministic finite automaton, there is an equivalent deterministic finite automaton
Let M = (K, Σ, Δ, s, F) be a nondeterministic finite automaton.
To prove the theorem, we construct M’ = (K’, Σ, δ, s’, F’) equivalent to M
K’ = 2K
s' = E(s)
F’ = {Q ⊆ K: Q ∩ F ≠ ∅}
δ
NFA is a DFA:
An NFA is a DFA provided that
If (q, u, q') ∈ Δ then |u| = 1
(q, e, q') transitions are absent in Δ
For each q ∈ K and σ ∈ Σ, there is a unique q' ∈ K s.t. (q, σ, q') ∈ Δ
Equivalent Finite Automata:
Finite automata M1 and M2 are equivalent iff L(M1) = L(M2)
w ∈ L(M1) then w ∈ L(M2)
Converting NFA to DFA:
Let M = (K, Σ, Δ, s, F) be an NFA
Step 1: Eliminate “string” transitions
Formally, if (q, σ1σ2...σk, q') ∈ Δ and σ1, σ2, ...σk, ∈ Σ, k>1, add new non-final states q1, ...qk-1 to K and new transitions (q,σ1,q1), (q1,σ2,q2), … (qk-1,σk,q') to Δ
Let M' = (K', Σ, Δ', s', F') be the NFA that resulted when the transformation was applied to each transition (q,u,q'), |u| > 1
Obviously, L(M) = L(M')
Construct M'' = (K'', Σ, Δ'', s'', F'') equivalent to M’
Step 2: Eliminate e-transitions
For any state q ∈ K’, let E(q) be the set of all states of M’ that are reachable from state q without reading any input.
E(q) = { p ∈ K' | (q,e)├*M (p,e) }
If M' moves without reading any input then its operation clearly does not depend on what that input is.
Step 3: Define M”
Define M'' = (K'', Σ, Δ'', s'', F'')
K'' = 2K'
s'' = E(s')
F'' = {Q ⊆ K' | Q ∩ F' ≠ Ø }
and for each Q ⊆ K and each symbol a ∈ Σ, define Δ''(Q, a)= U {E(p) | p ∈ K' and (q,a,p) ∈ Δ' for some q ∈ Q}
Finite Automata and Regular Languages
Theorem:
The class of languages accepted by finite automata is closed under Union, Concatenation, Kleene Star, Complementation, and Intersection
Union:
Let M1 = (K1, Σ, 1, s1, F1) and M2 = (K2, Σ, 2, s2, F2) be non-deterministic finite automata
construct a nondeterministic finite automaton M such that L(M) = L(M1) U L(M2)
M = (K, Σ, Δ, s, F)
K = K1 U K2 U {s}
F = F1 U F2
Δ = 1 U 2 U {(s, e, s1), (s, e, s2)}
Concatenation:
Let M1 = (K1, Σ, 1, s1, F1) and M2 = (K2, Σ, 2, s2, F2) be non-deterministic finite automata
construct a nondeterministic finite automaton M such that L(M) = L(M1) ○ L(M2)
M = (K, Σ, Δ, s, F)
K = K1 U K2 U {s}
F = F2
Δ = 1 U 2 U {(s, e, s1)} U {(f, e, s2) f ∈ F1}
Kleene Star:
Let M1 = (K1, Σ, 1, s1, F1) a non-deterministic finite automaton
construct a nondeterministic finite automaton M such that L(M) = L(M1)*
M = (K, Σ, Δ, s, F)
K = K1 U {s}
F = F1 U {s}
Δ = 1 U {(s, e, s1)} U {(f, e, s) f ∈ F1}
Complementation:
Let M = (K, Σ, δ, s, F) a deterministic finite automaton
The complementary language L’ = Σ* - L(M)
M = (K, Σ, δ, s, F’)
K = K
δ = δ
F’ = K - F
Intersection:
Intersection is formally defined as L1 ∩ L2 where
Σ* - ((Σ* - L1 ) U (Σ* - L2 ))
Theorem:
A language is regular if and only if it is accepted by finite automaton
(ONLY IF) the class of regular languages is the smallest class of languages containing the empty set ∅ and the singletons a, where a is a symbol, and closed under union, concatenation, and Kleene star.
(IF) Given L(M), where M is a DFA, there is a regular expression R that generates L(R) = L(M)
Regular Expression L(R) = L(M):
(Proof by construction)
Let M = (K, Σ, Δ, s, F)
K = {q1,q2, ..., qn } and s = q1
For i,j = 1, ... , n and k = 0, ... ,n, define R(i, j, k) as the set of all strings in Σ* that may drive M from state qi to state qj without passing through any intermediate state numbered k+1 or greater
when k = n, it follows that
R(i,j,n) = {w ∈ Σ*: (qi , w)├*M (qj ,e)}.
Prefix closure of a language L, denoted as Pref(L):
Pref(L) = {u ∈ Σ* : there exists v ∈ L such that u is a prefix of v
Regular Languages and Non-regular Languages
Theorem:
Pumping Lemma for Regular Languages
Let L be a regular language. There is an integer n ≥ 1 (pumping length) such that any string w ∈ L with |w| ≥ n can be rewritten as w = xyz such that y ≠ e, |xy| ≤ n, and xyiz ∈ L for each i ≥ 0.