Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3 The Program You are free to design your minimizer however you wish. When compl

ID: 643120 • Letter: 3

Question

3 The Program You are free to design your minimizer however you wish. When complete. you must be able to: . Load a DFSM from a text tile (formatted any way you choose) . Output a minimized DFSM to a text file, formatted the same way as your input text file . Run inputs against a DFSM to determine whether it accepts or rejects the input ? You can set up your program to keep track of both the original and minimized DFSMs and run inputs against both. or you can simply allow it to load a DFSM from a text file and run inputs against only one FSM at a time. VERY IMPORTANT!: I will test your programs with input DFSMs and strings that I will not tell you about in advance. Your program needs to be able to take and process input from files for both the DFSM and the test inputs. Hard-coding DFSMS or inputs will not work.

Explanation / Answer

I will not bore you with the theory, since you can read all about it in the wikipedia article, which explains the logic behind FSM better than I ever could. So I will just start withprogramming by wishful thinking. This is how I would like to consume an implementation of a deterministic FSM (DFSM):

As you can see I define the five components that make a DFSM: the states of the machineQ, the alphabet Sigma, the list of transitions Delta, the start state Q0, and the set of finish states F. I then construct the machine by passing the components to the constructor.

I expect the upper definition to construct the FSM that is visible on the image below. As you can see the machine accepts all the words with an even number of

  // Declaration  var Q = new List<string>{"q0", "q1", "q2"};  var Sigma = new List<char>{'a'};  var Delta = new List<Transition>{      new Transition("q0", 'a', "q1"),      new Transition("q1", 'a', "q2"),      new Transition("q2", 'a', "q1")  };  var Q0 = "q0";  var F = new List<string>{"q0", "q2"};  var dFSM = new DeterministicFSM(Q, Sigma, Delta, Q0, F);