Year 2 Term 1 Exams Flashcards
formal definition of a DFA
M = (Q, ∑, δ, s, F)
transition function of a DFA
δ : Q x ∑ -> Q
for 2 langauges to be regular, what 4 combinations must be regular
union, intersection, concatenation, kleene star
how do you prove regularity (4 steps)
1) define the langauge
2) construct a DFA
3) show acceptance of strings in the langauge
4) show rejection of strings not in the language
formal definition of an NFA
M = (Q, ∑, Δ, s, F)
transition function of an NFA
Δ : Q x ∑ -> 2^Q
what is non-deterministic acceptance
when an NFA reaches at least one accepting state after processing the entire input
formal definition of an εNFA
M = (Q, ∑, θ, s, F)
transition function of an εNFA
θ : Q x (∑ ∪ {ε}) -> 2^Q
how to convert an εNFA to an NFA (3 steps)
1) remove ε-transitions
2) states with ε-transitions to final states become final
3) new transitions added to preserve language
kleene’s theorem
if a is a regexp, then L(a) is a regular language
if L is a regular language, then L = L(a) for some regexp a
games with the demon - regular langauges
1) demon picks some k > 0
2) we pick x = _, y = _, z = _, s.t. |y| >= k
3) demon picks u,v,w s.t. y = uvw, v =/ ε
4) we pick i >= 0
why can’t CFLs be recognised by finite automata
they may include nesting or recrusive structures
formal definition of a CFG
G = (N, ∑, P, S)
CFG productions
P : N x (N ∪ ∑)*
what are CFGs used for
specifying syntax of programming langauges
compilers use parsers constructed from CFGs to verify inputs
if an input is of length n, how many variables in a CNF CFG
at most 2^(n+1) - n+1 is the length of each derivation
games with the demon - CFGs
1) demon picks some k > 0
2) we pick z = _
3) demon picks u,v,w,x,y s.t. z = uvwxy, |vx| > 0, |vwx| <= k
4) we pick i >= 0 (and show that, however the demon breaks up z, we can still pump it)