ALGORITHM RMET
--------------
Given Alphabet A.
Input: NFA (Q: States, din: Transition Function, S: Start State, Fin: Final States)
Output: Equivalent NFA without lambda-transitions
Method:
Construct output NFA (Q,dout,S,Fout) as follows:
1. For each state p in Q, Compute 
   lambda-closure(p) = { q | there is a path from p to q labeled 
                             only with lambda} U {p}
2. Output NFA transition function:
   for each q in Q, for each a in A
     introduce a transition from q on a to each state in lambda-closure(din(lambda-closure(q),a))
3. Fout = {q | q in Q and lambda-closure(q) contains some f in Fin }

ALGORITHM NTD
-------------
Given Alphabet A.
Input: NFA (Q: States, din: Transition Function, S: Start State, Fin: Final States)
without lambda-transitions
Output: Equivalent DFA
Method (Subset-construction):
Construct output DFA (Q',dout,{S}, Fout), where states in Q' are sets of states in Q, as follows
1. Define dout({q1,...,qn},a) = Union of din(qi,a), for each i, 1 <= i <= n.
2. Queue = < {S} >; Q' = {}
3. While Queue not empty do
     Q = dequeue(Queue);
     Q' = Q' union {Q};
     for each a in A 
       output transition from Q on a to dout(Q,a);
       enqueue(Queue,dout(Q,a)) if dout(Q,a) is neither in Q' nor in Queue;
     end for
   end while
4. Fout = { Q in Q' | Q contains at least one final state of Fin }

ALGORITHM MIN
-------------
Given Alphabet A.
Input: DFA (Q: States, d: Transition Function, S: Start State, F: Final States)
Output: Equivalent DFA with minimum number of states.
Method:

1. List all (unordered) pairs of states (p,q) where p is not same as q.
   (Note: On paper, these pairs can be listed in a staircase manner with
    the x-axis labeled with states 1 to n-1 and the y-axis labeled with
    states 2 to n.)
2. Mark each pair of which exactly one element is in F.
3. Repeat
     for each unmarked pair (r,s) do
        mark (r,s) if there exists a in A such that 
          d(r,a)=p, d(s,a)=q, and (p,q) is already marked.
4. Until (no new pairs are marked since previous iteration of repeat loop)
5. Create equivalence classes of states using:
     (p,q) unmarked iff p and q belong to same equivalence class.