You are on page 1of 4

Compiler Theory Lab 2

Finite State Machines

Deterministic Finite Automata (DFA)

Rules of DFA

This DFA is a 5-tuple (Q, Σ , 𝜹 , q0 , F)


1. Q = Set of states = {q0, q1,……}
2. Σ = alphabet = {0,1} or {a,b}
3. 𝜹 = transition function = (state diagram/tuple)
4. q0 = first state
5. F = set of final state

Exercise 1 Revisited

a) All strings of digits that contain no leading zeros


b) All strings of digits that represent even numbers

c) All strings of digits such that all the 2’s occur before all the 9’s

d) All strings of lowercase letters that either begin or end in a (or both)
e) All strings of lowercase letters that begin and end in a

f) All strings of a’s and b’s that contain no three consecutive b’s

g) All string of a’s and b’s that contain even numbers of a’s
h) All strings of a’s and b’s that contain an odd number of a’s or an odd number of b’s (or both)

Exercise 2

a) (A|B|…Z) (a|b|…|z)*

b) (0|1|…9|A|B|C|D|E|F)+(x|X)

You might also like