Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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.2, F. 90.5) where: . Q is a finite set of states; . E is an input alphabet; FSQ is a set of final states; Go E Q is the initial (or start) state; and .8:QxIQ is a transition function and that a string 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 DFAvalidate 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, M, shown in the figure below: 0 o start {0,1) M, will be represented in plain text form as follows: 1 % 2 A 4 5D 6 E 7 F 8 9 H 10 I 11 3 12 % Sigma 13 1 15 % F 16 A 17 B 18 19 D 20 E 21 H 22 I 23 % QO A 25 % Delta 25 AOB 27 A 10 28 BOB 29 B 1 E 30 COD 31 C10 32 DOB 33 D1G 34 E OF 35 E10 36 FOB 37 F11 38 GOH 39 G10 40 HOB 41 H1) 42 IO) 43 I10 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 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 M, from the previous section: 1 2 3 100100 111 00100100 10101 01010101 4 5 Usage The program DFAValidate is intended to be run via the following command-line invocation: 1 $ java DFAValidate 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: $ java DFAValidate DFAValidate: no input files specified 2 4 $ java DFAValidate foo.txt DFAValidate: invalid usage - the program must be given two files as input 5 6 7 $ java DFAValidate no-such-file.txt input.txt DFAValidate: the file 'no-such-file.txt' could not be opened 8 9 10 $ java DFAValidate dfa.txt no-such-file.txt DFAValidate: the file 'no-such-file.txt' could not be opened 11 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 DFAValidate dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 01010101 rejected 4 5 6 "Line numbers are included for reference only. 2 Note that in the example output there is exactly one space between the string its results. As before, line numbers are included for reference only. Usage The program DFAValidate is intended to be run via the following command-line invocation: $ java DFAValidate dfa.txt input.txt 1 1 If no input file is specified or if the input file is not found, an appropriate error message must be displayed. For example: $ java DFAValidate 2 DFAValidate: no input files specified 3 $ java DFAValidate foo.txt 5 DFAValidate: invalid usage - the program must be given two files as input 6 7 $ java DFAValidate no-such-file.txt input.txt 8 DFAValidate: the file 'no-such-file.txt' could not be opened 4 9 10 $ java DFAvalidate dfa.txt no-such-file.txt 11 DFAValidate: 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 DFAValidate dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 01010101 rejected 4 5 6 Line numbers are included for reference only. 2 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 Fall 2020 Compilation Notes Your program must compile using the following command-line invocation: $ 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.2, F. 90.5) where: . Q is a finite set of states; . E is an input alphabet; FSQ is a set of final states; Go E Q is the initial (or start) state; and .8:QxIQ is a transition function and that a string 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 DFAvalidate 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, M, shown in the figure below: 0 o start {0,1) M, will be represented in plain text form as follows: 1 % 2 A 4 5D 6 E 7 F 8 9 H 10 I 11 3 12 % Sigma 13 1 15 % F 16 A 17 B 18 19 D 20 E 21 H 22 I 23 % QO A 25 % Delta 25 AOB 27 A 10 28 BOB 29 B 1 E 30 COD 31 C10 32 DOB 33 D1G 34 E OF 35 E10 36 FOB 37 F11 38 GOH 39 G10 40 HOB 41 H1) 42 IO) 43 I10 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 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 M, from the previous section: 1 2 3 100100 111 00100100 10101 01010101 4 5 Usage The program DFAValidate is intended to be run via the following command-line invocation: 1 $ java DFAValidate 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: $ java DFAValidate DFAValidate: no input files specified 2 4 $ java DFAValidate foo.txt DFAValidate: invalid usage - the program must be given two files as input 5 6 7 $ java DFAValidate no-such-file.txt input.txt DFAValidate: the file 'no-such-file.txt' could not be opened 8 9 10 $ java DFAValidate dfa.txt no-such-file.txt DFAValidate: the file 'no-such-file.txt' could not be opened 11 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 DFAValidate dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 01010101 rejected 4 5 6 "Line numbers are included for reference only. 2 Note that in the example output there is exactly one space between the string its results. As before, line numbers are included for reference only. Usage The program DFAValidate is intended to be run via the following command-line invocation: $ java DFAValidate dfa.txt input.txt 1 1 If no input file is specified or if the input file is not found, an appropriate error message must be displayed. For example: $ java DFAValidate 2 DFAValidate: no input files specified 3 $ java DFAValidate foo.txt 5 DFAValidate: invalid usage - the program must be given two files as input 6 7 $ java DFAValidate no-such-file.txt input.txt 8 DFAValidate: the file 'no-such-file.txt' could not be opened 4 9 10 $ java DFAvalidate dfa.txt no-such-file.txt 11 DFAValidate: 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 DFAValidate dfa.txt input.txt 100100 accepted 111 accepted 00100100 accepted 10101 rejected 01010101 rejected 4 5 6 Line numbers are included for reference only. 2 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 Fall 2020 Compilation Notes Your program must compile using the following command-line invocation: $ 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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago