Scenario-Based Programming with LLMs

A developer has an LLM write small scenario objects for a behavioural program, runs a model checker on the result, and hands its counterexample traces back to the LLM to fix the strategy.

Read the paper

In one paragraph

Scenario-Based Programming with LLMs (2025, code verification) uses verifier-guided repair, pairing generator OpenAI GPT-4 (low temperature), then Claude with authority BPPy explicit-state model checker (DFSBProgramVerifier). The resulting Connect4 agent won every game against three online AI opponents. Limit: a single case study, with a human relaying verifier output and diagnosing when the LLM fails.

Verified against primary sources on · It matched its sources.

How does Scenario-Based Programming with LLMs work?

  1. Proposes

    Scenario objects (b-threads) in BPPy, written by GPT-4 and later Claude, for a Connect4 agent

  2. Judged by

    BPPy's explicit-state model checker (DFSBProgramVerifier) and games against external agents

  3. Steers

    The developer presents counterexample traces (for example a losing diagonal fork) to the LLM, confirms or corrects its diagnosis, and asks it for a new scenario

What did Scenario-Based Programming with LLMs report?

The resulting Connect4 agent won every game against three online AI opponents (10 matches against the non-deterministic Pro Player), and from each of six fixed openings the model checker showed it wins.

What does Scenario-Based Programming with LLMs not prove?

A single case study, with a human relaying verifier output and diagnosing when the LLM fails; the model checker does not scale to the full Connect4 state space, so verification covers only six fixed openings.

What a pass means here

The judge is a formal check, so a pass is exact for the statement it checks, not for what the user meant. The loop runs at design time, and its output is used afterwards.

See how this kind of check sits among the others: how to validate LLM output with code.

How it generalizes the harness

A model checker over the behavioural program decides whether the strategy can lose; the LLM only writes the scenario code.

Classification

Classification of Scenario-Based Programming with LLMs
Classification dimensionVerified value
What it proposesProgram
Generative modelOpenAI GPT-4 (low temperature), then Claude
Algorithmic authorityBPPy explicit-state model checker (DFSBProgramVerifier)
FeedbackVerifier errors
What gets updatedPrompt context
When it runsOffline, at design time
ValidityFormal (machine-checked)
EvidenceExperiments reported
LineageOriginal system