Behavioral Programming

Requirements documents describe a system one behavior at a time: “lower the gate when a train approaches”, “never raise it while a train is inside”. Most code does not look like that. A single requirement ends up spread across many functions, and a single function serves many requirements. Behavioral programming (BP) is a scenario-based paradigm that keeps the two aligned, and our group has been extending it since 2018.

How behavioral programs run

A behavioral program is a set of independent modules called b-threads, each implementing one requirement or scenario. B-threads run in lockstep. At every synchronization point, each b-thread declares which events it requests, which it waits for and which it blocks. An event arbiter then selects an event that is requested and not blocked, and notifies the b-threads that requested or waited for it. Because the protocol does the composition, a new requirement is added as a new b-thread without changing existing ones, and a requirement that forbids something is written as a b-thread that blocks it. The same model can be executed, simulated, or explored exhaustively for verification.

The behavioral programming execution cycle and our research directions In the center, b-threads declare the events they request, wait for and block; an event arbiter selects an event that is requested and not blocked and notifies the b-threads. Around it are five research directions, each linking to its section below: semantics, context, machine learning, automatic generation and testing. The BP execution cycle b-thread · requests A b-thread · waits for B b-thread · blocks C declare notify Event arbiter selects an event that is requested and not blocked Semantics What BP can express composition · liveness Context Context idioms LSC idioms · COBP Machine learning Guided DRL scenarios as rules Generation GP and LLMs code from requirements Testing Test suites coverage · Provengo
The BP execution cycle and the directions in which we extend it. Select a direction to jump to its section.

Semantics and expressiveness Back to top

BP’s central claim is that the execution protocol, not the modeler, should combine requirements. What Petri Nets Oblige Us to Say tests that claim against Petri nets. When several requirements share one net, the modeler must also specify how they combine, which leads to over-specification, missed execution paths and unintended ones. BP avoids this while keeping the same mathematical properties. Context-Oriented Behavioral Programming gives formal semantics, and two implementations, for b-threads that read and update a context data model, so verification and reasoning apply to context-aware programs too.

The original protocol can only enforce safety: what the system must not do. We added a must-finish idiom that marks states in which a task is still pending, so liveness requirements such as “do X at least three times” are written directly as b-threads (RE 2024). The journal version adds two execution mechanisms, one through Büchi automata and one through Markov decision processes, and a user study showing that the idiom improves the alignment between code and requirements.

Papers

  1. Adding liveness to behavioral programming: theory, implementation, and user study Tom Yaacov, Achiya Elyasaf, Gera Weiss Requirements Engineering, pp. 1–23, 2025
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    This paper investigates how Behavioral Programming (BP), and executable specifications in general, can more effectively align models with requirements, addressing a key motivation behind BP’s development. While BP has traditionally supported safety requirements—defining what a system may, must, and must not do—it lacks direct mechanisms for expressing liveness requirements, which ensure that certain tasks are eventually completed. We introduce a “must-finish” idiom for BP, allowing explicit specification of liveness requirements. We demonstrate how this approach allows for the direct representation of common requirements patterns, supported by a user study that highlights positive outcomes, particularly in improving the alignment between software components and their corresponding requirements. While formal modeling languages that allow specification of liveness requirements are mostly used in the context of model-checking and synthesis, the focus of BP is on the executability of the model. To this end, we propose two execution mechanisms: one based on translation to Büchi automata and another using Markov decision processes (MDP), with the latter offering scalability through deep reinforcement learning. A formal analysis of the MDP-based mechanism is provided, together with qualitative and quantitative evaluations of a proof-of-concept tool.

    [bib]
    @article{yaacov2025adding,
      author = {Yaacov, Tom and Elyasaf, Achiya and Weiss, Gera},
      journal = {Requirements Engineering},
      title = {Adding liveness to behavioral programming: theory, implementation, and user study},
      year = {2025},
      pages = {1--23},
      doi = {10.1007/s00766-025-00439-4},
      publisher = {Springer},
      groups = {Behavioral Programming, Software Engineering}
    }
    
  2. Keeping Behavioral Programs Alive: Specifying and Executing Liveness Requirements Tom Yaacov, Achiya Elyasaf, Gera Weiss 2024 IEEE 32nd International Requirements Engineering Conference (RE), pp. 91-102, 2024
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    One of the benefits of using executable specifications such as Behavioral Programming (BP) is the ability to align the system implementation with its requirements. This is facilitated in BP by a protocol that allows independent implementation modules that specify what the system may, must, and must not do. By that, each module can enforce a single system requirement, including negative specifications such as “don't do X after Y.” The existing BP protocol, however, allows only the enforcement of safety requirements and does not support the execution of liveness properties such as “do X at least three times.” To model liveness requirements in BP directly and independently, we propose idioms for tagging states with “must-finish;’ indicating that tasks are yet to be completed. We show that this idiom allows a direct specification of known requirements patterns from the literature. We also offer semantics and two execution mechanisms, one based on a translation to Büchi automata and the other based on a Markov decision process (MDP). The latter approach offers the possibility of utilizing deep reinforcement learning (DRL) algorithms, which bear the potential to handle large software systems effectively. This paper presents a qualitative and quantitative assessment of the proposed approach using a proof-of-concept tool. A formal analysis of the MDP-based execution mechanism is given in an appendix.

    [bib]
    @inproceedings{Yaacov2024Liveness,
      author = {Yaacov, Tom and Elyasaf, Achiya and Weiss, Gera},
      booktitle = {2024 IEEE 32nd International Requirements Engineering Conference (RE)},
      title = {Keeping Behavioral Programs Alive: Specifying and Executing Liveness Requirements},
      year = {2024},
      address = {Los Alamitos, CA, USA},
      month = jun,
      pages = {91-102},
      publisher = {IEEE Computer Society},
      doi = {10.1109/RE59067.2024.00019},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      keywords = {protocols;software algorithms;semantics;tagging;programming;software systems;safety},
      url = {https://doi.ieeecomputersociety.org/10.1109/RE59067.2024.00019}
    }
    
  3. What Petri Nets Oblige us to Say Comparing Approaches for Behavior Composition Achiya Elyasaf, Tom Yaacov, Gera Weiss IEEE Transactions on Software Engineering, vol. 49, no. 4, pp. 2303–2317, 2023
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    We identify and demonstrate a weakness of Petri Nets (PN) in specifying composite behavior of reactive systems. Specifically, we show how, when specifying multiple requirements in one PN model, modelers are obliged to specify mechanisms for combining these requirements. This yields, in many cases, over-specification and incorrect models. We demonstrate how some execution paths are missed, and some are generated unintentionally. To support this claim, we analyze PN models from the literature, identify the combination mechanisms, and demonstrate their effect on the correctness of the model. To address this problem, we propose to model the system behavior using behavioral programming (BP), a software development and modeling paradigm designed for seamless integration of independent requirements. Specifically, we demonstrate how the semantics of BP, which define how to interweave scenarios into a single model, allow for avoiding the over-specification. Additionally, while BP maintains the same mathematical properties as PN, it provides means for changing the model dynamically, thus increasing the agility of the specification. We compare BP and PN in quantitative and qualitative measures by analyzing the models, their generated execution paths, and the specification process. Finally, while BP is supported by tools that allow for applying formal methods and reasoning techniques to the model, it lacks the legacy of PN tools and algorithms. To address this issue, we propose semantics and a tool for translating BP models to PN and vice versa.

    [bib]
    @article{Elyasaf2023BPPN,
      author = {Elyasaf, Achiya and Yaacov, Tom and Weiss, Gera},
      journal = {IEEE Transactions on Software Engineering},
      title = {What Petri Nets Oblige us to Say Comparing Approaches for Behavior Composition},
      year = {2023},
      number = {4},
      pages = {2303--2317},
      volume = {49},
      doi = {10.1109/TSE.2022.3216683},
      groups = {Behavioral Programming, Software Engineering},
      url = {https://doi.org/10.1109/TSE.2022.3216683}
    }
    
  4. Context-Oriented Behavioral Programming Achiya Elyasaf Information and Software Technology, vol. 133, pp. 106504, 2021
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    Context: Modern systems require programmers to develop code that dynamically adapts to different contexts, leading to the evolution of new context-oriented programming languages. These languages introduce new software-engineering challenges, such as: how to maintain the separation of concerns of the codebase? how to model the changing behaviors? how to verify the system behavior? and more. Objective: This paper introduces Context-Oriented Behavioral Programming (COBP) — a novel paradigm for developing context-aware systems, centered on natural and incremental specification of context-dependent behaviors. As the name suggests, we combine behavioral-programming (BP) — a scenario-based modeling paradigm — with context idioms that explicitly specify when scenarios are relevant and what information they need. The core idea is to connect the behavioral model with a data model that represents the context, allowing an intuitive connection between the models via update and select queries. Combining behavioral-programming with context-oriented programming brings the best of the two worlds, solving issues that arise when using each of the approaches in separation. Methods: We begin with providing abstract semantics for COBP and two implementations for the semantics, laying the foundations for applying reasoning algorithms to context-aware behavioral programs. Next, we exemplify the semantics with formal specifications of systems, including a variant of Conway’s Game of Life. Then, we provide two case studies of real-life context-aware systems (one in robotics and another in IoT) that were developed using this tool. Throughout the examples and case studies, we provide design patterns and a methodology for coping with the above challenges. Results: The case studies show that the proposed approach is applicable for developing real-life systems, and presents measurable advantages over the alternatives — behavioral programming alone and context-oriented programming alone. Conclusion: We present a paradigm allowing programmers and system engineers to capture complex context-dependent requirements and align their code with such requirements.

    [bib]
    @article{Elyasaf2020COBP,
      author = {Elyasaf, Achiya},
      journal = {Information and Software Technology},
      title = {{Context-Oriented Behavioral Programming}},
      year = {2021},
      issn = {0950-5849},
      month = may,
      pages = {106504},
      volume = {133},
      doi = {10.1016/j.infsof.2020.106504},
      groups = {Behavioral Programming, Software Engineering},
      keywords = {Behavioral programming, Scenario-based programming, Programming paradigm, Context awareness, Context-oriented programming, Context-Oriented Behavioral Programming},
      publisher = {Elsevier {BV}},
      url = {https://doi.org/10.1016/j.infsof.2020.106504}
    }
    

Context-oriented behavioral programming Back to top

IoT devices and robots behave differently depending on their situation, and flat scenario specifications become unwieldy as conditions, exceptions and refinements pile up. We first proposed subjecting scenarios in live sequence charts (LSC) to context, using existing LSC idioms or embedding the charts in statecharts (2018), and then added dedicated context idioms to LSC for IoT systems. COBP carries these ideas into BP. Each b-thread states when it is relevant and what data it needs through queries on a context model, so context-dependent behavior stays aligned with the requirements. Case studies in robotics and IoT showed advantages over BP alone and over context-oriented programming alone.

Papers

  1. Context-Oriented Behavioral Programming Achiya Elyasaf Information and Software Technology, vol. 133, pp. 106504, 2021
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    Context: Modern systems require programmers to develop code that dynamically adapts to different contexts, leading to the evolution of new context-oriented programming languages. These languages introduce new software-engineering challenges, such as: how to maintain the separation of concerns of the codebase? how to model the changing behaviors? how to verify the system behavior? and more. Objective: This paper introduces Context-Oriented Behavioral Programming (COBP) — a novel paradigm for developing context-aware systems, centered on natural and incremental specification of context-dependent behaviors. As the name suggests, we combine behavioral-programming (BP) — a scenario-based modeling paradigm — with context idioms that explicitly specify when scenarios are relevant and what information they need. The core idea is to connect the behavioral model with a data model that represents the context, allowing an intuitive connection between the models via update and select queries. Combining behavioral-programming with context-oriented programming brings the best of the two worlds, solving issues that arise when using each of the approaches in separation. Methods: We begin with providing abstract semantics for COBP and two implementations for the semantics, laying the foundations for applying reasoning algorithms to context-aware behavioral programs. Next, we exemplify the semantics with formal specifications of systems, including a variant of Conway’s Game of Life. Then, we provide two case studies of real-life context-aware systems (one in robotics and another in IoT) that were developed using this tool. Throughout the examples and case studies, we provide design patterns and a methodology for coping with the above challenges. Results: The case studies show that the proposed approach is applicable for developing real-life systems, and presents measurable advantages over the alternatives — behavioral programming alone and context-oriented programming alone. Conclusion: We present a paradigm allowing programmers and system engineers to capture complex context-dependent requirements and align their code with such requirements.

    [bib]
    @article{Elyasaf2020COBP,
      author = {Elyasaf, Achiya},
      journal = {Information and Software Technology},
      title = {{Context-Oriented Behavioral Programming}},
      year = {2021},
      issn = {0950-5849},
      month = may,
      pages = {106504},
      volume = {133},
      doi = {10.1016/j.infsof.2020.106504},
      groups = {Behavioral Programming, Software Engineering},
      keywords = {Behavioral programming, Scenario-based programming, Programming paradigm, Context awareness, Context-oriented programming, Context-Oriented Behavioral Programming},
      publisher = {Elsevier {BV}},
      url = {https://doi.org/10.1016/j.infsof.2020.106504}
    }
    
  2. A Context-Based Behavioral Language for IoT Achiya Elyasaf, Assaf Marron, Arnon Sturm, Gera Weiss CEUR Workshop Proceedings, vol. 2245, pp. 485–494, 2018
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    As devices, platforms, and technologies for IoT (Internet-of-Things) and robots, develop, the question of how to best specify the behavior of such systems so that it is both robust and manageable becomes central. Current practices may suffice when working with simple requirements. However, behavior specification given in current languages often become unwieldy as they grow to accommodate complex conditions, exceptions, and priorities. To address this, we propose to use the scenariobased programming approach, and specifically, the graphical language of live sequence charts (LSC). This addresses one aspect of the specification growth issue by allowing a natural break-down of the specification in alignment with the requirements. The other aspect of our solution, aiming at further simplifying and shortening the specification, is based on subjecting these scenarios to context—a key concept in IoT and autonomous robot modeling. Specifically, we propose additions to LSC for subjecting behavioral scenario charts to contexts and a methodology to work with these idioms.

    [bib]
    @inproceedings{Elyasaf2018LSC4IoT,
      author = {Elyasaf, Achiya and Marron, Assaf and Sturm, Arnon and Weiss, Gera},
      booktitle = {{{CEUR Workshop Proceedings}}},
      title = {{A Context-Based Behavioral Language for IoT}},
      year = {2018},
      address = {{Copenhagen, Denmark}},
      editor = {{Regina Hebig and Thorsten Berger}},
      pages = {485--494},
      publisher = {{CEUR-WS.org}},
      volume = {2245},
      copyright = {All rights reserved},
      groups = {Behavioral Programming, Software Engineering},
      timestamp = {2019-10-22T20:25:23Z},
      url = {http://ceur-ws.org/Vol-2245}
    }
    
  3. Towards Integration of Context-Based and Scenario-Based Development Achiya Elyasaf, David Harel, Assaf Marron, Gera Weiss Springer, Cham, vol. 10748 LNCS, 2018
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    In scenario-based models of reactive systems complex specifications are divided into artifacts corresponding to separate aspects of overall system behavior, as they may appear, e.g., in a robot’s requirements document or user specifications. The advantages of scenario-based development include intuitiveness and clarity, the ability to execute or simulate specifications of early prototypes and of final systems, and the ability to verify the specification for early detection of conflicts, omissions, and errors. In this position paper we discuss two issues that emerge when applying scenario-based development in complex cases: (a) simple scenarios become unwieldy when subjected to a growing number of conditions, exceptions and refinements, and (b) it is hard to understand and maintain a large ‘flat’ specification, consisting of an unorganized list of independently-specified scenarios, simple as they may individually be. We address these issues by basing certain facets of scenario design on context, an increasingly popular foundational consideration in software engineering. We first show how one can incorporate context into the graphical language of live sequence charts (LSC) using existing LSC idioms. We then outline two other possibilities: (i) enriching the LSC language, or (ii) embedding LSCs within hierarchical state machines, namely, statecharts. We believe that this research can contribute to the broader goals of developing complex and powerful reactive systems in intuitive and robust ways.

    [bib]
    @book{Elyasaf2018IntegrationContextBased,
      author = {Elyasaf, Achiya and Harel, David and Marron, Assaf and Weiss, Gera},
      publisher = {{Springer, Cham}},
      title = {Towards {{Integration}} of {{Context}}-{{Based}} and {{Scenario}}-{{Based Development}}},
      year = {2018},
      isbn = {978-3-319-74729-3},
      volume = {10748 LNCS},
      copyright = {All rights reserved},
      doi = {10.1007/978-3-319-74730-9_21},
      groups = {Behavioral Programming, Software Engineering},
      url = {https://doi.org/10.1007/978-3-319-74730-9_21}
    }
    

Scenarios and machine learning Back to top

Deep reinforcement learning (DRL) agents perform well, but they are opaque and may violate requirements that engineers care about. Scenarios are small, readable and verifiable, which makes them a natural complement. For a simplified RoboCup-type game, we built four BP controllers, extending the base protocol with a constraint solver, context idioms and a DRL component. A position paper outlines how scenarios, together with verification, can guard and repair neural-network controllers. Scenario-assisted DRL and its journal extension inject expert scenarios into the reward function during training. In internet congestion control, the resulting agents were far more likely to obey the specified constraints, and the scenarios help explain their decisions. In the other direction, the MDP-based execution of must-finish requirements scales through DRL.

Our survey gives a framework for categorizing the ways machine learning can be integrated with executable specifications, and guidelines for choosing among them during system development.

Papers

  1. Adding liveness to behavioral programming: theory, implementation, and user study Tom Yaacov, Achiya Elyasaf, Gera Weiss Requirements Engineering, pp. 1–23, 2025
    • Behavioral Programming
    • Software Engineering
    view online
    [abstract]

    This paper investigates how Behavioral Programming (BP), and executable specifications in general, can more effectively align models with requirements, addressing a key motivation behind BP’s development. While BP has traditionally supported safety requirements—defining what a system may, must, and must not do—it lacks direct mechanisms for expressing liveness requirements, which ensure that certain tasks are eventually completed. We introduce a “must-finish” idiom for BP, allowing explicit specification of liveness requirements. We demonstrate how this approach allows for the direct representation of common requirements patterns, supported by a user study that highlights positive outcomes, particularly in improving the alignment between software components and their corresponding requirements. While formal modeling languages that allow specification of liveness requirements are mostly used in the context of model-checking and synthesis, the focus of BP is on the executability of the model. To this end, we propose two execution mechanisms: one based on translation to Büchi automata and another using Markov decision processes (MDP), with the latter offering scalability through deep reinforcement learning. A formal analysis of the MDP-based mechanism is provided, together with qualitative and quantitative evaluations of a proof-of-concept tool.

    [bib]
    @article{yaacov2025adding,
      author = {Yaacov, Tom and Elyasaf, Achiya and Weiss, Gera},
      journal = {Requirements Engineering},
      title = {Adding liveness to behavioral programming: theory, implementation, and user study},
      year = {2025},
      pages = {1--23},
      doi = {10.1007/s00766-025-00439-4},
      publisher = {Springer},
      groups = {Behavioral Programming, Software Engineering}
    }
    
  2. Categorizing Methods for Integrating Machine Learning with Executable Specifications David Harel, Raz Yerushalmi, Assaf Marron, Achiya Elyasaf Science China Information Sciences, vol. 67, no. 1, 2024
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    Deep learning (DL), which includes deep reinforcement learning (DRL), holds great promise for carrying out real-world tasks that human minds seem to cope with quite readily. That promise is already delivering extremely impressive results in a variety of areas. However, while DL-enabled systems achieve excellent performance, they are far from perfect. It has been demonstrated, in several domains, that DL systems can err when they encounter cases they had not hitherto encountered. Furthermore, the opacity of the produced agents makes it difficult to explain their behavior and ensure that they adhere to various requirements posed by human engineers. At the other end of the software development spectrum of methods, behavioral programming (BP) facilitates orderly system development using self-standing executable modules aligned with how humans intuitively describe desired system behavior. In this paper, we elaborate on different approaches for combining DRL with BP and, more generally, machine learning (ML) with executable specifications (ES). We begin by defining a framework for studying the various approaches, which can also be used to study new emerging approaches not covered here. We then briefly review state-of-the-art approaches to integrating ML with ES, continue with a focus on DRL, and then present the merits of integrating ML with BP. We conclude with guidelines on how this categorization can be used in decision making in system development, and outline future research challenges.

    [bib]
    @article{Harel2024CategorizingMethodsIntegrating,
      author = {Harel, David and Yerushalmi, Raz and Marron, Assaf and Elyasaf, Achiya},
      journal = {Science China Information Sciences},
      title = {{Categorizing Methods for Integrating Machine Learning with Executable Specifications}},
      year = {2024},
      issn = {1869-1919},
      month = oct,
      number = {1},
      volume = {67},
      doi = {10.1007/s11432-022-3826-6},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      publisher = {Springer}
    }
    
  3. Enhancing Deep Reinforcement Learning with Scenario-Based Modeling Raz Yerushalmi, Guy Amir, Achiya Elyasaf, David Harel, Guy Katz, Assaf Marron SN Computer Science, vol. 4, no. 2, pp. 156, 2023
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    Deep reinforcement learning agents have achieved unprecedented results when learning to generalize from unstructured data. However, the “black-box” nature of the trained DRL agents makes it difficult to ensure that they adhere to various requirements posed by engineers. In this work, we put forth a novel technique for enhancing the reinforcement learning training loop, and specifically—its reward function, in a way that allows engineers to directly inject their expert knowledge into the training process. This allows us to make the trained agent adhere to multiple constraints of interest. Moreover, using scenario-based modeling techniques, our method allows users to formulate the defined constraints using advanced, well-established, behavioral modeling methods. This combination of such modeling methods together with ML learning tools produces agents that are both high performing and more likely to adhere to prescribed constraints. Furthermore, the resulting agents are more transparent and hence more maintainable. We demonstrate our technique by evaluating it on a case study from the domain of internet congestion control, and present promising results.

    [bib]
    @article{Yerushalmi2023EnhancingDRL,
      author = {Yerushalmi, Raz and Amir, Guy and Elyasaf, Achiya and Harel, David and Katz, Guy and Marron, Assaf},
      journal = {{SN} Computer Science},
      title = {{Enhancing Deep Reinforcement Learning with Scenario-Based Modeling}},
      year = {2023},
      month = jan,
      number = {2},
      pages = {156},
      volume = {4},
      doi = {10.1007/s42979-022-01575-2},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      publisher = {Springer Science and Business Media {LLC}}
    }
    
  4. Scenario-assisted Deep Reinforcement Learning Raz Yerushalmi, Guy Amir, Achiya Elyasaf, David Harel, Guy Katz, Assaf Marron Proceedings of the 10th International Conference on Model-Driven Engineering and Software Development - MODELSWARD, pp. 310–319, 2022
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    Deep reinforcement learning has proven remarkably useful in training agents from unstructured data. However, the opacity of the produced agents makes it difficult to ensure that they adhere to various requirements posed by human engineers. In this work-in-progress report, we propose a technique for enhancing the reinforcement learning training process (specifically, its reward calculation), in a way that allows human engineers to directly contribute their expert knowledge, making the agent under training more likely to comply with various relevant constraints. Moreover, our proposed approach allows formulating these constraints using advanced model engineering techniques, such as scenario-based modeling. This mix of black-box learning-based tools with classical modeling approaches could produce systems that are effective and efficient, but are also more transparent and maintainable. We evaluated our technique using a case-study from the domain of internet congestion control, obtaining promising results.

    [bib]
    @conference{Yerushalmi2022ScenarioassistedDeep,
      author = {Yerushalmi, Raz and Amir, Guy and Elyasaf, Achiya and Harel, David and Katz, Guy and Marron, Assaf},
      booktitle = {Proceedings of the 10th International Conference on Model-Driven Engineering and Software Development - MODELSWARD},
      title = {Scenario-assisted Deep Reinforcement Learning},
      year = {2022},
      organization = {INSTICC},
      pages = {310--319},
      publisher = {SciTePress},
      doi = {10.5220/0010904700003119},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      isbn = {978-989-758-550-0},
      issn = {2184-4348},
      url = {https://doi.org/10.5220/0010904700003119}
    }
    
  5. Towards Combining Deep Learning, Verification, and Scenario-Based Programming Guy Katz, Achiya Elyasaf Proceedings of the 1st International Workshop on Verification of Autonomous & Robotic Systems, 2021
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [bib]
    @inproceedings{Katz2021TowardsCombiningDeep,
      author = {Katz, Guy and Elyasaf, Achiya},
      booktitle = {Proceedings of the 1st International Workshop on Verification of Autonomous \& Robotic Systems},
      title = {{Towards Combining Deep Learning, Verification, and Scenario-Based Programming}},
      year = {2021},
      address = {New York, NY, USA},
      publisher = {Association for Computing Machinery},
      series = {VARS '21},
      articleno = {5},
      doi = {10.1145/3459086.3459631},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      isbn = {9781450384445},
      location = {Nashville, Tennessee},
      numpages = {3},
      url = {https://doi.org/10.1145/3459086.3459631}
    }
    
  6. Using Behavioral Programming with Solver, Context, and Deep Reinforcement Learning for Playing a Simplified RoboCup-Type Game Achiya Elyasaf, Aviran Sadon, Gera Weiss, Tom Yaacov 2019 ACM/IEEE 22nd International Conference on Model Driven Engineering Languages and Systems Companion (MODELS-C), pp. 243–251, 2019
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    We describe four scenario-based implementations of controllers for a player in a simplified RoboCup-type game. All four implementations are based on the behavioural programming (BP) approach. We first describe a simple controller for the player using the state-of-the-art BPjs tool and then show how it can be extended in various ways. The first extension is based on a version of BP where the Z3 SMT solver is used to provide mechanisms for richer composition of modules within the BP model. This allows for modules with higher cohesion and lower coupling. It also allows incrementality: we could use the scenarios we developed for the challenge of MDETOOLS’18 and extend the model to handle the new system. The second extension of BP demonstrated in this paper is a set of idioms for subjecting model components to context. One of the differences between this year’s challenge and the challenge we dealt with last year is that following the ball is not the only task that a player needs to handle, there is much more to care for. We demonstrate how we used the idioms for handling context to parametrize scenarios like "go to a target" in a dynamic and natural fashion such that modelers can efficiently specify reusable components similar to the way modern user manuals for advanced products are written. Lastly, in an attempt to make the instructions to the robot even more natural, we demonstrate a third extension based on deep reinforcement learning. Towards substantiating the observation that it is easier to explain things to an intelligent agent than to dumb compiler, we demonstrate how the combination of BP and deep reinforcement learning (DRL) allows for giving abstract instructions to the robot and for teaching it to follow them after a short training session.

    [bib]
    @inproceedings{Elyasaf2019RoboCup,
      author = {Elyasaf, Achiya and Sadon, Aviran and Weiss, Gera and Yaacov, Tom},
      booktitle = {2019 {ACM}/{IEEE} 22nd International Conference on Model Driven Engineering Languages and Systems Companion ({MODELS}-C)},
      title = {{Using Behavioral Programming with Solver, Context, and Deep Reinforcement Learning for Playing a Simplified RoboCup-Type Game}},
      year = {2019},
      month = sep,
      pages = {243--251},
      publisher = {{IEEE}},
      doi = {10.1109/models-c.2019.00039},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      timestamp = {2019-10-22T19:55:05Z},
      url = {https://doi.org/10.1109/models-c.2019.00039}
    }
    

Automatic generation of behavioral programs Back to top

Because each b-thread implements one requirement, behavioral programs are small, regular and checkable, which makes them a good target for automatic generation. Evolution of Behavioral Programs uses genetic programming with COBP to evolve complete programs from scratch. The evolved tic-tac-toe player loses or misses a win in fewer than one percent of the possible cases, consists of readable modules that resemble the handcrafted program, and was verified over all execution paths. Boosting LLM-based software generation uses BP as the design for LLM code generation. Each requirement, including the scenarios that must not happen, is translated into its own module without a global view of the system, and on a railway level-crossing controller the generated BP code aligned with the requirements better than plain Python.

Papers

  1. Boosting LLM-Based Software Generation by Aligning Code with Requirements Tom Yaacov, Achiya Elyasaf, Gera Weiss 2024 IEEE 32nd International Requirements Engineering Conference Workshops (REW), pp. 301-305, 2024
    • Artificial Intelligence
    • Behavioral Programming
    • Machine Learning
    • Software Engineering
    view online
    [abstract]

    Emerging LLM-based code generation tools enable programmers to specify desired functionality and automatically generate code. However, these tools fall short in comparison to human ability when it comes to creating complete system models from requirements. This is because humans typically formulate a software design before implementing a system. In this paper, we propose to use the behavioral programming (BP) model-based paradigm as a general design approach that allows for the direct translation of requirements of any reactive systems into code. We demonstrate that each requirement can be automatically transformed into a dedicated code module without the need for a global view of the system. The key lies in BP’s capability to enable modules to implement both scenarios and anti-scenarios separately. This means that each module can independently define behaviors that may happen, must happen, and must not happen. Subsequently, an application-agnostic execution engine interprets and interweaves these modules at runtime to generate cohesive system behavior consistent with system requirements. The fact that each requirement is translated into a small module also facilitates the verification of its implementation, thereby helping to reduce errors in LLM code generation. We present an initial evaluation of our approach and demonstrate how the characteristics of BP aid in generating aligned and correct implementations.

    [bib]
    @inproceedings{Yaacov2024BoostingLLMBP,
      author = {Yaacov, Tom and Elyasaf, Achiya and Weiss, Gera},
      booktitle = {2024 IEEE 32nd International Requirements Engineering Conference Workshops (REW)},
      title = {Boosting LLM-Based Software Generation by Aligning Code with Requirements},
      year = {2024},
      month = jun,
      pages = {301-305},
      doi = {10.1109/REW61692.2024.00045},
      groups = {Artificial Intelligence, Behavioral Programming, Machine Learning, Software Engineering},
      issn = {2770-6834},
      keywords = {Analytical models;Codes;Software design;Runtime;Programming;Software;Requirements engineering;behavioral programming;large language models;requirement engineering}
    }
    
  2. From Requirements to Source Code: Evolution of Behavioral Programs Roy Poliansky, Moshe Sipper, Achiya Elyasaf Applied Sciences, vol. 12, no. 3, 2022
    • Artificial Intelligence
    • Behavioral Programming
    • Evolutionary Computation
    • Software Engineering
    view online
    [abstract]

    Automatically generating executable code has a long history of arguably modest success, mostly limited to the generation of small programs of up to 200 lines of code, and genetic improvement of existing code. We present the use of genetic programming (GP) in conjunction with context-oriented behavioral programming (COBP), the latter being a programming paradigm with unique characteristics that facilitate automatic coding. COBP models a program as a set of behavioral threads (b-threads), each aligned to a single behavior or requirement of the system. To evolve behavioral programs we design viable and effective genetic operators, a genetic representation, and evaluation methods. The simplicity of the COBP paradigm, its straightforward syntax, the ability to use verification and formal-method techniques to validate program correctness, and a program comprising small independent chunks all allow us to effectively generate behavioral programs using GP. To demonstrate our approach we evolve complete programs from scratch of a highly competent O player for the game of tic-tac-toe. The evolved programs are well structured, consisting of multiple, explainable modules that specify the different behavioral aspects of the program and are similar to our handcrafted program. To validate the correctness of our individuals, we utilize the mathematical characteristics of COBP to analyze program behavior under all possible execution paths. Our analysis of an evolved program proved that it plays as expected more than 99% of the times.

    [bib]
    @article{Poliansky2022BPGP,
      author = {Poliansky, Roy and Sipper, Moshe and Elyasaf, Achiya},
      journal = {Applied Sciences},
      title = {{From Requirements to Source Code: Evolution of Behavioral Programs}},
      year = {2022},
      issn = {2076-3417},
      number = {3},
      volume = {12},
      article-number = {1587},
      doi = {10.3390/app12031587},
      groups = {Artificial Intelligence, Behavioral Programming, Evolutionary Computation, Software Engineering},
      url = {https://doi.org/10.3390/app12031587}
    }
    

Scenario-driven testing Back to top

The same modularity serves testing: small b-threads describe the behaviors to exercise, and the execution engine explores their combinations. Generalized coverage criteria specify what a suite of action sequences must cover. A tool generates optimized test suites from test plans, and a Bayesian method estimates the remaining risk, balancing exploration against exploitation. Provengo, built on the BPjs engine, implements scenario-driven model-based testing. Testers write user stories as scenarios and grow the model incrementally, starting from simple stories.

Papers

  1. Generalized Coverage Criteria for Combinatorial Sequence Testing Achiya Elyasaf, Eitan Farchi, Oded Margalit, Gera Weiss, Yeshayahu Weiss IEEE Transactions on Software Engineering, pp. 1-12, 2023
    • Behavioral Programming
    • Testing
    • Software Engineering
    view online
    [abstract]

    We present a new model-based approach for testing systems that use sequences of actions and assertions as test vectors. Our solution includes a method for quantifying testing quality, a tool for generating high-quality test suites based on the coverage criteria we propose, and a framework for assessing risks. For testing quality, we propose a method that specifies generalized coverage criteria over sequences of actions, which extends previous approaches. Our publicly available tool demonstrates how to extract effective test suites from test plans based on these criteria. We also present a Bayesian approach for measuring the probabilities of bugs or risks, and show how this quantification can help achieve an informed balance between exploitation and exploration in testing. Finally, we provide an empirical evaluation demonstrating the effectiveness of our tool in finding bugs, assessing risks, and achieving coverage.

    [bib]
    @article{Elyasaf2023GeneralizedCoverageCriteria,
      author = {Elyasaf, Achiya and Farchi, Eitan and Margalit, Oded and Weiss, Gera and Weiss, Yeshayahu},
      journal = {IEEE Transactions on Software Engineering},
      title = {{Generalized Coverage Criteria for Combinatorial Sequence Testing}},
      year = {2023},
      pages = {1-12},
      doi = {10.1109/TSE.2023.3279570},
      groups = {Behavioral Programming, Testing, Software Engineering},
      url = {https://doi.org/10.1109/TSE.2023.3279570}
    }
    
  2. Provengo: A Tool Suite for Scenario Driven Model-Based Testing Michael Bar-Sinai, Achiya Elyasaf, Gera Weiss, Yeshayahu Weiss 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 2062–2065, 2023
    • Behavioral Programming
    • Testing
    • Software Engineering
    view online
    [abstract]

    We present Provengo, a comprehensive suite of tools designed to facilitate the implementation of Scenario-Driven Model-Based Testing (SDMBT), an innovative approach that utilizes scenarios to construct a model encompassing the user’s perspective and the system’s business value while also defining the desired outcomes. With the assistance of Provengo, testers gain the ability to effortlessly create natural user stories and seamlessly integrate them into a model capable of generating effective tests. The demonstration illustrates how SDMBT effectively addresses the bootstrapping challenge commonly encountered in model-based testing (MBT) by enabling incremental development, starting from simple models and gradually augmenting them with additional stories.

    [bib]
    @inproceedings{BarSinai2023ProvengoToolSuite,
      author = {Bar-Sinai, Michael and Elyasaf, Achiya and Weiss, Gera and Weiss, Yeshayahu},
      booktitle = {2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)},
      title = {Provengo: A Tool Suite for Scenario Driven Model-Based Testing},
      year = {2023},
      pages = {2062--2065},
      doi = {10.1109/ASE56229.2023.00146},
      groups = {Behavioral Programming, Testing, Software Engineering},
      keywords = {Testing;Software engineering;Business},
      url = {https://doi.org/10.1109/ASE56229.2023.00146}
    }