kth.sePublications KTH
Change search
Link to record
Permanent link

Direct link
Publications (10 of 50) Show all publications
Hampus, A. & Nyberg, M. (2025). A Theory of Probabilistic Contracts. In: Leveraging Applications of Formal Methods, Verification and Validation. Specification and Verification - 12th International Symposium, ISoLA 2024, Proceedings: . Paper presented at 12th International Symposium on Leveraging Applications of Formal Methods, Verification and Validation, ISoLA 2024, Crete, Greece, October 27-31, 2024 (pp. 296-319). Springer Nature
Open this publication in new window or tab >>A Theory of Probabilistic Contracts
2025 (English)In: Leveraging Applications of Formal Methods, Verification and Validation. Specification and Verification - 12th International Symposium, ISoLA 2024, Proceedings, Springer Nature , 2025, p. 296-319Conference paper, Published paper (Refereed)
Abstract [en]

In industrial-sized cyber-physical systems, ensuring fulfillment of requirements gets increasingly more costly as the number of components increases. To make the task feasible, compositional verification has been suggested as a scalable solution. Such techniques allow verification by divide-and-conquer, often using assume-guarantee contracts. Although previous research has focused mostly on the non-probabilistic setting, in the real world, probabilities often arise due to random hardware failures, stochastic communication delays, sensor ghost objects, machine learning components, rounding errors caused by finite-precision arithmetic, human behavior, and probabilistic algorithms. Therefore, for contract theories to be practically relevant to cyber-physical systems, there is a need to support probabilistic reasoning, for instance regarding safety and reliability. To this end, we propose a completely trace-based probabilistic contract theory, supporting general probability measures, continuous time, and continuous state spaces. To verify decompositions of such contracts, we also present a deductive system, which is illustrated on an industrially inspired automatic emergency braking example.

Place, publisher, year, edition, pages
Springer Nature, 2025
Keywords
Compositional verification, Contract theory, Probability
National Category
Computer Sciences Computer Systems
Identifiers
urn:nbn:se:kth:diva-356657 (URN)10.1007/978-3-031-75380-0_17 (DOI)001419014500017 ()2-s2.0-85208595091 (Scopus ID)
Conference
12th International Symposium on Leveraging Applications of Formal Methods, Verification and Validation, ISoLA 2024, Crete, Greece, October 27-31, 2024
Note

Part of ISBN 9783031753794

QC 20241121

Available from: 2024-11-20 Created: 2024-11-20 Last updated: 2025-03-17Bibliographically approved
Sevenhuijsen, M., Ung, G., Suresh Patil, M. & Nyberg, M. (2025). Generating Safety-Critical Automotive C-programs using LLMs with Formal Verification. In: Proceedings of Machine Learning Research - Conference on Neurosymbolic Learning and Reasoning, NeSy 2025: . Paper presented at 19th Conference on Neurosymbolic Learning and Reasoning, NeSy 2025, Santa Cruz, United States of America, September 8-10, 2025 (pp. 353-378). ML Research Press
Open this publication in new window or tab >>Generating Safety-Critical Automotive C-programs using LLMs with Formal Verification
2025 (English)In: Proceedings of Machine Learning Research - Conference on Neurosymbolic Learning and Reasoning, NeSy 2025, ML Research Press , 2025, p. 353-378Conference paper, Published paper (Refereed)
Abstract [en]

We evaluate the feasibility of generating formally verified C code that adheres to both functional and non-functional requirements using Large Language Models (LLMs) for three real industrial, automotive safety-critical software modules. We explore the capabilities of ten LLMs and four prompting techniques — Zero-Shot, Zero-Shot Chain-of-Thought, One-Shot, and One-Shot Chainof-Thought — to generate C programs for the three modules. Functional correctness of generated programs is assessed through functional verification, and adherence to non-functional requirements is evaluated using an industrial static analyzer, along with human evaluation. The results demonstrate that it is feasible for LLMs to generate functionally correct code, with success rates of 540/800, 59/800, and 46/800 for the three modules. Additionally, the generated programs frequently adhere to the defined non-functional requirements. In the cases where the LLM-generated programs did not adhere to the non-functional requirements, deviations typically involve violations of single-read and single-write access patterns or minimal variable scope constraints. These findings highlight the promise and limitations of using LLMs to generate industrial safety-critical C programs, providing insight into improving automated LLM-based program generation in the automotive safety-critical domain.

Place, publisher, year, edition, pages
ML Research Press, 2025
Series
Proceedings of Machine Learning Research ; 284
Keywords
Formal Verification, Large Language Models, Non-Functional Requirements, Prompt Engineering, Safety-Critical Automotive Software
National Category
Software Engineering Computer Systems Computer Sciences
Identifiers
urn:nbn:se:kth:diva-372794 (URN)2-s2.0-105020236369 (Scopus ID)
Conference
19th Conference on Neurosymbolic Learning and Reasoning, NeSy 2025, Santa Cruz, United States of America, September 8-10, 2025
Note

QC 20251119

Available from: 2025-11-19 Created: 2025-11-19 Last updated: 2025-11-19Bibliographically approved
Sevenhuijsen, M., Ung, G., Patil, M. S. & Nyberg, M. (2025). Generating Safety-Critical Automotive C-programs using LLMs with Formal Verification. In: Gilpin, LH Giunchiglia, E Hitzler, P VanKrieken, E (Ed.), Conference On Neurosymbolic Learning And Reasoning: . Paper presented at 19th International Conference on Neural Symbolic Learning and Reasoning-NESY-Annual, SEP 08-10, 2025, Santa Cruz, CA (pp. 353-378). JMLR-JOURNAL MACHINE LEARNING RESEARCH, 284
Open this publication in new window or tab >>Generating Safety-Critical Automotive C-programs using LLMs with Formal Verification
2025 (English)In: Conference On Neurosymbolic Learning And Reasoning / [ed] Gilpin, LH Giunchiglia, E Hitzler, P VanKrieken, E, JMLR-JOURNAL MACHINE LEARNING RESEARCH , 2025, Vol. 284, p. 353-378Conference paper, Published paper (Refereed)
Abstract [en]

We evaluate the feasibility of generating formally verified C code that adheres to both functional and non-functional requirements using Large Language Models (LLMs) for three real industrial, automotive safety-critical software modules. We explore the capabilities of ten LLMs and four prompting techniques - Zero-Shot, Zero-Shot Chain-of-Thought, One-Shot, and One-Shot Chain-of-Thought - to generate C programs for the three modules. Functional correctness of generated programs is assessed through functional verification, and adherence to non-functional requirements is evaluated using an industrial static analyzer, along with human evaluation. The results demonstrate that it is feasible for LLMs to generate functionally correct code, with success rates of 540/800, 59/800, and 46/800 for the three modules. Additionally, the generated programs frequently adhere to the defined non-functional requirements. In the cases where the LLM-generated programs did not adhere to the non-functional requirements, deviations typically involve violations of single-read and single-write access patterns or minimal variable scope constraints. These findings highlight the promise and limitations of using LLMs to generate industrial safety-critical C programs, providing insight into improving automated LLM-based program generation in the automotive safety-critical domain.

Place, publisher, year, edition, pages
JMLR-JOURNAL MACHINE LEARNING RESEARCH, 2025
Series
Proceedings of Machine Learning Research, ISSN 2640-3498
National Category
Software Engineering
Identifiers
urn:nbn:se:kth:diva-378979 (URN)001669525800019 ()
Conference
19th International Conference on Neural Symbolic Learning and Reasoning-NESY-Annual, SEP 08-10, 2025, Santa Cruz, CA
Note

QC 20260409

Available from: 2026-04-09 Created: 2026-04-09 Last updated: 2026-04-09Bibliographically approved
Sevenhuijsen, M., Etemadi, K. & Nyberg, M. (2025). VeCoGen: Automating Generation of Formally Verified C Code With Large Language Models. In: Gwen Salaün and Anastasia Mavridou (Ed.), FormaliSE 2025: ACM/IEEE International Conference on Formal Methods in Software Engineering, Ottawa, Canada, April 27-28, 2025.: . Paper presented at FormaliSE 2025. Ottawa, Ontario, Canada: IEEE Computer Society Digital Library
Open this publication in new window or tab >>VeCoGen: Automating Generation of Formally Verified C Code With Large Language Models
2025 (English)In: FormaliSE 2025: ACM/IEEE International Conference on Formal Methods in Software Engineering, Ottawa, Canada, April 27-28, 2025. / [ed] Gwen Salaün and Anastasia Mavridou, Ottawa, Ontario, Canada: IEEE Computer Society Digital Library, 2025Conference paper, Published paper (Refereed)
Abstract [en]

Large language models have demonstrated impressive capabilities in generating code, yet they often produce programs with flaws or deviations from intended behavior, limiting their suitability for safety-critical applications. To address this limitation, this paper introduces VeCoGen, a novel tool that combines large language models with formal verification to automate the generation of formally verified C programs. VeCoGen takes a formal specification in ANSI/ISO C Specification Language, a natural language specification, and a set of test cases to attempt to generate a verified program. This program-generation process consists of two steps. First, VeCoGen generates an initial set of candidate programs. Secondly, the tool iteratively improves on previously generated candidates. If a candidate program meets the formal specification, then we are sure the program is correct. We evaluate VeCoGen on 15 problems presented in Codeforces competitions. On these problems, VeCoGen solves 13 problems. This work shows the potential of combining large language models with formal verification to automate program generation.

Place, publisher, year, edition, pages
Ottawa, Ontario, Canada: IEEE Computer Society Digital Library, 2025
Keywords
Codes, Program processors, Limiting, Large language models, Natural languages, Programming, Specification languages, Formal specifications, Formal verification, Software development management
National Category
Computer Sciences
Research subject
Computer Science
Identifiers
urn:nbn:se:kth:diva-364661 (URN)10.1109/FormaliSE66629.2025.00017 (DOI)001554519900011 ()2-s2.0-105009063103 (Scopus ID)
Conference
FormaliSE 2025
Note

Part of ISBN 979-8-3315-3794-4

QC 20250617

Available from: 2025-06-16 Created: 2025-06-16 Last updated: 2025-12-20Bibliographically approved
Hampus, A. & Nyberg, M. (2024). A Theory of Probabilistic Contracts (With Proofs).
Open this publication in new window or tab >>A Theory of Probabilistic Contracts (With Proofs)
2024 (English)Report (Other academic)
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-350235 (URN)
Note

QC 20240710

Available from: 2024-07-10 Created: 2024-07-10 Last updated: 2024-10-09Bibliographically approved
Hampus, A. & Nyberg, M. (2024). Formally verifying decompositions of stochastic specifications. International Journal on Software Tools for Technology Transfer, 26(2), 207-228
Open this publication in new window or tab >>Formally verifying decompositions of stochastic specifications
2024 (English)In: International Journal on Software Tools for Technology Transfer, ISSN 1433-2779, E-ISSN 1433-2787, Vol. 26, no 2, p. 207-228Article in journal (Refereed) Published
Abstract [en]

According to the principles of compositional verification, verifying that lower-level components satisfy their specification ensures that the whole system satisfies its top-level specification. The key step is to ensure that the lower-level specifications constitute a correct decomposition of the top-level specification. In a non-stochastic context, such decomposition can be analyzed using techniques of theorem proving. In industrial applications, especially in safety-critical systems, specifications are often of stochastic nature, for example, giving a bound on the probability that a system failure will occur before a given time. A decomposition of such a specification requires techniques beyond traditional theorem proving. The first contribution of the paper is a theoretical framework that allows the representation of, and reasoning about, stochastic and timed behavior of systems as well as specifications for such behavior. The framework is based on traces that describe the continuous-time evolution of a system, and specifications are formulated using timed automata combined with probabilistic acceptance conditions. The second contribution is a novel approach to verifying decompositions of such specifications by reducing the problem to checking emptiness of the solution space for a system of linear inequalities.

Place, publisher, year, edition, pages
Springer Nature, 2024
Keywords
Automata, Contracts, Refinement, Specification theory
National Category
Computer Systems
Identifiers
urn:nbn:se:kth:diva-367078 (URN)10.1007/s10009-024-00742-5 (DOI)001168918400001 ()2-s2.0-85185288333 (Scopus ID)
Note

QC 20250715

Available from: 2025-07-15 Created: 2025-07-15 Last updated: 2025-07-15Bibliographically approved
Kaalen, S., Nyberg, M., Strandberg, T., Warg, F. & Westerberg, A. (2024). Probabilistic Approach Using SMP Tool For Systems Safety Of Road Vehicles. In: Kolowrocki, K Dabrowska, E (Ed.), Advances In Reliability, Safety And Security, Esrel 2024, Pt 3: . Paper presented at 34th European Safety and Reliability Conference, JUN 23-27, 2024, Krakow, POLAND (pp. 87-96). INST QUALITY ASSURANCE
Open this publication in new window or tab >>Probabilistic Approach Using SMP Tool For Systems Safety Of Road Vehicles
Show others...
2024 (English)In: Advances In Reliability, Safety And Security, Esrel 2024, Pt 3 / [ed] Kolowrocki, K Dabrowska, E, INST QUALITY ASSURANCE , 2024, p. 87-96Conference paper, Published paper (Refereed)
Abstract [en]

Safety analysis on the level of a complete road vehicle can be an intricate task. Several methods and tools for safety analysis have been developed by the research community. One such tool developed to bridge the gap between research and industry is Semi-Markov Process (SMP) Tool. In this paper, two approaches for safety analysis utilizing SMP Tool are presented. The holistic approach starts out with a quantitative safety target on a vehicle level to then finally argue whether a proposed system design is safe enough. In the segmented approach, the idea is to follow the development steps of industrial standards, while utilizing SMP Tool for specific tasks within the standard. Specifically the standard ISO 26262 will be under most consideration. Both approaches are applied to a case study of a battery management system for an electrified truck. The segmented approach can avoid some difficulties arising when following ISO 26262 conventionally while keeping the advantage that the standard is utilized to find what qualitative tasks should be performed. The holistic approach has an advantage in that it considers the safety from a vehicle perspective. Moreover, all ambiguity issues in ISO 26262 are avoided.

Place, publisher, year, edition, pages
INST QUALITY ASSURANCE, 2024
Keywords
safety, ISO 26262, probability, SMP Tool, quantitative, road vehicles
National Category
Vehicle and Aerospace Engineering
Identifiers
urn:nbn:se:kth:diva-374129 (URN)001542494800009 ()
Conference
34th European Safety and Reliability Conference, JUN 23-27, 2024, Krakow, POLAND
Note

Part of ISBN 978-83-68136-02-9

QC 20251215

Available from: 2025-12-15 Created: 2025-12-15 Last updated: 2025-12-15Bibliographically approved
Hampus, A. & Nyberg, M. (2023). Verifying Refinement of Probabilistic Contracts Using Timed Automata (With Proofs).
Open this publication in new window or tab >>Verifying Refinement of Probabilistic Contracts Using Timed Automata (With Proofs)
2023 (English)Report (Refereed)
Abstract [en]

Compositional verification allows a system to be verified indirectly by verifying the individual components of the system. The keystep is to ensure that the decomposition of the system specification intocomponent specifications is correct. That is, it needs to be verified thatthe composition of the component specifications refines the system specification. In many cyber-physical systems, specifications are probabilisticin nature. For instance, a specification might state that the probabilityof reaching an unsafe state within 10.000 hours shall be less than 0.05.Verifying refinement under such assumptions requires techniques beyondtraditional theorem proving. This paper presents a solution where specifications are built up by probabilistic contracts based upon timed automata. In particular, the main contribution is an algorithm for verifyingrefinement between such specifications. The algorithm utilizes a reduction to the language emptiness problem, making the algorithm terminateafter a finite number of computations

Publisher
p. 21
Series
TRITA-ITM-RP ; 2023:6
Keywords
Probabilistic Contracts, Automata, Algorithm
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-325814 (URN)
Note

QC 20230807

Available from: 2023-04-16 Created: 2023-04-16 Last updated: 2023-08-07Bibliographically approved
Hampus, A. & Nyberg, M. (2023). Verifying Refinement of Probabilistic Contracts Using Timed Automata. In: Theoretical Aspects of Software Engineering - 17th International Symposium, TASE 2023, Proceedings: . Paper presented at 17th International Symposium on Theoretical Aspects of Software Engineering, TASE 2023, Bristol, United Kingdom of Great Britain and Northern Ireland, July 4-6, 2023 (pp. 95-113). Springer Nature
Open this publication in new window or tab >>Verifying Refinement of Probabilistic Contracts Using Timed Automata
2023 (English)In: Theoretical Aspects of Software Engineering - 17th International Symposium, TASE 2023, Proceedings, Springer Nature , 2023, p. 95-113Conference paper, Published paper (Refereed)
Abstract [en]

Compositional verification allows a system to be verified indirectly by verifying the individual components of the system. The key step is to ensure that the decomposition of the system specification into component specifications is correct. That is, it needs to be verified that the composition of the component specifications refines the system specification. In many cyber-physical systems, specifications are probabilistic in nature. For instance, a specification might state that the probability of reaching an unsafe state within 10.000 h shall be less than 0.05. Verifying refinement under such assumptions requires techniques beyond traditional theorem proving. This paper presents a solution where specifications are built up by probabilistic contracts based upon timed automata. In particular, the main contribution is an algorithm for verifying refinement between such specifications. The algorithm utilizes a reduction to the language emptiness problem, making the algorithm terminate after a finite number of computations.

Place, publisher, year, edition, pages
Springer Nature, 2023
Keywords
Algorithms, Automata, Probabilistic Contracts
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-334441 (URN)10.1007/978-3-031-35257-7_6 (DOI)001330380200006 ()2-s2.0-85164938598 (Scopus ID)
Conference
17th International Symposium on Theoretical Aspects of Software Engineering, TASE 2023, Bristol, United Kingdom of Great Britain and Northern Ireland, July 4-6, 2023
Note

Part of ISBN 9783031352560

QC 20241203

Available from: 2023-08-21 Created: 2023-08-21 Last updated: 2024-12-03Bibliographically approved
Kaalen, S., Hampus, A., Nyberg, M. & Mattsson, O. (2022). A Stochastic Extension of Stateflow. In: Association for Computing Machinery, New York, NY, United States (Ed.), ICPE 22: Proceedings of the 2022 ACM/SPEC on International Conference on Performance Engineering: . Paper presented at 13th ACM/SPEC International Conference on Performance Engineering (pp. 211-222). Association for Computing Machinery (ACM)
Open this publication in new window or tab >>A Stochastic Extension of Stateflow
2022 (English)In: ICPE 22: Proceedings of the 2022 ACM/SPEC on International Conference on Performance Engineering / [ed] Association for Computing Machinery, New York, NY, United States, Association for Computing Machinery (ACM) , 2022, p. 211-222Conference paper, Published paper (Refereed)
Abstract [en]

Although commonly used in industry, a major drawback of Stateflow is that it lacks support for stochastic properties; properties that are often needed to build accurate models of real-world systems. In order to solve this problem, as the first contribution, Stochastic Stateflow (SSF) is presented as a stochastic extension of a subset of Stateflow models. As the second contribution, the tool SMP-tool is updated with support for SSF models specified in Stateflow. Finally, as the third contribution, an industrial case study is presented.  

 

Place, publisher, year, edition, pages
Association for Computing Machinery (ACM), 2022
Keywords
Stateflow, SSF, SMP-tool, Stochastic, Model-based
National Category
Computational Mathematics
Identifiers
urn:nbn:se:kth:diva-313247 (URN)10.1145/3489525.3511679 (DOI)000883411400023 ()2-s2.0-85128682345 (Scopus ID)
Conference
13th ACM/SPEC International Conference on Performance Engineering
Projects
SafeDim
Funder
Vinnova, 2020-05131
Note

Part of proceedings: ISBN 978-1-4503-9143-6

QC 20220621

Available from: 2022-06-01 Created: 2022-06-01 Last updated: 2023-01-16Bibliographically approved
Organisations
Identifiers
ORCID iD: ORCID iD iconorcid.org/0000-0001-6667-3783

Search in DiVA

Show all publications