Automated adaptation of embedded software

A method using a machine learning model to generate and test code elements for cyber-physical systems ensures reliable and accurate software updates, addressing maintenance challenges and ensuring compliance with interface criteria.

JP2025188059APending Publication Date: 2025-12-25ROBERT BOSCH GMBH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2025099570
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-14
Filing Date
2025-06-13
Publication Date
2025-12-25

AI Technical Summary

Technical Problem

Existing software, particularly embedded software for cyber-physical systems like vehicles and robots, is difficult to maintain due to its complexity, and machine learning models generate code elements that may be non-compilable or fail to meet requirements, lacking reliability and accuracy.

Method used

A method using a machine learning model to generate code elements based on linguistic specifications and interface testing criteria, followed by rigorous testing to ensure compliance, and optionally incorporating the elements into the software, with further training of the model based on testing results.

Benefits of technology

Ensures reliable and accurate generation of code elements that meet interface criteria, improving software quality and reducing maintenance effort, enabling frequent and easy code revisions while maintaining software integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025188059000001_ABST
    Figure 2025188059000001_ABST
Patent Text Reader

Abstract

To provide a computer-implemented method for automated generation of a code element of a software code.SOLUTION: The method includes: generating, via a machine learning model, the code element based upon a language specification for the code element to be created and upon an interface test criterion that is to be satisfied by the code element to be created, optionally where a prompt to the machine learning model includes the language specification and the interface test criterion; and testing whether the code element satisfies the interface test criterion, thus providing a test result.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] Prior art Software, e.g., embedded software, for controlling, regulating, and / or monitoring technical systems, especially cyber-physical systems, such as computing units of vehicles and / or robots, usually has a high degree of complexity, which makes it difficult for individual software engineers and even entire software development departments to maintain visibility into the software and its changes, especially during its entire life cycle (development, testing, production, and maintenance).

[0002] Throughout its lifecycle, and especially during the development and testing phases, software may need to be adjusted and / or rewritten. For example, identified errors or vulnerabilities must be continually eliminated and / or the software must be adjusted to new and / or changed features. It may also be desirable to adapt the code in light of changed boundary conditions regarding execution time, memory usage, readability, and / or maintainability. [Background technology]

[0003] A machine learning model, in particular a foundation model or a large-scale language model (LLM), can generate code or parts of code (hereinafter referred to as code elements) based on prompts, e.g., instructions in natural language to the machine learning model. This can be used, for example, to extend or refactor existing code by one or more code elements, i.e., to replace one or more existing parts of code with one or more code elements, in particular with respect to changed boundary conditions.

[0004] However, because machine learning models can hallucinate, there has traditionally been a lack of guarantees regarding the accuracy of code elements generated by the machine learning model and / or that such code elements fit for and within the code. The generated code may, for example, be non-compilable, or requirements placed on the code may not be met or may not be fully met. Summary of the Invention [Problem to be solved by the invention]

[0005] The problem underlying this disclosure is therefore to be able to automatically, yet reliably, revise the code of a piece of software, and thus to generate appropriate code elements for the code. [Means for solving the problem]

[0006] Disclosure of the Invention A first general aspect of the present disclosure relates to a computer-implemented method for automatically generating code elements of software code. The method includes generating the code elements via a machine learning model based on a linguistic specification of the code elements to be created and interface testing criteria to be satisfied by the code elements to be created. Prompts to the machine learning model may include the linguistic specification and the interface testing criteria. The method further includes testing whether the code elements satisfy the interface testing criteria, resulting in a testing result.

[0007] The software may be configured to control, regulate and / or monitor at least one computing unit of a technical system, in particular a cyber-physical system, in particular a vehicle and / or a robot. In particular, the software may be embedded software. The method may be implemented in an electronic programming environment.

[0008] The method may further comprise, at least if the test result is sufficiently positive, incorporating the code element into the code, resulting in a revised code. The code may be extended by the code element or a previous code element in the code may be replaced by the code element. The method may further comprise executing the revised code (in compiled form) in a computing unit of a technical system, in particular a cyber-physical system, in particular a vehicle and / or a robot.

[0009] A second general aspect of the present disclosure relates to a computer-implemented method for further training a machine learning model, the machine learning model being configured to generate code elements of a piece of software code based on a linguistic specification of the code elements to be created and interface testing criteria to be satisfied by the code elements to be created, the method including adjusting the machine learning model based on testing results, the testing results resulting from testing whether the code elements satisfy the interface testing criteria.

[0010] A method according to the second general aspect (or an embodiment thereof) may, but need not necessarily be performed in accordance with a method according to the first general aspect (or an embodiment thereof).

[0011] The code elements may have been generated and inspected according to a method for automatically generating code elements of code for software according to the first general aspect (or an embodiment thereof).

[0012] A third general aspect of the present disclosure relates to a computer system configured to perform a computer-implemented method for automatically generating code elements of code for software according to the first general aspect (or an embodiment thereof) and / or a computer-implemented method for further training a machine learning model according to the second general aspect (or an embodiment thereof).

[0013] A fourth general aspect of the present disclosure relates to a computer program configured to perform a computer-implemented method for automatically generating code elements of code for software according to the first general aspect (or an embodiment thereof) and / or a computer-implemented method for further training a machine learning model according to the second general aspect (or an embodiment thereof).

[0014] A fifth general aspect of the present disclosure relates to a computer-readable medium or signal storing and / or including a computer program according to the fourth general aspect (or an embodiment thereof).

[0015] The method according to the first aspect (or an embodiment thereof) proposed in the present disclosure aims to automatically generate code elements of a piece of software code.

[0016] The method proposed in the present disclosure allows software code to be revised in a planned manner at one or more locations. For example, a portion of the software code can be replaced with a generated code element. In another example, the software code at a certain location can be extended by a generated code element. Such code elements are generated by a machine learning model based on interface testing criteria. However, before the generated code element can be incorporated into the code, for example, the code element must satisfy the interface testing criteria. This ensures that the code element is suitable for the code. That is, the method proposed in the present disclosure first utilizes the sufficiently large machine language knowledge of the machine learning model, and then automatically checks to ensure that the generated code element satisfies the interface testing criteria. This utilizes the mechanical creativity of the machine learning model, which tends to cause hallucination, while simultaneously narrowing down the code elements to the extent that only suitable code elements can be selected for final incorporation into the code. This ensures the quality of the software code and thus the quality of technical systems, in particular cyber-physical systems, in particular the computing units of vehicles and / or robots that are controlled, regulated and / or monitored at least by software. At the same time, the work effort is significantly reduced. This allows reliable code changes to be made more frequently and more easily. This improves the quality of the software.

[0017] A high level of automation further allows for the automatic generation of multiple code elements. In particular, automation allows for the generation of multiple code elements until one of the code elements satisfies the interface testing criteria. Here, diversity (e.g., through random selection) in the output of the machine learning model (which is sometimes referred to in technical terms as temperature) proves to be particularly advantageous. In other words, even for repetitions based on the same input, the machine learning model can generate different outputs. Alternatively or additionally, the linguistic specification can be adapted to the code element to be created and / or the interface testing criteria.

[0018] Advantageously, in the method proposed in this disclosure, prompts to machine learning models, in particular large language models (LLMs), can be extended with properties such as, for example, value ranges that must be satisfied by the input and output values ​​of the code elements to be generated. These properties can be obtained, for example, by forward and backward computation of existing code by complex verification using abstract interpretation. Alternatively or additionally, these properties can come from (manual) code annotations. In a second step, the code elements generated by the machine learning model are automatically checked in a verification step for compliance with these properties.

[0019] This ensures that the code elements generated by the machine learning model, and thus the resulting code, satisfy certain property guarantees, such as respecting certain value ranges formulated as preconditions, postconditions and invariants. While no guarantees exist for the generated code elements in the past, the method proposed in this disclosure guarantees that the generated code elements can safely handle at least all possible calls in existing code, while only producing output values ​​suitable for further use in the code.

[0020] The method can be used equally well for all popular programming languages ​​(e.g., abstract interpretation or other suitable formal methods can be used for programming languages), and the method does not need to be painstakingly adapted or developed for a specific programming language - as has been the case in the past.

[0021] A further advantage is that the resulting code elements and their testing results can be used to train a respective domain-specific code element generator, as may be implemented, for example, as in the method according to the second general aspect (or an embodiment thereof). This allows supervised fine-tuning and / or unsupervised (reinforcement) learning to be performed based on the testing results, thus improving the method according to the first general aspect (or an embodiment thereof). This allows for (future) better creation of code elements for software code. [Brief explanation of the drawings]

[0022] [Figure 1] FIG. 1 illustrates a schematic diagram of an exemplary embodiment of a computer-implemented method for automatically generating code elements of a software code. [Figure 2] FIG. 1 illustrates a computer-implemented method for further training a machine learning model. [Figure 3] FIG. 1 illustrates an exemplary embodiment of a method for automatically generating code elements of a piece of software code. [Figure 4] FIG. 1 illustrates an exemplary embodiment of a method for automatically generating code elements of software code to fill in blanks in the code or to replace previous code elements in the code. DETAILED DESCRIPTION OF THE INVENTION

[0023] Detailed Description The method 100 proposed in this disclosure aims to automatically generate code elements of or for software.

[0024] The software may be configured to control, regulate, and / or monitor at least one computing unit of a technical system, in particular a cyber-physical system, in particular a vehicle and / or a robot. In particular, the software may be embedded software configured to run on an embedded (i.e., for example, for the respective task) system. Examples of uses of the software may be drive control and / or transmission control, brake control, autonomous driving, machine perception for autonomous driving, hybrid strategies, battery management, etc. Thanks to the testing step 130, the method 100 can even be used for safety-related software in accordance with certain standards, such as ISO 26262 (functional safety).

[0025] For example, in method 100, a prompt sent to a machine learning model, such as a large language model (LLM), can be automatically expanded with context (i.e., at least interface validation criteria) for the purpose of generating one or more code elements of or for the code. For example, the prompt can be expanded with additional context related to the use of the code to be generated, giving the machine learning model a chance to generate one or more code elements that satisfy this context. The one or more code elements generated by the machine learning model are automatically validated for satisfying the context related to the use of the code element.

[0026] The method 100 may be implemented in an electronic programming environment, which allows intervention in the method through a user interface.

[0027] To this end, firstly, a computer-implemented method 100, such as that shown schematically in FIG. 1, for automatically generating code elements 50 of a piece of software code 10 is disclosed.

[0028] The method 100 includes generating 120 a code element 50 via a machine learning model 40 (e.g., by the machine learning model 40) based on a linguistic specification 31 of the code element 50 to be created and interface testing criteria 32 to be satisfied by the code element 50 to be created.

[0029] Method 100 includes testing 130 whether code element 50 satisfies interface testing criteria 32, resulting in a testing result. Testing 130 may also be performed via machine learning model 40 or another machine learning model (e.g., by machine learning model 40 or another machine learning model). However, testing 130 is preferably not performed via (nor by) machine learning model 40 or by another / other machine learning model, since in such case testing 130 is not affected by potential hallucinations of the machine learning model.

[0030] The software code 10 may be software source code. The code may be written in one or more programming languages. For example, the code may be written in the programming language C. Alternatively or additionally, the code may be written in, for example, the programming language Rust. Due to the sufficiently large language understanding of the machine learning model, the programming language need not be specified. In other words, the method 100 may be applied to the respective code regardless of the programming language(s).

[0031] A code element may also be code, and thus may be software source code or a portion thereof. A code element may be part of a larger piece of code. A code element may, for example, include or be a function or procedure of code.

[0032] The linguistic specification 31, in particular the natural language specification 31, of at least one code element 50 to be created may be a specification of a function or procedure. For example, the linguistic specification may include an input / output signature 12. The input / output signature 12 may be a specification of one or more input types and / or a specification of one or more output types. An exemplary input / output signature for a function to calculate a square root is:

number

[0033] The machine learning model 40 may include or be a foundation model. The foundation model may be a large-scale machine learning model trained (often by self-supervised or semi-supervised learning) based on a large amount of extensive data so that it can be tailored to a wide range of downstream tasks. In particular, the machine learning model may include or be a large-scale language model (LLM). The large-scale language model may be a language model characterized by its size. In particular, the large-scale language model may be a chatbot and / or have chatbot functionality. For example, LLaMA, an AI from Meta, may be used as the large-scale language model. Such a large-scale language model would be advantageous because such a large-scale language model, in particular the weights and / or biases of such a large-scale language model, can be adjusted, for example, by method 200. Alternatively or additionally, for example, Google's Gemini may be used. Alternatively or additionally, for example, ChatGPT (e.g., May 24, 2023 version) by OpenAI may be used as the large-scale language model. Alternatively or additionally, for example, Bloom by Hugging Face may be used as the large-scale language model. Alternatively or additionally, the machine learning model may include or be a foundation model (also referred to as a multi-domain model). Here, for example, GPT-4 (e.g., March 14, 2023 version) by OpenAI may be used.

[0034] The interface check criteria 32 may include preconditions 33 on the inputs of the function. An input here may include one or more input quantities. The preconditions 33 may include one or more sub-preconditions for one or more input quantities. The interface check criteria may not require postconditions 34, for example, if the code element does not have an output quantity.

[0035] Alternatively or additionally, the interface check criteria 32 may include post-conditions 34 on the outputs of the function. The outputs here may include one or more output quantities. The post-conditions 34 may include one or more sub-post-conditions for one or more output quantities. The interface check criteria may not require pre-conditions 33, for example, if the code element does not have input quantities, because the pre-conditions 33 should be placed before the existing code, for example.

[0036] In particular, interface check criteria 32 may include both preconditions 33 on the inputs of the function and postconditions 34 on the outputs of the function. Interface check criteria require both preconditions and postconditions, for example, if a code element is to fill a blank in the computational chain of code or is to be used in place of a chain member, as exemplarily shown in Figure 4.

[0037] A prompt 30 to the machine learning model 40 may include a linguistic instruction 31 as exemplarily shown in Fig. 3. Alternatively or additionally, the prompt may include interface test criteria 32. In particular, the prompt may include both the linguistic instruction and the interface test criteria. Alternatively, the linguistic instruction 31 and the interface test criteria 32 may be provided to the machine learning model as input values ​​outside the prompt 30. The prompt may be text in a natural language.

[0038] Satisfaction of an interface check criterion 32 may presuppose satisfaction of preconditions 33 and / or postconditions 34. In particular, an interface check criterion may be satisfied by a code element if and only if the preconditions and / or postconditions are satisfied by that code element.

[0039] Checking 130 whether a code element satisfies interface testing criteria may include, for example, static analysis. Static analysis may be based on, for example, abstract interpretation, in which case the code element is not executed. Alternatively or additionally, checking 130 whether a code element satisfies interface testing criteria may include, for example, dynamic analysis. Dynamic analysis may include, for example, fuzzing, in which the code element is executed based on multiple inputs and generates multiple outputs. In particular, checking 130 whether a code element satisfies interface testing criteria may include static analysis and dynamic analysis.

[0040] Both static and dynamic analyses may be performed automatically, and the results of these static and dynamic analyses may be used to specify further language for further code elements to be created as needed in a new execution of method 100, especially if the results are not sufficiently positive ("nOK," short for notOK).

[0041] The test result may comprise or be a text in a natural language. Alternatively or additionally, the evaluation result may comprise or be a data structure written in a predetermined syntax (e.g., in a programming language). The data structure may, for example, comprise a text in a natural language. The test result may comprise one or more numerical values, in particular one or more confidence values, which allow encoding the quality of at least one code element 50, and which may be taken into account in the question of whether the code element should be incorporated 140 into the code.

[0042] Even in the case of a failure to generate a code element, the test results may contain information that the generation of at least one code element was unsuccessful. This may occur, for example, if the language specifications 31 (and / or prompts 30) and / or interface test criteria, derived from code that often contains errors, are already inconsistent. Such information is also valuable for the development of technical systems. In such cases, it is possible and necessary to adjust, in particular improve, these language specifications and / or interface test criteria, and possibly also the code from which they are derived.

[0043] The method 100 may further aim to incorporate the generated code element 50 into the code 10. The method 100 may, for example, include, as optionally shown in Figure 1, incorporating 140 the code element into the code 10, at least if the test result is sufficiently positive ("OK"), resulting in a revised code 11. Here, for example, the code 10 may be extended by the generated 120 code element 50, or a previous code element in the code may be replaced by the generated 120 code element 50.

[0044] The method 100 may further comprise compiling the revised code 11. The method 100 may further comprise executing 150 the revised code (e.g. in compiled form) in a computation unit of a technical system, in particular a cyber-physical system, in particular a vehicle and / or a robot, for example as optionally shown in Figure 1. To that extent, the method 100 may be a method for producing code for software of a technical system.

[0045] Method 100 may further include repeating 141 method 100 if the test result is not sufficiently positive ("nOK"), for example, as shown as an option in FIG. 1. Multiple iterations are possible. The linguistic designation 31 of the at least one code element 50 to be created may, but need not, be changed, since machine learning models 40 can generate different outputs even for identical inputs. In other words, the machine learning model may have a temperature. On the other hand, the machine learning model may also be changed (e.g., by method 200 for further training the machine learning model).

[0046] The method 100 may include deriving 110 interface test criteria 32 based on the code, particularly via abstract interpretation. Alternatively or additionally, the method 100 may include deriving 110 interface test criteria based on at least one manual annotation in the code. In particular, the method 100 may include deriving 110 interface test criteria based on the code, particularly via abstract interpretation, and based on at least one manual annotation in the code. The automatically deriving 110 interface test criteria may also enable, in particular, automatic derivation of multiple interface test criteria at different points in the code. This allows the method 100 to automatically revise the code at multiple points (e.g., based on decomposing the code into functions and / or procedures). Such a process may be relevant, for example, when translating code from one programming language (e.g., C) to another programming language (e.g., Rust). Thanks to the decomposition of the code, individual functions and / or procedures can be translated separately. This allows the basic structure of the code to be maintained after translation. Furthermore, code decomposition can represent, for example, the responsibilities of different programmers.

[0047] Method 100 may include receiving code 10. Alternatively or additionally, method 100 may include receiving verbal instructions 31 and / or prompts 30, in which case the order of such steps may be trivial. Alternatively or additionally, method 100 may include receiving a machine learning model 40. Method 100 may include receiving desired changes 20 to code 10. The prompts and / or verbal instructions may be based on the desired changes 20.

[0048] The method 100 may include outputting the code element 50 and / or the test results, which may be performed, for example, via an electronic programming environment.

[0049] Method 100 can be based on at least one input from a user of an interface of the electronic programming environment. For example, the execution of method 100 and / or multiple executions of method 100 can be (interactively) controlled via the electronic programming environment. This can be useful, for example, when test results for created code elements are still not sufficiently positive. Alternatively or additionally, interactive control can be useful when debugging automated execution of method 100. Alternatively or additionally, for example, desired code elements can be interactively selected via input after test cases have been generated, followed by incorporating 140 the code elements into the code.

[0050] The method 100 may also include generating a plurality of code elements 50 via a machine learning model 40 based on specifications 31 in one or more languages ​​for the code elements to be created and interface testing criteria 32 to be satisfied by the code elements to be created.

[0051] The method 100 may also include testing whether one of the generated code elements 50 meets interface testing criteria 32 .

[0052] For example, one or more of the plurality of code elements may be generated based at least on the linguistic designation, i.e., in a single execution of method 100. Alternatively or additionally, one or more of the plurality of code elements may be generated by multiple executions of method 100. Advantageously, the linguistic designation and / or prompts may be changed in multiple executions of method 100. On the other hand, the linguistic designation and / or prompts may not be changed in multiple executions of method 100. Alternatively or additionally, the machine learning model may be changed in multiple executions of method 100.

[0053] The natural language text in method 100 may be written in English, which may be advantageous because most machine learning models are currently trained predominantly, if not entirely, in English.

[0054] Also disclosed is a computer-implemented method 200 for further training a machine learning model, the machine learning model being configured to generate code elements of a piece of software code based on linguistic specifications of the code elements to be created and interface testing criteria to be satisfied by the code elements to be created. For example, as shown generally in FIG. 2, the method 200 may include adjusting 210 the machine learning model based on the code elements and the testing results (and, in some cases, based on linguistic instructions to the machine learning model), the testing results resulting from testing 130 whether the code elements satisfy the interface testing criteria.

[0055] The checking 130 may be, but is not necessarily, part of the method 200. The code elements may have been generated 120 and checked 130 according to the method 100 for automatically generating code elements for software code, resulting in a checking result. The method 200 may be, but is not necessarily, a continuation of the method 100.

[0056] Alternatively or additionally, method 100 can be performed anew via an adjusted machine learning model. In particular, the machine learning model can be adjusted according to method 200 between multiple performances of method 100.

[0057] Machine learning models can be tuned through supervised learning. Such tuning of machine learning models can be considered as supervised finetuning. Thanks to finetuning, for example, a generic machine learning model trained with general machine language comprehension can be tuned for a specific application, i.e., in view of generating code elements for a code.

[0058] Fine-tuning of a machine learning model can, but does not have to, precede further tuning of the machine learning model via unsupervised (reinforcement) learning.

[0059] Alternatively or additionally, adjusting the machine learning model based at least on the at least one code element and on the at least one test result may include calculating at least one reward based at least on the at least one test result and adjusting the machine learning model based at least on the at least one code element and on the at least one reward. Such tuning of the machine learning model can be considered as unsupervised (reinforcement) learning. This allows, for example, a generic machine learning model trained with general machine language comprehension and / or such a model after fine-tuning to be (further) tuned for a respective application, i.e., in light of generating code elements for code. This allows the machine learning model to be better tailored to the application case of generating code elements for code.

[0060] A reward may be a parameter, particularly a numerical parameter, that is comparable to other parameters that are also rewards, and may, for example, be higher, equal to, or lower than the other rewards.

[0061] If the at least one test result is relatively good, the at least one reward may be higher, and if the at least one test result is relatively bad, the at least one reward may be lower.

[0062] A test result may be relatively bad, particularly bad, if the tests on which the test result is based (e.g., in view of multiple generated code elements) are already negative, i.e., for example, failed. Alternatively or additionally, a test result may be relatively good, particularly good, if all tests are positive, i.e., for example, passed.

[0063] The machine learning model can be adjusted based on at least a plurality of code elements (and, optionally, corresponding verbal instructions to the machine learning model) and a plurality of corresponding rewards. The method can then include calculating a reward for each code element of the plurality of code elements based on at least a plurality of test results. In other words, the reward for a code element need not depend solely on the test result for that code element, but can also be based on one or more test results for other code elements. The one or more rewards (i.e., the magnitude of the reward) can depend, for example, on the number of test results. Alternatively or additionally, the one or more rewards can depend on the number of relatively good test results and the number of relatively bad test results, and in particular, on the imbalance between the relatively good and relatively bad test results. Alternatively or additionally, the reward can be calculated for each test result first, and then adjusted and / or calculated based on other test results.

[0064] Tuning the machine learning model can be based on a reinforcement learning algorithm, such as, for example, Proximal Policy Optimization (PPO).

[0065] Parts of the machine learning model may be (intentionally) left untuned, i.e., fixed, while only other parts of the machine learning model are tuned.

[0066] For example, certain parameters such as weights and / or biases, particularly weights and / or biases in earlier layers of a machine learning model, may not need to be adjusted, i.e., may be fixed. For example, adjustments may be limited to later layers of the machine learning model. This may ensure that the machine learning model does not degrade excessively in terms of machine language comprehension. On the other hand, adjustments may be aimed at reducing machine language comprehension to the extent that it is not important for generating code elements for the code; for example, machine language comprehension of Shakespearean English is not (usually) necessary for generating code elements.

[0067] The method 200 may be controlled via an electronic programming environment. In particular, the machine learning model may be further tuned via the electronic programming environment.

[0068] In the exemplary embodiment of method 100 shown in FIG. 3 , a change request 20, such as an implementation or revision (refactoring) of a specific function or procedure, can first be received for a given code, e.g., in a natural language. These functions or procedures may be blank or previous code elements, as in the exemplary embodiment of method 100 shown in FIG. 4 . The revision may also include translation from one programming language to another, e.g., from C to Rust. Based on the code 10, a complex verification using abstract interpretation can first be applied to derive one or more preconditions 33 and / or one or more consequent conditions 34, and possibly one or more invariants, for the change request 20. This step can implement deriving 110 interface check criteria 32 based on the code 10. When new code (i.e., new code element 50) is to be created for existing code 10, a location already exists in code 10 where the new code (i.e., generated code element 50) should be inserted, as shown in FIG. 4 . If the code is to be revised, the previous code element is replaced by a newly generated code element 50 .

[0069] Furthermore, a prompt 30 for the machine learning model 40 (particularly the LLM) can be created, and the prompt 30 can include linguistic instructions 31. For this purpose, the desired change 20 can be encoded together with functional properties to be achieved, possibly a required context for the code, preconditions 33 and / or postconditions 34, and possibly invariants. In the case of refactoring, at least one previous code element can additionally be included in the prompt. For example, it is also conceivable to include at least a portion of further data about the code 10, such as coding guidelines, documentation, etc., in the prompt 30.

[0070] The machine learning model 40 can process the prompt 30 and / or further input values ​​(e.g., for linguistic instructions, interface testing criteria, input / output signature 12, etc.), and at least one new code element 50 is output or extracted from the machine learning model's prompt. This new code (i.e., at least one new code element 50) is checked for compliance with one or more preconditions 33 and / or one or more postconditions, and possibly one or more invariants, as used by the code. This may be performed by one or more formal methods, such as abstract interpretation, fuzzing, and / or testing, which may output guarantees of varying strength. If the check 130 passes successfully ("OK" in FIGS. 3-4), revised code 11 can be output with the corresponding guarantee. On the other hand, if the check 130 fails ("nOK" in FIGS. 3-4), the prompt 30 can be revised, for example, to remedy the error in a repetition of the method 100. Theoretically, failures can occur with infinite frequency. However, this is extremely unlikely in practice (as long as a feasible task is set), because the machine learning model can eventually produce an appropriate output depending on its internal parameters and appropriate prompts. A counter can be incorporated here for safety, and after a predetermined number of steps, for example 10 steps, the best suggestion can be returned with a corresponding indication of possible insufficiency. If the machine learning model does not actually find a sufficiently positive solution, the problem can be returned to the user of the electronic programming environment along with the collected information, so that the user can construct a new, refined prompt based on this information. Optionally, the user can be replaced in this case by a further machine learning model.

[0071] An exemplary flow of the method 100 can be seen in Figure 4. Here, exemplarily, there is initially code 10 consisting of two functions 13 and a location 14 where new code should be inserted (first column of Figure 4). In the analysis step (second column of Figure 4), preconditions 33 and postconditions 34 (more generally, interface check criteria 32) for the location to be processed ("blank") can be calculated based on the existing functions 13, for example, by complex verification using abstract interpretation. These preconditions 33 and postconditions 34 can be used in the next step (third column of Figure 4) to generate a prompt 30 for, for example, a machine learning model 40 (e.g., LLM). Additionally, a linguistic specification of the code elements to be created, i.e., a (functional) specification of the location to be processed, can be used, as can the input / output signature of the function to be generated. The prompt can also include an indication of whether new code should be generated. In the next step (column 4 of FIG. 4 ), the machine learning model 40 generates 120 a code element 50 based on the generated prompt 30. This code element 50 can then be checked 130 using existing formal methods for compliance with preconditions 33 and postconditions 34 (generally, interface checking criteria 32) in a final step (column 5 of FIG. 4 ). If the checking results are sufficiently positive, the generated 120 code element 50 can fill in the blanks 12.

[0072] Here is an example, written in English (and C) since most current machine learning models can handle English better than German.

[0073] First prompt example:

number

[0074] That is, here, this prompt has a precondition

number

number

[0075] The first code element generated by the machine learning model based on the first example prompt is:

number

[0076] An example verification output when checking whether the generated code elements meet the interface verification criteria is as follows:

number

[0077]

number

[0078] That is, an error was identified here in that a division by zero could occur in the generated code element, since according to the preconditions, x=0 is allowed.

[0079] An exemplary further prompt aimed at correcting code elements that still contain errors is as follows:

number

[0080] The second code element generated by the machine learning model based on further prompts is as follows (changes from the first example output are highlighted in bold):

number

[0081] That is, the error in the generated code element was indeed correctly corrected. This example also illustrates that generating 130 a code element can be based on pre-generated code elements and / or pre-utilized prompts.

[0082] Further disclosed is a computer system configured to perform the computer-implemented method 100 for automatically generating code elements of a piece of software code. Alternatively or additionally, the computer system may be configured to perform the computer-implemented method 200 for further training a machine learning model. In particular, the computer system may be configured to perform the computer-implemented method 100 for automatically generating code elements of a piece of software code and (e.g., subsequently) the computer-implemented method 200 for further training a machine learning model. The computer system may include a processor and / or a main memory.

[0083] Further disclosed is a computer program configured to perform the computer-implemented method 100 for automatically generating code elements of a software code. Alternatively or additionally, the computer program may be configured to perform the computer-implemented method 200 for further training a machine learning model. In particular, the computer program may be configured to perform the computer-implemented method 100 for automatically generating code elements of a software code and (e.g., subsequently) the computer-implemented method 200 for further training a machine learning model. The computer program may, for example, exist in an interpretable form or in a compiled form. The computer program may, for example, be loaded (even partially) into the RAM of the computer to be executed as a bit or byte sequence.

[0084] Further disclosed is a computer readable medium or signal storing and / or including the computer program. The medium may include, for example, one of RAM, ROM, EPROM, HDD, SSD, etc., on / in which the signal is stored.

Claims

1. A computer-implemented method (100) for automatically generating code elements (50) of a piece of software code (10), said method (100) comprising: generating (120) a code element (50) via a machine learning model (40) based on a linguistic specification (31) of the code element (50) to be created and interface test criteria (32) to be satisfied by the code element (50) to be created, optionally wherein prompts (30) to the machine learning model (40) include the linguistic specification and the interface test criteria (32); - checking (130) whether said code element (50) satisfies said interface test criteria (32), resulting in a test result (130); A method (100) comprising:

2. the software is configured to control, regulate and / or monitor a technical system, in particular a cyber-physical system, in particular a computing unit of a vehicle and / or a robot, The method (100) of claim 1.

3. The method (100) is performed in an electronic programming environment.

3. The method (100) of claim 1 or 2.

4. The method (100) comprises: - incorporating (140) said code element (50) into said code (10), at least if said test result is sufficiently positive, resulting in a revised code (11) (140). Including, The code (10) is extended by the code element (50), or a previous code element in the code (10) is replaced by the code element (50). The method (100) of any one of claims 1 to 3.

5. The method (100) comprises: Executing (150) said revised code (11) in a computing unit of a technical system, in particular a cyber-physical system, in particular a vehicle and / or a robot. The method (100) of claim 4, comprising:

6. The method (100) comprises: Deriving (110) the interface test criteria (32) based on the code (10), in particular via abstract interpretation, and / or based on at least one manual annotation in the code (10). The method (100) of any one of claims 1 to 5, comprising:

7. The code element (50) comprises a function (13) or procedure of the code (10), the language specification of the code element (50) to be created includes a specification of the function (13) or procedure and, optionally, an input / output signature (12); The method (100) of any one of claims 1 to 6.

8. The interface check criteria (32) include preconditions (33) for the inputs of the function and / or postconditions (34) for the outputs of the function (13), The fulfillment of the interface check criteria presupposes that the preconditions (33) and / or the postconditions (34) are fulfilled. The method (100) of claim 7.

9. Verifying (130) whether the code element (50) satisfies the interface verification criteria (32) includes static analysis and / or dynamic analysis. The method (100) of any one of claims 1 to 8.

10. The method (100) comprises: If the test result is not sufficiently positive, repeating (141) the method (100) of any one of claims 1 to 9, optionally modifying (141) the linguistic specification of the code element (50) to be created and / or the machine learning model (40). The method (100) of any one of claims 1 to 9, comprising:

11. A computer-implemented method (200) for further training a machine learning model (40), comprising: The machine learning model (40) is configured to generate code elements (50) of a software code (10) based on a linguistic specification (31) of the code elements (50) to be created and interface testing criteria (32) to be satisfied by the code elements (150) to be created; The method (200) comprises: Adjusting (210) the machine learning model (40) based on the code element (50) and test results, the test results resulting from testing whether the code element (50) satisfies the interface test criteria (32). A computer-implemented method (200) comprising:

12. The code element (50) has been generated (120) and checked (130) according to a method (100) for automatically generating code elements (50) of a software code (10) according to any one of claims 1 to 10. The method (200) of claim 11.

13. 1. A computer system comprising: A computer-implemented method (100) for automatically generating code elements (50) of a software code (10) according to any one of claims 1 to 10, and / or A computer-implemented method (200) for further training a machine learning model according to claim 11 or 12.

1. A computer system configured to perform the steps of:

14. A computer program comprising: A computer-implemented method (100) for automatically generating code elements (50) of a software code (10) according to any one of claims 1 to 10, and / or A computer-implemented method (200) for further training a machine learning model according to claim 11 or 12. A computer program configured to perform the steps of:

15. A computer readable medium or signal storing and / or including a computer program according to claim 14.