Formal language and automaton simulation system based on Android platform
By developing a formal language and automaton simulation system based on the Android platform, the problem of lack of mobile platform simulation software in China has been solved, the visual construction and simulation of various automata have been realized, the usage threshold has been lowered, and it is suitable for teaching and mobile platform environments.
Patent Information
- Application Number
- CN202410512800.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-04-26
AI Technical Summary
At present, domestic universities lack formal language and automaton simulation software based on mobile platforms. Traditional teaching methods are difficult to effectively impart formal language and automaton theory. Existing desktop platform software such as JFLAP is widely used but not suitable for mobile platforms.
Develop a formal language and automaton simulation system based on the Android platform, including a user interaction layer, a data processing layer, an intermediate layer, and a storage layer. It provides the creation and simulation of models such as finite automata, pushdown automata, and Turing machines, supports the visual construction and persistent storage of various automata, and has good page interaction capabilities.
It realizes the visual construction and simulation of various types of automata, lowers the usage threshold, is suitable for beginners, supports teaching demonstrations, has good page interaction functions, and is suitable for teaching and mobile platform environments.
Smart Images

Figure CN118363714B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of modeling and digital simulation of formal language and automata theory, and in particular relates to a formal language and automata simulation system based on an Android platform. Background Art
[0002] Around 1956, N. Chomsky proposed a mathematical model of grammar in his research on natural languages. He used restrictions on productions to categorize grammars into four types: phrase grammars (Type 0), context-sensitive grammars (Type 1), context-free grammars (Type 2), and regular grammars (Type 3). In 1959, he proved the equivalence between grammars and automata. These four types of formal grammars correspond to Turing machines, linear bounded automata, pushdown automata, and finite automata in automata theory, respectively. In computer science research, formal languages and automata are often used as abstract models of computers and computational processes to study computer architecture and algorithm design.
[0003] Due to the fundamental theoretical role of formal languages and automata theory in modern computer science, many universities offer courses in computer science-related majors. As a crucial foundational course, the abstract and formal nature of formal languages and automata theory makes it difficult to achieve effective learning outcomes using traditional teaching methods. Scholars have long recognized this issue, and with the increasing popularity of modern computers, a variety of formal language and automata simulation software has emerged for educational purposes.
[0004] To date, the most widely used automaton simulation software is JFLAP, developed by Rodger et al. Based on their FLAP software, JFLAP is a desktop-based, graph-based visual automaton simulation software developed in Java. It supports simulation of deterministic and nondeterministic finite automata, pushdown automata, Turing machines, and specialized finite automata such as Mealy and Moore machines. Users can draw automata in JFLAP by clicking and dragging, and interactively set state and transition properties. According to data published by Rodger in 2009, JFLAP has been downloaded over 64,000 times, with users in over 160 countries.
[0005] Compared to desktop-based formal language and automata simulation software, there was a lack of such software for mobile platforms until Carlos H. Pereira and Ricardo Terra launched FLApp. FLApp is an Android-based mobile software that implements the key features of each level of the Chomsky hierarchy. It is currently used in formal language and automata courses at Brazilian universities.
[0006] Although domestic universities have started teaching formal languages and automata courses, there is currently no simulation software based on mobile platforms that has been officially applied. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a formal language and automaton simulation system based on the Android platform in response to the above-mentioned deficiencies in the prior art.
[0008] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0009] Formal language and automaton simulation system based on Android platform, including user interaction layer, data processing layer, middle layer and storage layer based on Android platform;
[0010] The user interaction layer provides an automaton canvas for creating and modifying finite automata, pushdown automata, Turing machines, and regular models;
[0011] The data processing layer includes a finite automaton simulation module, a pushdown automaton simulation module, a Turing machine and extended Turing machine simulation module, and a regular expression and automaton simulation module, which are used for data processing related to finite automaton simulation, pushdown automaton simulation, Turing machine and extended Turing machine simulation, and regular expression and automaton simulation;
[0012] The middle layer is used to serialize the automaton drawn on the canvas into an automaton file and deserialize the automaton file;
[0013] The storage layer is used to manage the robot files.
[0014] To optimize the above technical solutions, specific measures taken also include:
[0015] The automaton canvas described above includes:
[0016] Canvas operation module, used to move and scale the canvas;
[0017] Status operation module, used to add status, delete status, modify status information, and move status position;
[0018] State transfer operation module, used to add state transfer, delete state transfer, modify state transfer information, and rotate state transfer;
[0019] Overall operation module, used to undo or redo an operation.
[0020] The above-mentioned finite automaton simulation module performs relevant data processing when finite automaton simulation is performed, including:
[0021] (1) Drawing of finite automata, and related specificity drawing of states and state transition functions;
[0022] (2) Detecting the nondeterminism of finite automata;
[0023] (3) Automaton simulation based on input string: accept an input string, start from the initial state and process each character to reach another state until the entire input string is processed. If the current state is in the terminal state, it means that the input string can be accepted by the automaton, otherwise it cannot be accepted;
[0024] (4) The non-deterministic finite automaton NFA is converted to an equivalent deterministic finite automaton DFA:
[0025] For DFA, simulation is performed directly through the transfer function;
[0026] For NFA, convert NFA to DFA so that each input character in the current state has a certain next state, as follows:
[0027] First, calculate the closure ε-closure(s) of each state in NFA. ε-closure(s) represents the set of all states that can be reached from state s by inputting a null character.
[0028] Then start from the closure of the initial state and query the closure of all states in the closure that can be reached by inputting the specified character. If the closure has generated a state in the DFA before, use that state. If not, use the closure to generate a deterministic state in the DFA.
[0029] (5) Minimize the deterministic finite automaton DFA:
[0030] First, divide all state sets of the target automaton into non-terminal state sets and terminal state sets;
[0031] For each non-single element set, determine whether it is divisible. The judgment is based on whether the same state can be reached by inputting the same character for the states in the set. If the same state cannot be reached, it needs to be separated. This cycle is repeated until all state sets are no longer divisible.
[0032] The data processing performed by the above-mentioned pushdown automaton simulation module during pushdown automaton simulation includes:
[0033] (1) Checking the correctness of context-free grammar:
[0034] When inputting a grammar production, check whether the production satisfies the form A→β, β∈(V∪T) * , A∈V, unsatisfied production rules give relevant prompt information;
[0035] (2) Check the sub-types of the grammar:
[0036] Analyze the grammar productions and determine the subtypes into which the grammar can be divided. The subtypes include right-linear grammar, left-linear grammar, regular grammar, CNF, GNF, and context-free grammar.
[0037] (3) Perform CYK algorithm analysis, LL(1) grammar analysis or SLR grammar analysis on the grammar;
[0038] (4) Simplify the grammar: including eliminating ε-productions, eliminating single productions, and eliminating useless symbols;
[0039] If the original grammar can deduce ε, then add the production "S→ε" to the simplified grammar production, where S is the start symbol of the grammar, so that the grammar contains only this ε-production;
[0040] (5) Perform CNF conversion on the grammar: convert all production rules of the grammar into Chomsky normal form;
[0041] (6) Representing context-free languages using pushdown automata (PDA);
[0042] (7) Context-free language pumping lemma game: Use the converse form of the context-free language pumping lemma to determine whether a language is not a context-free language.
[0043] The above-mentioned Turing machine and extended Turing machine simulation module performs relevant data processing when simulating the Turing machine and extended Turing machine:
[0044] (1) Drawing of the classical single-band Turing machine, and specific drawing of states and state transition functions;
[0045] (2) Extended Turing Machine:
[0046] Drawing of Turing machines with subroutines, specific drawing of states and state transition functions;
[0047] Added subroutine state and mixed state transfer function. Supports creation, deletion and renaming of subroutine state, selection of subroutine Turing machine, setting subroutine Turing machine to initial state or cancellation, setting subroutine Turing machine to accept state and cancellation;
[0048] Creation, modification, and deletion of mixed state transfer functions for transferring from the start state of a main program Turing machine to a subroutine state, and from a subroutine state to the return state of the main program Turing machine, or between subroutine states; support for the creation, modification, and deletion of mixed state transfer functions for transferring from a subroutine state to itself;
[0049] (3) Based on the Turing machine simulation of the input string, rewrite the input string:
[0050] The Turing machine starts to receive string input based on the initial state. The state transition function indicates the read character, write character, and next position. If it is L, the previous character is read and recognized and rewritten; if it is R, the next character is recognized and rewritten; if it is S, no operation is performed;
[0051] The termination condition of the Turing machine simulation process can be set to stop at the terminal state. When the next position indicated in the state transfer function is S, it stops at the terminal character. After the simulation is completed, the rewritten string is given.
[0052] The above regular expression and automaton simulation module performs relevant data processing during regular expression and automaton simulation:
[0053] (1)Conversion between regular grammar and regular expression;
[0054] (2) Construct equivalent non-deterministic finite automata ε-NFA and deterministic finite automata DFA containing ε from regular grammar;
[0055] (3) Construct equivalent regular expressions from deterministic finite automata.
[0056] The above-mentioned middle layer and storage layer perform persistent storage of the drawn automaton, as follows:
[0057] The middle layer serializes the automaton drawn on the canvas into Json key-value pairs, and the storage layer stores them as automaton files;
[0058] The middle layer deserializes the automaton files stored in the storage layer, thereby enabling the canvas to be drawn based on the existing automaton.
[0059] The present invention has the following beneficial effects:
[0060] 1. The present invention is based on the Android platform, can realize the visual construction and simulation of various types of automata, realize the persistent storage of model data, and can handle most known errors.
[0061] 2. The present invention has good page interaction function, and the visualized automatic machine construction operation and simulation operation lower the usage threshold and are more suitable for beginners. It is also suitable for teaching demonstrations. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 This is a system architecture diagram of the present invention;
[0063] Figure 2It is the main view interface of the system of the present invention;
[0064] Figure 3 This is the functional activity diagram of the Turing machine subsystem of the system of the present invention;
[0065] Figure 4 A method for creating / modifying a single-band Turing machine model according to an embodiment of the present invention;
[0066] Figure 5 This is a Turing machine model simulation verification method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0068] Although the steps in the present invention are arranged with numbers, they are not intended to limit the order of the steps. Unless the order of the steps is clearly stated or the execution of a step requires other steps as a basis, the relative order of the steps can be adjusted. It is understood that the term "and / or" used herein refers to and covers any and all possible combinations of one or more of the associated listed items.
[0069] like Figure 1 As shown, the formal language and automaton simulation system based on the Android platform of the present invention includes a user interaction layer, a data processing layer, an intermediate layer, and a storage layer based on the Android platform;
[0070] The user interaction layer provides an automaton canvas for creating and modifying finite automata, pushdown automata, Turing machines, and regular models;
[0071] In this embodiment, smartphones typically rely on touchscreens for control, with the most common touch modes limited to single tap, double tap, and long press. However, when designing and drawing an automaton, users often need to add states, transition states, and even move the canvas. Therefore, when implementing automaton drawing, it is necessary to combine limited control methods to create a reasonable interaction method that allows users to easily draw the desired pushdown automaton model.
[0072] Therefore, the present invention provides a method for drawing an automaton on an Android platform through an automaton canvas of a user interaction layer. The automaton canvas includes:
[0073] Canvas operation module: move canvas, scale canvas;
[0074] Status operation module: add status, delete status, modify status information, move status position;
[0075] State transfer operation module: add state transfer, delete state transfer, modify state transfer information, rotate state transfer (only for self-loop state transfer);
[0076] Overall operation module: undo an operation and redo an operation.
[0077] Furthermore, the middle layer serializes the automaton drawn on the canvas into an automaton file, and deserializes the automaton file;
[0078] Storage layer, which saves the automaton files.
[0079] The middle layer and storage layer of the present invention provide the function of persistent storage of the drawn automaton, including:
[0080] Serialize the drawn automaton into Json key-value pairs and then store them as automaton files;
[0081] Deserialize the automaton file to draw based on the existing automaton.
[0082] The data processing layer performs data processing related to finite automaton simulation, pushdown automaton simulation, Turing machine and extended Turing machine simulation, and regular expression and automaton simulation;
[0083] Based on the above basic functions, the data processing layer provides a series of methods for automaton simulation.
[0084] The data processing layer includes finite automaton simulation module, pushdown automaton simulation module, Turing machine and extended Turing machine simulation module, regular expression and automaton simulation module;
[0085] First, the finite automaton simulation module of the present invention provides common and important methods related to finite automata, including:
[0086] (1) Drawing of finite automata, and related specific drawing methods of states and state transition functions.
[0087] (2) Detecting the non-determinism of finite automata. For finite automata, a key step is to determine whether the current finite automaton is deterministic or non-deterministic. This is an indispensable step in the subsequent implementation of functions.
[0088] (3) Automaton simulation based on input string. The automaton can also be called a receiver. Its most basic function is to accept an input string, starting from the initial state and processing each character to reach another state until the entire input string is processed. If the current state is in the terminal state, it means that the input string can be accepted by the automaton, otherwise it cannot be accepted.
[0089] (4) Methods for converting non-deterministic finite automata (NFA) into equivalent deterministic finite automata (DFA).
[0090] For deterministic finite automata, since a certain state can be reached for a certain state and a certain character, it can be simulated directly through the transition function.
[0091] However, for non-deterministic finite automata, there are multiple possible arrival states for the same state and the same input character. In this case, it is no longer possible to simply simulate based on the transition function.
[0092] Convert a nondeterministic finite automaton (NFA) to a deterministic finite automaton (DFA) so that each input character in the current state has a deterministic next state. First, calculate the closure ε-closure(s) of each state in the NFA. ε-closure(s) represents the set of all states that can be reached from state s by inputting a null character. Next, starting from the closure of the initial state, query the closure for all states in that closure that can be reached by inputting a specified character. If the closure has previously generated a state in the DFA, use that state. If not, use this closure to generate a deterministic state in the DFA.
[0093] (5) Methods for minimizing the number of deterministic finite automata. Each deterministic finite automaton corresponds to a unique language, but for a language, there can be multiple deterministic finite automata. Obviously, it is very beneficial to find an automaton that is both simple and requires little space to store its state.
[0094] When minimizing a DFA, the target automaton's state sets are first divided into sets of non-terminal states and sets of terminal states. For each non-single element set, the separability is determined by determining whether the same character input leads to the same state in the set. If the state sets do not reach the same state, they must be separated. This cycle repeats until all state sets are no longer separable.
[0095] At the same time, the pushdown automaton simulation module of the present invention provides common and important formal methods for context-free grammars, including:
[0096] (1) Check the correctness of the context-free grammar. Mainly check whether the production rules satisfy the form A→β, β∈(V∪T) * , A∈V, this will be done when inputting grammar production formulas. Production formulas that do not meet the requirements will not be accepted, and the present invention will give relevant prompt information.
[0097] (2) A method for checking the sub-categories of a grammar. This method mainly analyzes the grammar productions to determine the most detailed category into which the grammar can be divided. The specific categories provided in this invention are: right-linear grammar, left-linear grammar, regular grammar, CNF, GNF, and context-free grammar, a total of 6 categories.
[0098] (3) Methods of performing CYK algorithm analysis, LL(1) grammar analysis or SLR grammar analysis on the grammar.
[0099] (4) Methods for simplification of grammar. Grammar simplification includes eliminating ε-productions, eliminating single productions, and eliminating useless symbols. However, if the original grammar can deduce ε, then add the production "S→ε" to the simplified grammar production, where S is the start symbol of the grammar, so that the grammar only contains this ε-production.
[0100] (5) Method for converting grammar into CNF. Convert all production rules of grammar into Chomsky normal form.
[0101] (6) A method for representing context-free languages using push-down automata (PDA).
[0102] (7) The context-free language pumping lemma game function uses the converse form of the context-free language pumping lemma to determine whether a language is not a context-free language. The user can choose whether the user or the system takes the first step. The user can select a language from the built-in language list to play the game, but cannot enter a language.
[0103] Furthermore, the regular expression and automaton simulation module of the present invention provides a formal method implementation of regular grammar, including:
[0104] (1) Methods for converting regular grammar to regular expressions.
[0105] (2) A method to construct equivalent non-deterministic finite automata (ε-NFA) and deterministic finite automata (DFA) containing ε from regular grammar.
[0106] (3) A method for constructing equivalent regular expressions from deterministic finite automata.
[0107] Finally, the Turing machine and extended Turing machine simulation module of the present invention provide relevant formal methods for implementing Turing machines, including:
[0108] (1) Drawing of the classical single-band Turing machine, and specific drawing methods related to states and state transition functions.
[0109] (2) Extended Turing Machine: Drawing of Turing Machine with Subroutines, specific drawing methods related to states and state transition functions. Add two contents: subroutine states and mixed state transition functions. Support the creation, deletion and renaming of subroutine states, selection of subroutine Turing machines, setting subroutine Turing machines to initial states or cancellation, setting subroutine Turing machines to accept states and cancellation. Support the creation, modification and deletion of mixed state transition functions for transferring from the start state of a main program Turing machine to a subroutine state, from a subroutine state to the return state of the main program Turing machine, or between subroutine states. Support the creation, modification and deletion of mixed state transition functions for transferring from a subroutine state to itself.
[0110] (3) Turing machine simulation based on input string. Unlike the string recognition function of the automaton, the Turing machine will also rewrite the input string. The Turing machine must have an initial state, from which it receives string input. The state transition function indicates the reading of characters, the writing of characters, and the next position. If it is L, the previous character is read for recognition and rewriting; if it is R, the next character is recognized and rewritten; if it is S, no operation is performed. The termination condition of the Turing machine simulation process can be set by the user. It can be set to stop at the terminal state, in the stop state (the next position indicated in the state transition function is S), and stop at the terminal character. After the simulation is completed, the system gives the rewritten string.
[0111] Example
[0112] like Figure 1 As shown, the system architecture of the present invention is divided into four layers: user interaction layer, data processing layer, middle layer, and storage layer. Through the collaboration of these four layers, the present invention implements the model creation functions of finite automata, pushdown automata, Turing machines, and regular expressions, methods for simulating existing automata models, and model file management functions.
[0113] Figure 2 The main view interface of the system of the present invention shown displays the top menu of the system of the present invention, the main interactive interface when the user draws the automaton, and the automaton file list operation interface.
[0114] Figure 3 The overall functional activity diagram of the Turing machine subsystem of the system of the present invention is shown to more finely illustrate the collaboration mode and interaction process among the four levels of the present invention.
[0115] Figure 4This is an embodiment of a method for creating / modifying a single-band Turing machine model, an important function of the Turing machine subsystem of the present invention. Clicking the button indicated by 101 in the toolbar enters the state management state. At this point, a user clicking on the canvas shown in 103 creates a state. 104-106 indicate the three states that can be created by this system. 104 indicates an initial state, 105 indicates a normal state, and 106 indicates an end state. Clicking the button indicated by 102 in the toolbar enters the state transition function management state. At this point, the user can create a state transition function between any states in the canvas shown in 103. 107-108 indicate two state transition functions that can be created by this system. 107 is a state transition function between two created states, indicating that transitions can be made from one state to another based on the definition of the state transition function and the received data. 108 is a self-state transition function within a single created state, indicating that the current state can be maintained unchanged based on the definition of the state transition function and the received data.
[0116] Figure 5 This is an important function of the Turing machine subsystem in the present invention: a schematic diagram of simulating a Turing machine model, wherein the area shown in 201 is an observation window for the Turing machine simulation state, in which a snapshot of the Turing machine model being simulated will be displayed, and the currently executed Turing machine state will be highlighted. The entry shown in 202 will display the state name of the currently executed Turing machine state. The operations on the current state in area 201 and entry 202 are all to assist the user in quickly locating the current simulation state. The entry shown in 203 is a simulation data input bar, and the user needs to enter simulation data in this area in order to perform a simulation run of the Turing machine model. The entry shown in 204 is a simulation data output bar, and when the user enters data and chooses to simulate, the simulation results will be displayed in this bar. The red block in the output indicates the position processed after the run. It is convenient for users to quickly locate the end state of the simulation.
[0117] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims, not the foregoing description, and all variations within the meaning and range of equivalents of the claims are intended to be included therein. Any reference sign in a claim should not be construed as limiting the claim to which it relates.
[0118] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
Claims
1. Formal language and automaton simulation system based on Android platform, characterized by: Including user interaction layer, data processing layer, middle layer and storage layer based on Android platform; The user interaction layer provides an automaton canvas for creating and modifying finite automata, pushdown automata, Turing machines, and regular models; The data processing layer includes a finite automaton simulation module, a pushdown automaton simulation module, a Turing machine and extended Turing machine simulation module, and a regular expression and automaton simulation module, which are used for data processing related to finite automaton simulation, pushdown automaton simulation, Turing machine and extended Turing machine simulation, and regular expression and automaton simulation; The middle layer is used to serialize the automaton drawn on the canvas into an automaton file and deserialize the automaton file; Storage layer, used to manage automaton files; The finite automaton simulation module performs relevant data processing when finite automaton simulation is performed, including: (1) Drawing of finite automata, and related specificity drawing of states and state transition functions; (2) Detecting the nondeterminism of finite automata; (3) Automaton simulation based on input string: accept an input string, start from the initial state and process each character to reach another state until the entire input string is processed. If the current state is in the terminal state, it means that the input string can be accepted by the automaton, otherwise it cannot be accepted; (4) The non-deterministic finite automaton NFA is converted to an equivalent deterministic finite automaton DFA: For DFA, simulation is performed directly through the transfer function; For NFA, convert NFA to DFA so that each input character in the current state has a certain next state, as follows: First, calculate the closure ε-closure(s) of each state in NFA. ε-closure(s) represents the set of all states that can be reached from state s by inputting a null character. Then, starting from the closure of the initial state, query the closure of all states in the closure that can be reached by inputting the specified character. If the closure has generated a state in the DFA before, then use that state. If not, use the closure to generate a deterministic state in the DFA. (5) Minimize the deterministic finite automaton DFA: First, divide all state sets of the target automaton into non-terminal state sets and terminal state sets; For each non-single element set, determine whether it is divisible. The judgment is based on whether the same state can be reached by inputting the same character for the states in the set. If the same state cannot be reached, it needs to be separated. This cycle is repeated until all state sets are no longer divisible.
2. The formal language and automaton simulation system based on the Android platform according to claim 1, characterized in that: The automaton canvas includes: Canvas operation module, used to move and scale the canvas; Status operation module, used to add status, delete status, modify status information, and move status position; State transfer operation module, used to add state transfer, delete state transfer, modify state transfer information, and rotate state transfer; Overall operation module, used to undo or redo an operation.
3. The formal language and automaton simulation system based on the Android platform according to claim 1, characterized in that: The pushdown automaton simulation module performs data processing when simulating the pushdown automaton, including: (1) Checking the correctness of context-free grammar: When inputting a grammar production, check whether the production satisfies the form A→β, β∈(V∪T) * , A∈V, unsatisfied production rules give relevant prompt information; (2) Check the sub-types of the grammar: Analyze the grammar productions and determine the subtypes into which the grammar can be divided. The subtypes include right-linear grammar, left-linear grammar, regular grammar, CNF, GNF, and context-free grammar. (3) Perform CYK algorithm analysis, LL(1) grammar analysis or SLR grammar analysis on the grammar; (4) Simplify the grammar: including eliminating ε-productions, eliminating single productions, and eliminating useless symbols; If the original grammar can deduce ε, then add the production "S→ε" to the simplified grammar production, where S is the start symbol of the grammar, so that the grammar contains only this ε-production; (5) Perform CNF conversion on the grammar: convert all production rules of the grammar into Chomsky normal form; (6) Representing context-free languages using pushdown automata (PDA); (7) Context-free language pumping lemma game: Use the converse form of the context-free language pumping lemma to determine whether a language is not a context-free language.
4. The formal language and automaton simulation system based on the Android platform according to claim 1, characterized in that: The Turing machine and extended Turing machine simulation module performs relevant data processing when simulating the Turing machine and extended Turing machine: (1) Drawing of the classical single-band Turing machine, and specific drawing of states and state transition functions; (2) Extended Turing Machine: Drawing of Turing machines with subroutines, specific drawing of states and state transition functions; Added subroutine state and mixed state transfer function, supporting the creation, deletion and renaming of subroutine states, selection of subroutine Turing machines, setting subroutine Turing machines to initial state or cancellation, setting subroutine Turing machines to accept state and cancellation; Creation, modification, and deletion of mixed state transfer functions for transferring from the start state of a main program Turing machine to a subroutine state, and from a subroutine state to the return state of the main program Turing machine, or between subroutine states; support for the creation, modification, and deletion of mixed state transfer functions for transferring from a subroutine state to itself; (3) Based on the Turing machine simulation of the input string, rewrite the input string: The Turing machine starts to receive string input based on the initial state. The state transition function indicates the read character, write character, and next position. If it is L, the previous character is read and recognized and rewritten; if it is R, the next character is recognized and rewritten; if it is S, no operation is performed; The termination condition of the Turing machine simulation process can be set to stop at the terminal state. When the next position indicated in the state transfer function is S, it stops at the terminal character. After the simulation is completed, the rewritten string is given.
5. The formal language and automaton simulation system based on the Android platform according to claim 1, characterized in that: The regular expression and automaton simulation module performs relevant data processing when performing regular expression and automaton simulation: (1)Conversion between regular grammar and regular expression; (2) Construct equivalent non-deterministic finite automata ε-NFA and deterministic finite automata DFA containing ε from regular grammar; (3) Construct equivalent regular expressions from deterministic finite automata.
6. The formal language and automaton simulation system based on the Android platform according to claim 1, characterized in that: The middle layer and storage layer perform persistent storage on the drawn automaton, as follows: The middle layer serializes the automaton drawn on the canvas into Json key-value pairs, and the storage layer stores them as automaton files; The middle layer deserializes the automaton files stored in the storage layer, thereby enabling the canvas to be drawn based on the existing automaton.