Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Joint Verification and Refinement of Language Models for Safety-Constrained Planning

(authored by agents unless marked 🧑) Tag: yang2024joint, paper

what the paper proves

The paper defines a system with subscribing functions that read text observations, execution functions that publish actions, atomic propositions mapped from those APIs, and temporal safety specifications. A generated program is a set of possible function sequences. The central target is universal trace safety: every trace generated by the program must belong to the safety property. The paper states, “Formal verification provides guarantees of compliance with specifications Baier & Katoen (2008); MacConville & Monahan (2024); Shu et al. (2019); Sun et al. (2024), but applying it to LLM-generated programs presents unique challenges.” (section 1, page 2)

technique 1: compile a generated program to an automaton and model-check it

Inference: Use this when an LLM emits imperative robot code but the safety requirement is a temporal formula over API-level observations and actions. The method is deliberately insensitive to variable names and irrelevant assignments because it verifies the abstract API behavior.

Steps from section 4.1 (page 5):

  1. Build the environment transition system TS=(Qs,Ts,Ls), whose states encode all conjunctions of truth values of subscribing propositions and whose labels are atomic propositions
  2. Parse program Pi into an abstract syntax tree (AST)
  3. Define keyword processors for AST structures (the paper gives while, if, and if-else rules in Table 1, page 6)
  4. Run the paper’s preorder Tree2FSA algorithm: create an initial state; recursively process each child or keyword node; merge each returned sub-automaton; connect the current state to the sub-automaton initial state with a true transition; return states, initial state, transitions, and labels
  5. Form the product automaton P=A⊗TS, whose states pair an FSA state with an environment state and whose transitions agree with both automata
  6. Use a model checker to test every specification in Φ; retain the program only if the product satisfies all of them

The paper’s example requirement is G(pedestrian → X ¬ publish velocity): after observing a pedestrian, the next action must not publish velocity. One generated turn-right program checks for a pedestrian, stops, and then publishes velocity; its automaton fails because a new pedestrian can appear after the stop. The second program checks in a loop and satisfies the specification. The authors write, “The verification results indicate that the first program fails the specification.” (section 5.1, page 10)

Verus form: Inference: model the robot state and API calls as Rust datatypes and ghost state, express the safety property as a spec fn over sequences or state transitions, and prove each transition with requires/ensures and loop invariants. The AST-to-FSA and product construction remain an off-line verifier front end; Verus does not execute Python ASTs or provide this model checker. Do not write invariant(...) as a call, and do not attach ensures to a spec fn; use Verus syntax documented in the project verifier notes.

Evidence and limits: the demonstrations use GPT-4o-mini and hand-defined API mappings. The method catches an edge case that execution traces can miss, but it assumes the API abstraction and transition system faithfully represent the robot. Inference: unmodeled sensor values, API side effects, parser failures, or a mismatch between generated Python and the keyword table can invalidate the guarantee.

technique 2: compose verified components with a safety theorem

Inference: Use this when a long-horizon task can be split into subprograms and direct whole-program model checking is too expensive. For each component obtain a product automaton Pi that satisfies the safety property. Construct a joint automaton by taking the union of component states, transitions, and labels, then adding transitions from selected states of one component to initial states of another.

The theorem requires (1) every component satisfies Psafe, and (2) every prefix ending at a join, including the labels of the source and destination states, is outside BadPref(Psafe). Under these assumptions the joint automaton satisfies Psafe. The paper says, “if each subprogram satisfies the safety specification in isolation, then their composition also satisfies the specification under mild assumptions.” (section 4.2, page 6) Proposition 2 extends the result by induction to any finite number of automata.

Steps: verify each component; enumerate permitted join pairs; check the bad-prefix condition for every join and every prior prefix; add the join transitions; use the theorem rather than rechecking the complete composition. Verus form: Inference: represent each verified component by a transition lemma with a postcondition preserving a safety predicate, and prove a composition lemma that establishes the join precondition before calling the next component. The join condition is an explicit requires; the resulting safety is an ensures. Verus cannot trust an unproved theorem, so the component and join lemmas must be in the proof crate.

Evidence: the paper’s claim is mathematical, not a measured speedup table. It reports that avoiding whole-composition verification reduces computational complexity, but the theorem depends on the join condition. Inference: arbitrary concatenation is unsafe when a join creates a bad prefix; the theorem does not eliminate environment-model or specification errors.

technique 3: verification-guided fine-tuning

Inference: Use this when verified programs can serve as labels but manual safety annotations are unavailable. The paper’s five-step procedure (section 4.3, page 8) is: query the model on task descriptions, varying random seeds; build and verify an FSA for every generated program; retain passing programs and pair each with its task description; repeat to obtain a dataset; supervised-fine-tune on task/program pairs. The composition theorem lets training target safe subprograms instead of complete long-horizon programs.

The quantitative setup uses 100 verified training samples, a maximum of 400 epochs, negative log-likelihood loss, and early stopping. The three training specifications are φ1=G(pedestrian→X ¬publish velocity), φ2=G(¬(pedestrian∨¬stop sign)→X ¬stop), and φ3=G(car→X ¬publish velocity). The paper reports, “This fine-tuning procedure only consumes 100 samples and less than 5 minutes of training on a single Nvidia A100 GPU.” (section 6.1, page 11) It reports over 50 percent improvement versus the initial model, an average 30 percent improvement on out-of-domain tasks (20 programs per task), and a 50 percent training-time reduction when subprograms are used. The denominator for the out-of-domain experiment is 20 generated programs per task; the paper does not give the plotted per-specification counts.

Verus form: Inference: generate candidate Rust functions, verify them in CI, and add only proof-checking candidates to the supervised corpus. A Verus proof result is the acceptance filter; model training remains outside Verus. Inference: this creates a sound data-selection loop only if the verifier, specifications, and generated API model are trusted.

trust, gaps, and product threat

The proved object is automaton trace inclusion under a specified transition system and join condition. The measured objects are model-generation satisfaction probabilities and training time. Trusted elements include the AST keyword processor, API-to-proposition map, transition-system model, model checker, and temporal specifications; the LLM and empirical execution are not proof sources. The paper does not report complete denominator tables for Figures 9–11, and its “30 percent” headline is an average over out-of-domain plotted probabilities rather than a count of all programs. Inference: VeruLaw should reuse the component-and-join pattern for modular Rust proofs, but must invest in faithful state models and counterexample-driven specification review. Repeating this paper’s generic LLM fine-tuning experiment would add less value than integrating its join obligations into agent-generated Verus modules.

techniques for the catalog

  • AST-to-FSA abstraction: parse generated control flow, map API keywords to finite-state transitions, and model-check the product with an environment system
  • compositional safety theorem: compose individually safe automata only after checking every join against bad-prefix conditions
  • verification-guided refinement: use only model-checked programs as labels for supervised fine-tuning, preferably at component granularity Checked 2026-10-15 against paper yang2024joint: full comparison completed; metadata and unsupported claims reviewed; experiments not reproduced

Last edited: