Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a DFA (deterministic finite automata) in java using these sets of instructions. Pay close attention to the highlighted text. Overview The purpose of this

Create a DFA (deterministic finite automata) in java using these sets of instructions. Pay close attention to the highlighted text.

image text in transcribed

Overview The purpose of this assignment is to broaden your understanding of deterministic finite automata and their acceptance relation. Recall that a deterministic finite automaton is defined as a 5-tuple of the form (Q, E, F, 90, ) where: Q is a finite set of states; . is an input alphabet; . FC is a set of final states; .90 Q is the initial (or start) state; and 8:QxIQ is a transition function and that a string w is accepted by a DFA M, if and only if there exists a path from the start state of M to some final state in M labeled by the constituent characters of w. In this assignment, you will implement a program in Java which will accept as its input a pair of file names, the first of which contains a textual representation of a DFA, and the second of which contains a collection of strings, and determines whether or not the given strings are accepted by the specified automaton Specification Define a program called DFACheck which will accept as its input a pair of file names, the first of which contains a textual representation of a DFA, and the second of which contains a collection of strings, and determines whether or not the given strings are accepted by the specified automaton. DFA Input File Specification Consider the DFA, Mo shown in the figure below: start - (0,1) Mo will be represented in plain text form as follows: the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and that the order of the DFA's constituent parts are as in the example above (which by design corresponds with how the definition of a DFA is formulated). String Input File Specification For this assignment you may assume that the string input file is formatted with exactly one string per line and that the strings are guaranteed to be formed from characters of the input alphabet {0, 1}. As an example, the following is one possible input file: 1 2 3 4 5 100100 111 00100100 10101 01010101 Usage The program DFACheck is intended to be run via the following command-line invocation: 1 $ java DFACheck dfa.txt input.txt If no input file is specified or if the input file is not found, an appropriate error message must be display. For example: 1 $ java DFACheck DFACheckBasic: no input files specified $ java DFACheck foo.txt DFACheckBasic: invalid usage - the program must be given two files as input 7 8 $ java DFACheck no-such-file.txt input.txt DFACheckBasic: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheckBasic: the file 'no-such-file.txt' could not be opened If valid files are specified as input, then for every string of the second file you should output both the string and the word accepted if the given DFA accepts it and rejected otherwise, with only one string's results given per line. Using the files dfa.txt and input.txt given as examples above, your program should behave as follows: 1 $ java DFACheck dfa.txt input.txt 2 100100 accepted 3 111 accepted 4 00100100 accepted 5 10101 rejected the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and that the order of the DFA's constituent parts are as in the example above (which by design corresponds with how the definition of a DFA is formulated). String Input File Specification For this assignment you may assume that the string input file is formatted with exactly one string per line and that the strings are guaranteed to be formed from characters of the input alphabet {0, 1}. As an example, the following is one possible input file: 1 100100 2 111 3 00100100 4 10101 5 01010101 Usage The program DFACheck is intended to be run via the following command-line invocation: 1 $ java DFACheck dfa.txt input.txt If no input file is specified or if the input file is not found, an appropriate error message must be display. For example: 1 $ java DFACheck DFACheckBasic: no input files specified 4 $ java DFACheck foo.txt 5 DFACheckBasic: invalid usage - the program must be given two files as input $ java DFACheck no-such-file.txt input.txt 8 DFACheckBasic: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheckBasic: the file 'no-such-file.txt' could not be opened If valid files are specified as input, then for every string of the second file you should output both the string and the word accepted if the given DFA accepts it and rejected otherwise, with only one string's results given per line. Using the files dfa.txt and input.txt given as examples above, your program should behave as follows: 1 2 3 $ java DFACheck dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 5 6 01010101 rejected Compilation Notes Your program must compile using the following command-line invocation: 1 $ javac *.java Do not submit any IDE specific files and in the interest of simplicty do not use packages for this assignment. If your program does not compile using the command mentioned above you will receive no credit. Overview The purpose of this assignment is to broaden your understanding of deterministic finite automata and their acceptance relation. Recall that a deterministic finite automaton is defined as a 5-tuple of the form (Q, E, F, 90, ) where: Q is a finite set of states; . is an input alphabet; . FC is a set of final states; .90 Q is the initial (or start) state; and 8:QxIQ is a transition function and that a string w is accepted by a DFA M, if and only if there exists a path from the start state of M to some final state in M labeled by the constituent characters of w. In this assignment, you will implement a program in Java which will accept as its input a pair of file names, the first of which contains a textual representation of a DFA, and the second of which contains a collection of strings, and determines whether or not the given strings are accepted by the specified automaton Specification Define a program called DFACheck which will accept as its input a pair of file names, the first of which contains a textual representation of a DFA, and the second of which contains a collection of strings, and determines whether or not the given strings are accepted by the specified automaton. DFA Input File Specification Consider the DFA, Mo shown in the figure below: start - (0,1) Mo will be represented in plain text form as follows: the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and that the order of the DFA's constituent parts are as in the example above (which by design corresponds with how the definition of a DFA is formulated). String Input File Specification For this assignment you may assume that the string input file is formatted with exactly one string per line and that the strings are guaranteed to be formed from characters of the input alphabet {0, 1}. As an example, the following is one possible input file: 1 2 3 4 5 100100 111 00100100 10101 01010101 Usage The program DFACheck is intended to be run via the following command-line invocation: 1 $ java DFACheck dfa.txt input.txt If no input file is specified or if the input file is not found, an appropriate error message must be display. For example: 1 $ java DFACheck DFACheckBasic: no input files specified $ java DFACheck foo.txt DFACheckBasic: invalid usage - the program must be given two files as input 7 8 $ java DFACheck no-such-file.txt input.txt DFACheckBasic: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheckBasic: the file 'no-such-file.txt' could not be opened If valid files are specified as input, then for every string of the second file you should output both the string and the word accepted if the given DFA accepts it and rejected otherwise, with only one string's results given per line. Using the files dfa.txt and input.txt given as examples above, your program should behave as follows: 1 $ java DFACheck dfa.txt input.txt 2 100100 accepted 3 111 accepted 4 00100100 accepted 5 10101 rejected the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and that the order of the DFA's constituent parts are as in the example above (which by design corresponds with how the definition of a DFA is formulated). String Input File Specification For this assignment you may assume that the string input file is formatted with exactly one string per line and that the strings are guaranteed to be formed from characters of the input alphabet {0, 1}. As an example, the following is one possible input file: 1 100100 2 111 3 00100100 4 10101 5 01010101 Usage The program DFACheck is intended to be run via the following command-line invocation: 1 $ java DFACheck dfa.txt input.txt If no input file is specified or if the input file is not found, an appropriate error message must be display. For example: 1 $ java DFACheck DFACheckBasic: no input files specified 4 $ java DFACheck foo.txt 5 DFACheckBasic: invalid usage - the program must be given two files as input $ java DFACheck no-such-file.txt input.txt 8 DFACheckBasic: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheckBasic: the file 'no-such-file.txt' could not be opened If valid files are specified as input, then for every string of the second file you should output both the string and the word accepted if the given DFA accepts it and rejected otherwise, with only one string's results given per line. Using the files dfa.txt and input.txt given as examples above, your program should behave as follows: 1 2 3 $ java DFACheck dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 5 6 01010101 rejected Compilation Notes Your program must compile using the following command-line invocation: 1 $ javac *.java Do not submit any IDE specific files and in the interest of simplicty do not use packages for this assignment. If your program does not compile using the command mentioned above you will receive no credit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions