Reliable Java program automatic generation method based on Event-B

The Event-B model is translated into a Java program with JML annotations through the EB2Prog operator, which solves the problems of insufficient automation and limited syntax support in the existing technology, and realizes the seamless transition and coding of the Event-B model to Java code. Reliability, improving development efficiency and tool availability.

CN118733058AInactive Publication Date: 2024-10-01CHINA RAILWAY LIUYUAN GRP CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411232515.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-10-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing Java code generation tools based on the Event-B model are not automated enough and have limited syntax support, resulting in users requiring a lot of manual intervention and model refinement, which affects the usability and development efficiency of the tool.

Method used

The Event-B model is translated into a Java program with JML annotations through the EB2Prog operator. It uses automated translation rules and auxiliary operators to ensure the consistency of event and machine semantics, supports accurate translation of complex structures, and uses JML annotations to verify the generated code. Correctness.

Benefits of technology

It achieves a seamless transition from Event-B model to Java code, improves the automation level and syntax support scope, ensures the integrity and accuracy of model translation, reduces user intervention, and improves development efficiency and code reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733058A_ABST
    Figure CN118733058A_ABST
Patent Text Reader

Abstract

The invention discloses a reliable Java program automatic generation method based on Event-B. An operator EB2Prog is adopted to translate EB into a Java program with JML annotations, the operator EB2Prog uses an operator EB2Java to obtain a translated Java part, and an operator EB2Jml is used to obtain a JML part; a machine is translated into a Java class according to the translation rule that the machine is translated into two parts of translation E of an event and translation of the machine, and the machine is translated into a Java class containing a JML class and a method specification, including declared variables and translation of a watched context; each event is translated into a separate Java class, including an object reference to a machine class. According to the method, seamless transition from abstraction to codes is realized on the premise that the event and machine semantics are kept consistent, and a complex structure in the EB event is efficiently and accurately translated into Java.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of automatic code generation and relates to a reliable Java program automatic generation method based on Event-B. Background Art

[0002] Event-B is a formal modeling language for reactive systems and a formal software development methodology in which software systems are initially conceived in a very abstract way and then refined into code.

[0003] Directly generating code from the verified Event-B model can ensure consistency between the implementation and the original verified model, which reduces the risk of manual coding errors and implementation deviations. The use of automatic code generation can reduce the manual workload from abstract models to specific implementations and improve development efficiency, especially when complex systems are involved.

[0004] Dalvandi et al. [Dalvandi M, Butler M, Salehi Fathabadi A. SEB-CG: Code generation tool with algorithmic refinement support for Event-B[C] / / FormalMethods. FM 2019 International Workshops: Porto, Portugal, October 7–11,2019, Revised Selected Papers, Part I 3. Springer International Publishing,2020: 19-29.] improved Event-B to address the difficulty of handling sequential structures. ScheduledEvent-B (SEB for short) is an extension of Event-B that enhances the model by adding control structures and supports the gradual introduction of control structures in the refinement step. SEB-CG is a tool that automatically generates executable code from SEB and can convert the model into code in the target programming language. The tool provides facilities for inferring the algorithmic structure of the program through refinement. The flexible and configurable design of the tool enables it to target a variety of programming languages.

[0005] Mery and Singh [Singh NK, Singh N K. EB2ALL: an automatic code generation tool[J]. Using Event-B for Critical Device Software Systems, 2013:105-141.] presented the EB2ALL plug-in toolset, which machine-translates Event-B into several different languages: C, C++, Java, and C. EB2ALL only supports a small subset of Event-B syntax, and users are required to write their final Event-B refinements in the syntax supported by the tool.

[0006] Ostroumov and Tsiopoulos [Ostroumov S, Tsiopoulos L. VHDL code generationfrom formal Event-B models[C] / / 2011 14th Euromicro Conference on DigitalSystem Design. IEEE, 2011: 127-134.] proposed an EHDL tool prototype for generating VHDL code from Event-B models. The tool supports a reduced syntax, and the user must first extend the Event-B model before translating it. Wright [Wright S. Automatic generation of C from Event-B[C] / / Workshop onintegration of model-based formal methods and tools. 2009: 14.] defined a B2C extension of the Rodin platform to convert Event-B models into C code.

[0007] In summary, the shortcomings of existing Java code automatic generation tools based on Event-B model are mainly reflected in the following two aspects: 1. Not fully automatic Current tools have not yet achieved tool automation and still require active user intervention. The B2C extension tool still requires users to decompose the Event-B model and refine the allocation of uncertainty; SEB requires users to manually adjust the task flow in the plug-in; Gene-Auto needs to verify the model at a higher level of abstraction, adding additional steps.

[0008] 2. Limited syntax support Current code generation tools have limited support for executable code syntax. For example, MEB2ALL only supports a small subset of Event-B syntax, limiting the user's ability to write the final implementation; the JML2B tool converts in the opposite direction and cannot directly verify the correctness of the model; the EHDL prototyping tool supports a simplified subset of Event-B syntax, but the user needs to expand the model to translate it. Summary of the invention

[0009] Event-B is a formal modeling language for responsive systems and a formal software development method. It allows the system to be conceived in a highly abstract way and then gradually refined into code. The current work of automatically generating executable code from the Event-B model has four main deficiencies. First, the automation level of the tool is not enough, and users need to perform a lot of manual intervention. For example, the B2C extension tool requires users to decompose the Event-B model and refine non-deterministic allocations; the current code generation tools have less support for the syntax of executable code. EB2ALL only supports a small subset of Event-B syntax, and the JML2B tool converts in the opposite direction and cannot directly verify the correctness of the model. These problems seriously affect the usability of the tool and increase the burden on developers. Only by improving the level of automation, expanding the scope of syntax support, and ensuring the integrity and accuracy of model translation can a more efficient and reliable solution be provided for train sensor data acquisition and processing.

[0010] The purpose of the present invention is to provide a reliable Java program automatic generation method based on Event-B, which solves the problems of incomplete automation and limited grammar support in the prior art.

[0011] The present invention is achieved through the following technical solutions: A reliable Java program automatic generation method based on Event-B, using operator EB2Prog, responsible for translating Event-B into Java program with JML annotations, EB2Prog uses operator EB2Java to obtain the translated Java part, and uses operator EB2Jml to obtain the JML part; The machine is translated into a Java class, and the translation rule M is: the translation E of the machine into events and the translation of the machine itself. The machine itself is translated into a Java class containing JML class and method specifications, including the translation of declared variables and the context viewed; each event is translated into a separate Java class containing an object reference to the machine class.

[0012] Further, the Java translation of the machine includes the translation of the set of carriers, constants and axioms defined in the context viewed by the machine, and also includes the translation of variables and constraints declared in the machine, where: Translate carrier sets and constants into class attributes and constrain these attributes for validation, where carrier sets are translated into sets of integers; Translate axioms into static invariants; Translate machine variables into class attributes; Translate invariants into JML invariants; The variation is translated by EB2Prog into a method that returns the translation result of event E; The auxiliary operator TypeOf translates the type of a variable or constant into the Java representation of that type. The function AxiomTheoremValue <type>Returns a value of type Type that conforms to the axioms defined in the context seen by the machine. The auxiliary operator Pred is used to translate predicates and variations. The auxiliary operator FreeVar returns the set of free variables in a variation.

[0013] Furthermore, events include initialization events, standard events, convergence events, or expected events. The specific translation rules are as follows: The initialization event of the machine, which assigns initial values ​​to the state variables, is translated by EB2Jml into a Java class constructor and a JML postcondition, which is translated by EB2Java into the body of the constructor and serves as the Java code that initializes the machine object; The translation rules of standard events are as follows: for subclasses of the Java `Thread` class, non-mutually exclusive event guard conditions are translated by overriding the `run()` method; mutually exclusive guard conditions are translated without overriding the `run()` method of the `Thread` class and forced to execute in sequence; the class generated by the translated event includes a reference to the machine class implementation and the following three methods: the `guard_evt` method is used to detect whether the guard condition of the event is met, the `run_evt` method is used to simulate the execution of the event, and the `run()` method overrides the corresponding Java `Thread` method; Convergent event translation is based on the standard event rules and monotonically reduces the variation; The translation of expected events is based on the standard event rules, without adding any variations.

[0014] Furthermore, the `run_evt` method uses reentrant locks from the Java concurrency library to execute within `lock` and `unlock` instructions.

[0015] Furthermore, the variables defined by the `any` structure in the event parameter definition are translated into parameters of the `run_evt` and `guard_evt` methods, and the `GuardValue` in the `run()` method <type>The .next() expression returns a random value of type Type in the event's guard condition. The auxiliary operator Mod calculates the set of variables assigned in the event action. The auxiliary operator Mod is used to return a set of variables that a Java method can assign values ​​to.

[0016] Furthermore, the JML specification of the `run_evt` method has two cases: In the first case, the `GuardValue <type>The .next()` expression returns a random value of type `Type` that satisfies the guard condition of the event. The post-state of the method must satisfy the translation of the event action and the translation of the variable restriction. In the second case, the `GuardValue` in the `run()` method <type>The .next()` expression returns a random value of type `Type` which does not satisfy the event's guard condition. The method must not modify any fields to ensure that the subsequent state is the same as the previous state.

[0017] Furthermore, the event body contains deterministic and non-deterministic assignments. On the one hand, the non-deterministic and deterministic assignments are translated into JML and used in the postconditions of JML methods. The deterministic assignment `:=` is represented in JML by the `ensures` keyword and the `\old` expression; the non-deterministic assignment `:|` is represented in JML by the `ensures` keyword and the existential quantifier `\exists`; on the other hand, the non-deterministic and deterministic assignments are translated into Java and used by the `Any` rule to translate the event body, `PredicateValue <type>()` returns a value of type `Type` that satisfies the predicate.

[0018] Furthermore, simultaneous assignments in the event body are translated separately and then the results are merged, and the assignments are translated into both JML and Java at the same time.

[0019] Compared with the prior art, the present invention has the following beneficial effects: The present invention ensures a seamless transition from abstraction to code by completely translating the Event-B model into Java code with JML annotations while maintaining event and machine semantic consistency. By introducing automated translation rules and auxiliary operators, the complex structures in Event-B events, including guard conditions, variables, simultaneous assignments and other logics, can be efficiently and accurately translated into Java, and JML annotations are used to verify that the generated Java code is consistent with the specifications of the original Event-B model. This method enables users to fully verify the correctness of the model during the system design phase, ensuring that the final code implementation meets the design intent, and provides a reliable technical foundation for the development of safety-critical systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.

[0021] Figure 1 The figure is a schematic diagram of a flow chart of an embodiment of the method of the present invention. DETAILED DESCRIPTION

[0022] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to be able to fully convey the scope of the present invention to those skilled in the art. It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

[0023] like Figure 1 As shown, the present invention translates Event-B into Java and JML through three operators EB2Prog, EB2Java and EB2Jml, and uses grammar rewriting rules to define them. The main operator is EB2Prog, which is responsible for translating Event-B into a Java program with JML annotations. EB2Prog uses EB2Java to obtain the Java part of the translation, and uses EB2Jml to obtain the JML part. For example, the constraints in Event-B are only translated into JML specifications, so EB2Jml has rules for constraints, while EB2Java does not. On the other hand, the translation of constants includes Java parts and JML parts, so the constant rules in EB2Prog involve EB2Java and EB2Jml rules.

[0024] The translation also uses the following auxiliary operators: Mod returns a set of variables that a Java method can assign values ​​to; Pred translates the predicate or mutation in Event-B; TypeOf returns the type of a variable or constant; FreeVar returns the set of free variables in the mutation; Stat1 and Stat2 specify the state transitions in the expected event and convergent event by non-increment and only decrement of the mutation, respectively.

[0025] Event-B machine is translated into a Java class. When translating a machine, EB2Prog considers not only the information provided by the machine, but also the context it sees. The translation rule M is: Translate the machine into two parts: the translation E of the event and the translation of the machine itself. The machine is translated into a Java class containing JML classes and method specifications. Each event is translated into a separate Java class containing an object reference to the machine class. The translation of the machine includes the translation of the context it sees. Therefore, the Java translation of the machine includes the translation of carrier sets, constants, and axioms defined in the machine context, as well as the translation of variables and constraints declared in the machine. The initialization event is translated into the postcondition B1 of the JML machine class constructor and as the Java code B2 to initialize the machine object. The content of the machine translation rule M is as follows:

[0026]

[0027]

[0028] Refinements are translated the same way as abstract machines, in that Rodin will correctly add abstract machine components to the internal representation of the refined machine. Refinement and extension events (defined by refines and extends, respectively) are translated the same way as abstract events.

[0029] Translate carrier sets and constants into class attributes and constrain these attributes for validation. Therefore, carrier sets are translated as class attributes, with history constraints added to prevent any changes to their values. Since there is no type information for carrier sets, they are translated into integer sets.

[0030]

[0031] Constants are translated in a similar way to carrier sets, except that the values ​​of constants in Event-B are constrained by axioms. The auxiliary operator TypeOf translates the type of an Event-B variable or constant into the Java representation of that type. Function AxiomTheoremValue <type>Returns a value of type Type that conforms to the axioms defined in the context as seen by the machine.

[0032]

[0033] Since axioms are primarily used to specify properties of constants and carrier sets, they are translated into static invariants. JML static invariants can only refer to static fields, in a way that is consistent with the way constants and carrier sets are translated into static fields. Translating axioms into static invariants makes it more explicit, so axioms do not refer to machine variables.

[0034]

[0035] Machine variables are translated into class attributes. The JML keyword spec_public makes a protected or private attribute or method public to any JML specification.

[0036]

[0037] In Event-B, every event must preserve the invariants of the machine. In JML, invariants specify properties that must hold in every visible state of the system, in particular after the execution of a class's constructor and after the termination of a method. This is semantically equivalent to combining invariants with postconditions of every method and constructor. Since initialization events are translated as postconditions of class constructors, and actions of other events are translated as postconditions of the "atomic" run_evt method, Event-B invariants naturally translate into JML invariants.

[0038]

[0039] The translation rules of standard events are as follows: the JAVA code with JML annotations is obtained by translating after calling the EB2Prog operator.

[0040]

[0041]

[0042]

[0043] The machine includes a special initialization event that assigns initial values ​​to state variables. This event is translated by EB2Jml into a postcondition of the Java class constructor (translated by the machine) and by EB2Java into the body of the constructor. Both translations assign initial values ​​to the translations of the machine variables.

[0044]

[0045] In addition to standard events, non-initialized Event-B events also include convergence events or expected events. Convergence events are used to model terminating systems, while expected events represent abstract behaviors that will be clarified in future refinements. Convergence events must monotonically reduce the machine variant (an expression of natural numbers), while expected events cannot increase the machine variant. Convergence or expected events in Event-B are only enabled when the variable value is non-negative. The variant of Event-B "variant E(s,c,v)" is translated by EB2Prog into a method that returns the translation result of event E.

[0046]

[0047] The following rules Status1 and Status2 are used to impose variable-related conditions on the guard and action of convergent and expected events. Translating variants in this way allows users to verify that the implementation of custom methods is consistent with the translated event meaning. For example, since the translation of convergent events mentions the translation of variables in the postconditions of its JML specification, users can use JML tools to verify that the customized implementation actually reduces the variable. The return type of the method `variant()` above is `int`. This, together with the Status1 rule in the Any rule, ensures that the variable is a natural number expression required by Event-B.

[0048]

[0049] Standard events are translated into subclasses of the Java `Thread` class, which means that each event is treated as a thread and can take advantage of Java's thread management capabilities to perform concurrent operations. This conversion allows concurrent events in the Event-B model to be implemented and simulated in a Java environment.

[0050] In Event-B, non-mutually exclusive event guard conditions allow events to be executed alternately, while mutually exclusive guard conditions force events to run in order. The latter is translated without overriding the `run()` method of the `Thread` class to force sequential execution. The former is translated by overriding the `run()` method, as described below. The translation of standard events is defined by the `Any` rule. The class generated by the translated event includes a reference to the machine class implementation and three methods: the `guard_evt` method is used to detect whether the guard condition of the event `evt` is satisfied, the `run_evt` method is used to simulate the execution of `evt`, and the `run()` method overrides the corresponding Java `Thread` method. The `run_evt` method is atomic and it uses a reentrant lock from the Java concurrency library to execute in the `lock` and `unlock` instructions. In testing, using a reentrant lock in this way reduces CPU usage compared to using Java synchronization methods, and the execution time is faster than using the Bakery algorithm implementation using synchronization methods or locks. In addition, the constructor of the reentrant lock class accepts an optional fairness parameter that reduces the probability of any thread starvation.

[0051] The variables qualified by the `any` structure in the event are translated into parameters of the `run_evt` and `guard_evt` methods. The `GuardValue` in the `run()` method <type>The .next() expression returns a random value of type Type from the event's guard condition. The auxiliary operator Mod evaluates the set of variables assigned in the event's action.

[0052] The JML specification of the `run_evt` method has two cases. In the first case, the translation of the guard condition is satisfied (and the current values ​​of the variables are non-negative for convergent and expected events), and the method's post-state must satisfy the translation of the event action and the translation of the variable constraints. In the second case, the translation of the guard condition is not satisfied, and the method must not modify any fields, ensuring that the post-state is the same as the pre-state. This conforms to the semantics of Event-B: if the guard condition of an event is not satisfied, the event cannot execute and therefore cannot modify the system state. Since the effective precondition of a JML method with multiple specification cases (separated by `also` in JML) is the disjunction of the preconditions of each case, the precondition of the `run_evt` method is always true. Therefore, although we translate the guard condition into a precondition, no method in the translation result has a precondition, but rather the translation of the guard condition determines the behavior that the method must exhibit.

[0053] An event body may contain many deterministic and non-deterministic assignments. In Event-B, the symbol `:|` represents a non-deterministic assignment. Non-deterministic assignments generalize deterministic assignments (implemented by `:=`). For example, `v:=v+w` can be expressed as `v:|v'=v+w`, where `v'` is the value of `v` after the assignment. The first rule `NAsg` and the first rule `Asg` below translate non-deterministic and deterministic assignments into JML, respectively. They are used in the postcondition of a JML method. The JML translation of the non-deterministic assignment `v:|P` is a JML existential quantifier expression. The expression `\old(P)` ensures that `P` is evaluated in the before state of the method. This conforms to the assignment semantics in Event-B, where the left side of the assignment assigns the value of the right side expression evaluated in the before state. The `v.equals(v')` and `v.equals(\old(E))` expressions ensure that the value of the variable `v` in the after state is correctly represented.

[0054] The second rule `NAsg` and the second rule `Asg` below translate non-deterministic and deterministic assignments into Java respectively. They are used by the parameter definition `Any` rule to translate the body of the event. `PredicateValue <type>(P)` returns a value of type `Type` that satisfies the predicate `P`.

[0055]

[0056] Simultaneous assignments in event bodies are translated separately and the results are merged. Assignments are translated into both JML and Java. For example, a pair of simultaneous operations `x:=y||y:=x` is translated into a JML postcondition `x==\old(y)&&y==\old(x)` for variables `x` and `y` of type integer.

[0057]

[0058] In Java, simultaneous operations are implemented by first evaluating the right side of each assignment into a temporary variable. The Java translation of `x:=y||y:=x` is:

[0059] Some Event-B constructs cannot be translated into Java or JML for various reasons. For example, the `with` construct is used in the definition of a refined event as a "witness" for a vanishing abstract (refined) event variable. The witness predicate specifies how the refined event implements the vanishing variable. Witnesses act like "glue invariants" for events. The witness for an abstract event variable `x` is a predicate `P(x)` involving `x`. A deterministic witness for a variable `x` is an equality predicate `x=E`, where `E` is an expression that does not contain `x`. Since Rodin ensures that `x` does not appear in a refined event (`x` is replaced by `E`), there is no need to translate witnesses into Java or JML.

[0060] The following are specific application cases: The Event-B model machine part code for binary search in sorted array:

[0061]

[0062]

[0063] The EventB2Java tool of the present invention is used to generate code:

[0064]

[0065]

[0066]

[0067]

[0068]

[0069]

[0070]

[0071]

[0072]

[0073] The present invention proposes a method for completely translating an Event-B model into a Java program annotated with JML, and implements the method as an EventB2Java tool. Most of the Java code generators of EventB2Java support Event-B syntax and can be used to translate abstract and refined Event-B models. Through the generated code, users can verify whether the behavior of the system meets expectations, so as to correct errors and add functions in time during the further development of the model. In addition, it can generate sequential or multi-threaded Java implementations of Event-B models.

[0074] Another key feature of tool translation is the generation of JML formal specifications together with Java code, allowing users to write custom code and verify its correctness using existing JML tools. In case studies, EventB2Java can help develop Android applications based on the MVC pattern through testing, as well as help improve the Tokeneer safety-critical system model to comply with the system test specification.

[0075] Through the testing of 9 Event-B models and 6 benchmarks, it is proved that EventB2Java, as an effective code generation tool, can seamlessly integrate Event-B models and Java code, realize the complete development chain from model to code, and provide solid technical support for the responsive design and development of complex systems.

[0076] The present invention has been described in detail above through embodiments, but the contents described are only exemplary embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. The protection scope of the present invention is defined by the claims. Anyone who utilizes the technical solution described in the present invention, or a technician in the field, inspired by the technical solution of the present invention, designs a similar technical solution within the essence and protection scope of the present invention to achieve the above technical effects, or makes equal changes and improvements to the scope of application, shall still belong to the scope of protection covered by the patent of the present invention. It should be noted that in order to make a clear statement, the description of some components and processes that have no direct and obvious connection with the scope of protection of the present invention but are known to those skilled in the art are omitted in the description of the present invention.< / type> < / type> < / type> < / type> < / type> < / type> < / type> < / type>

Claims

1. A reliable Java program automatic generation method based on Event-B, characterized in that: Operator EB2Prog is used to translate Event-B into a Java program with JML annotations. EB2Prog uses operator EB2Java to obtain the Java part of the translation and operator EB2Jml to obtain the JML part. The machine is translated into a Java class, and the translation rule M is: the translation E of the machine into events and the translation of the machine itself. The machine itself is translated into a Java class containing JML class and method specifications, including the translation of declared variables and the context viewed; each event is translated into a separate Java class containing an object reference to the machine class.

2. According to the Event-B based reliable Java program automatic generation method of claim 1, it is characterized in that: The machine's Java translation includes the translation of the set of vectors, constants, and axioms defined in the context viewed by the machine, and also includes the translation of variables and constraints declared in the machine, where: Translate carrier sets and constants into class attributes and constrain these attributes for validation, where carrier sets are translated into sets of integers; Translate axioms into static invariants; Translate machine variables into class attributes; Translate invariants into JML invariants; The variation is translated by EB2Prog into a method that returns the translation result of event E; The auxiliary operator TypeOf translates the type of a variable or constant into the Java representation of that type. The function AxiomTheoremValue <type> Returns a value of type Type that conforms to the axioms defined in the context seen by the machine. The auxiliary operator Pred is used to translate predicates and variations. The auxiliary operator FreeVar returns the set of free variables in a variation.< / type> 3. The method for automatically generating reliable Java programs based on Event-B according to claim 1, characterized in that: Events include initialization events, standard events, convergence events, or expected events. The specific translation rules are as follows: The initialization event of the machine, which assigns initial values ​​to the state variables, is translated by EB2Jml into a Java class constructor and a JML postcondition, which is translated by EB2Java into the body of the constructor and serves as the Java code that initializes the machine object; The translation rules of standard events are as follows: for subclasses of the Java `Thread` class, non-mutually exclusive event guard conditions are translated by overriding the `run()` method; mutually exclusive guard conditions are translated without overriding the `run()` method of the `Thread` class and forced to execute in sequence; the class generated by the translated event includes a reference to the machine class implementation and the following three methods: the `guard_evt` method is used to detect whether the guard condition of the event is met, the `run_evt` method is used to simulate the execution of the event, and the `run()` method overrides the corresponding Java `Thread` method; Convergent event translation is based on the standard event rules and monotonically reduces the variation; The translation of expected events is based on the standard event rules, without adding any variations.

4. The method for automatically generating reliable Java programs based on Event-B according to claim 3 is characterized in that: The `run_evt` method uses a reentrant lock from the Java concurrency library to execute within the `lock` and `unlock` instructions.

5. The method for automatically generating reliable Java programs based on Event-B according to claim 3, characterized in that: The definition of the parameters in the event `any` structure is translated into the parameters of the `run_evt` and `guard_evt` methods. The `GuardValue` in the `run()` method <type> The .next() expression returns a random value of type Type in the event's guard condition. The auxiliary operator Mod calculates the set of variables assigned in the event action. The auxiliary operator Mod is used to return a set of variables that a Java method can assign values ​​to.< / type> 6. The method for automatically generating reliable Java programs based on Event-B according to claim 5, characterized in that: The JML specification of the `run_evt` method has two cases: In the first case, the `GuardValue` in the `run()` method <type>The .next()` expression returns a random value of type `Type` that satisfies the guard condition of the event. The post-state of the method must satisfy the translation of the event action and the translation of the variable restriction. In the second case, the `GuardValue` in the `run()` method <type>The .next() expression returns a random value of type Type. The guard condition of the event is not satisfied. The method must not modify any fields to ensure that the subsequent state is the same as the previous state.< / type> < / type> 7. The method for automatically generating reliable Java programs based on Event-B according to claim 3, characterized in that: The event body contains deterministic and non-deterministic assignments. On the one hand, the non-deterministic and deterministic assignments are translated into JML and used in the postconditions of JML methods. The deterministic assignments `:=` are represented in JML by the `ensures` keyword and the `\old` expression; the non-deterministic assignments `:|` are represented in JML by the `ensures` keyword and the existential quantifier `\exists`; on the other hand, the non-deterministic and deterministic assignments are translated into Java and used by the `Any` rule to translate the event body, `PredicateValue <type> ()` returns a value of type `Type` that satisfies the predicate.< / type> 8. The method for automatically generating reliable Java programs based on Event-B according to claim 7, characterized in that: Simultaneous assignments in the event body are translated individually and then the results are merged; the assignments are translated into both JML and Java at the same time.

Citation Information

Patent Citations

  • Verification system for Java program runtime capable of deploying rules dynamically

    CN104765688A

  • JAVA code generation tool based on EPF

    CN114780071A