On Augmenting Scenario-Based Modeling with Generative AI

David Harel, Guy Katz, Assaf Marron, Smadar Szekely

Introduction

The design of complex, reactive systems—ranging from industrial controllers to autonomous vehicles—is a notoriously difficult and error-prone endeavor. While Large Language Models (LLMs) like ChatGPT have emerged as powerful tools for generating code from natural language, their tendency to "hallucinate" or produce logically flawed "black box" solutions makes them risky for safety-critical applications. This paper explores a middle ground: using Scenario-Based Modeling (SBM) as a rigorous framework to harness the creative speed of Generative AI while maintaining formal soundness.

The SBM Framework: A Bridge for AI

Scenario-Based Modeling (SBM) decomposes system behavior into independent, modular "scenarios." Unlike monolithic codebases, SBM scenarios interact through three primary idioms: requesting an event, waiting-for an event, and blocking an event. This structure is inherently aligned with how humans describe requirements—as a series of rules or stories.

Figure 1: Scenario-Based Modeling of a Water Tank Controller, illustrating the interaction between AddHotWater, AddColdWater, and Stability scenarios.

As shown in Figure 1, a water tank controller can be modeled by separate scenarios that manage temperature and water levels. The "Stability" scenario can block "AddCold" while "AddHot" is requested, ensuring the system doesn't oscillate or violate safety constraints. This modularity makes it easier for both humans and AI to reason about specific behaviors without needing to grasp the entire system state at once.

Methodology: The Human-AI Feedback Loop

The proposed approach does not simply ask an AI to "write the code." Instead, it follows a structured four-step process:

  1. The Preamble: The LLM is provided with a specific set of rules defining SBM semantics. This "teaches" the AI to output transition systems rather than generic code.
  2. Iterative Prompting: Engineers describe requirements in natural language, and the LLM generates individual scenario objects.
  3. External Verification: The AI's output is verified outside the chatbot using formal model checkers or unit tests.
  4. The Feedback Loop: If errors are detected, the engineer refines the prompt rather than manually editing the code, ensuring the model remains a direct reflection of the requirements.
Figure 3: A tabular representation of scenario states (Wake-up, Requested, Blocked, Waited for), providing a formal view of system execution.

This formalization, exemplified by the state tracking in Figure 3, allows for precise debugging. The engineer can see exactly which scenario is blocking an event or waiting for a trigger, making the AI's logic transparent.

Key Insights and Case Studies

The authors found that LLMs excel at certain types of reasoning within this framework:

  • Explainability: When a system fails to perform a specific action (e.g., a "long beep" never occurs), the AI can analyze the scenario interactions to identify priority conflicts or starvation issues.
  • Arithmetic Reasoning: In traffic light simulations, the AI correctly identified periodic conflicts by calculating the least common multiple of light cycles, rather than relying on brute-force simulation.
  • Semantic Flexibility: LLMs can quickly adapt to different "flavors" of SBM logic (e.g., changing event handling rules) simply by updating the natural language prompt.

Case studies included a Water Tank Controller for temperature stability, Autonomous Vehicle Safety logic (handling conflicting goals like "stop at red" vs. "avoid rear-end collision"), and a Robot Bubble Sort implementation. In each case, the AI acted as a "co-pilot," handling high-level logic while the SBM framework provided the necessary guardrails.

Limitations and Future Outlook

Despite its promise, the approach has clear limitations. LLMs struggle with exhaustive tasks, such as listing every possible path in a grid, and occasionally produce incorrect retrospective logs for observed outcomes.

The ultimate vision is "Wise Computing"—a future where the computer is a proactive teammate that suggests fixes and identifies under-specified requirements. Integrating chatbots directly into SBM development environments will be a critical next step in making this vision a reality.

Summary updated

BibTeX
@inproceedings{harel2024augmenting,
  author = {David Harel and Guy Katz and Assaf Marron and Smadar Szekely},
  title = {{On Augmenting Scenario-Based Modeling with Generative AI}},
  booktitle = {MODELSWARD},
  year = {2024},
  url = {https://openreview.net/forum?id=O3mIvvm3ax},
}
Figure