Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA CODE PLEASE, THANK YOU!! Overview The purpose of this assignment is to broaden your understanding of deterministic finite automata and their acceptance relation. Recall

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

JAVA CODE PLEASE, THANK YOU!!

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,8) where: . Q is a finite set of states; . E is an input alphabet; .FCQ is a set of final states; .90 Q is the initial (or start) state; and .8:QxE Q 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: 0 0 start {0,1} H Mo will be represented in plain text form as follows: Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 1 % 2 A B 4 5 D 6 E 7 F 8 G 9 H 10 I 11 J 12 % Sigma 130 14 1 15 % F 16 A 17 B 18 19 D 20 E 21 H 221 23 % Qe 24 A 25 % Delta 26 AOB 27 A 1 0 28 BOB 29B1E 30 COD 31 CIC 32 DOB 33 D 1 G 34 E OF 35 Eic 36 FEB 37 F11 38 GOH 39 G10 40 41H1 42 IO) 13 Iic 44 JOJ 45 J1] Note that in this representation, those lines preceded by a % sign (i.e., lines 1, 12, 15, 25, and 27) are to be treated as single line comments in Java - any content on the line after the % sign is to be ignored and is entirely optional. Also note, that for this assignment you are guaranteed the following about the DFA input file: the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 - 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 (which in the context of this example is {0,1}). The following is one possible input file' to be used with the deterministic finite automaton Mo from the previous section: 1100100 2 111 3 00100100 4 10101 5 01010101 Usage 3 4 The program DFACheck is intended to be run via the following command-line invocation: $ 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 displayed. For example: 1 $ java DFACheck 2 DFACheck: no input files specified $ java DFACheck foo.txt 5 DFACheck: invalid usage - the program must be given two files as input 6 7 $ java DFACheck no-such-file.txt input.txt 8 DFACheck: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheck: 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 100100 accepted 111 accepted 2010e1ee accepted 10101 rejected 01010101 rejected 9 2 3 6 5 6 Line numbers are included for reference only. Note that in the example output there is exactly one space between the string and its results. As before, line numbers are included for reference only. Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 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 simplicity 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,8) where: . Q is a finite set of states; . E is an input alphabet; .FCQ is a set of final states; .90 Q is the initial (or start) state; and .8:QxE Q 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: 0 0 start {0,1} H Mo will be represented in plain text form as follows: Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 1 % 2 A B 4 5 D 6 E 7 F 8 G 9 H 10 I 11 J 12 % Sigma 130 14 1 15 % F 16 A 17 B 18 19 D 20 E 21 H 221 23 % Qe 24 A 25 % Delta 26 AOB 27 A 1 0 28 BOB 29B1E 30 COD 31 CIC 32 DOB 33 D 1 G 34 E OF 35 Eic 36 FEB 37 F11 38 GOH 39 G10 40 41H1 42 IO) 13 Iic 44 JOJ 45 J1] Note that in this representation, those lines preceded by a % sign (i.e., lines 1, 12, 15, 25, and 27) are to be treated as single line comments in Java - any content on the line after the % sign is to be ignored and is entirely optional. Also note, that for this assignment you are guaranteed the following about the DFA input file: the DFA within it is correctly specified (i.e., is both a a DFA, and in the correct textual form), and Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 - 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 (which in the context of this example is {0,1}). The following is one possible input file' to be used with the deterministic finite automaton Mo from the previous section: 1100100 2 111 3 00100100 4 10101 5 01010101 Usage 3 4 The program DFACheck is intended to be run via the following command-line invocation: $ 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 displayed. For example: 1 $ java DFACheck 2 DFACheck: no input files specified $ java DFACheck foo.txt 5 DFACheck: invalid usage - the program must be given two files as input 6 7 $ java DFACheck no-such-file.txt input.txt 8 DFACheck: the file 'no-such-file.txt' could not be opened 10 $ java DFACheck dfa.txt no-such-file.txt 11 DFACheck: 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 100100 accepted 111 accepted 2010e1ee accepted 10101 rejected 01010101 rejected 9 2 3 6 5 6 Line numbers are included for reference only. Note that in the example output there is exactly one space between the string and its results. As before, line numbers are included for reference only. Programming Project 2: Generalizing the DFA Acceptance Relation Spring 2021 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 simplicity 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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

=+18-4 Describe the loca- tion and function of feature. detectors.

Answered: 1 week ago