Blog

When Correct Proofs Are Not Enough: Product Definition as Code Meets Proof-Driven Development

I investigated whether PDaC needed formal semantics. The most useful result was a working integration and a feature I decided not to build.

Author’s note: I directed this investigation using AI agents for research, experimental implementation, review and article drafting, while formal tools performed the mathematical checks against the supplied models and contracts. Agent reviews were not independent human expert validation; the linked repository preserves the evidence, failures and limitations.

By Juan G. Carmona

When Dafny reported two verified methods and zero errors, the program could still change a booking’s owner from 7 to 8. I had deliberately removed the ownership postconditions before changing the implementation to increment the owner identifier, so the remaining contracts verified even though checking the executable against the intended behaviour found mismatches in all 922 public runtime calls. The verifier had done exactly what I asked, because ownership was no longer among its obligations.

That experiment came towards the end of an investigation into a possible next version of Product Definition as Code. I had started by wondering whether PDaC should incorporate formal semantics, and ended up with a useful reason to leave the specification alone.

A promising reason to add something

A LinkedIn publication sent me to Microsoft’s work on Proof-Driven Development, then to Alex Lavaee and Matthai Philipose’s PDD Kit walkthrough. Their example uses Verus to check login logic in a Rust application, with people reviewing intent, formal tools checking specified properties, and tests covering selected behaviour outside the proof boundary. Reading about PDD Kit, a research collaboration between GitHub Next and Microsoft Research, brought me back to a question I was already asking with PDaC.

Product Definition as Code keeps agreed product knowledge in versioned Markdown, with stable identities, explicit relationships and governed Product Changes. ProductShape can check that structure and the freshness of its citations, although it cannot establish the mathematical meaning of arbitrary prose. I wanted to know whether that product knowledge could help agents build and maintain better formal specifications, and whether doing so would require formal semantics inside PDaC itself.

The research initiative left several answers open: existing contracts might be sufficient, external integrations might help, or the evidence might justify an optional formal profile or native semantics. We were exploring a possible v0.4.0 without committing to a feature, drawing on Microsoft’s work without attempting to replicate PDD Kit. Intent Formalization already treats specification validation as a central challenge; SPOTs probes specification gaps through small verified clients, while DeepTest explores AI-assisted specification inference and systematic testing.

Rather than design another language, I started with established formal methods. The executable work used Z3, cvc5, Alloy, Dafny and ProductShape, with booking as a small domain where confirmation, cancellation and expiry all had to respect capacity and ownership.

The experiment that challenged the premise

Before attributing anything to PDaC, I needed a comparison with equivalent formal tooling without it. We prepared four agentic workflows: ordinary requirements, PDaC alone, formal tools alone, and PDaC with formal tools. Our first attempt failed on tool transport and nested sandbox incompatibilities, so we qualified a compatible isolated executor before running the renewed trial. Once that worked, the fixture exposed a different problem: some agents legitimately refused to invent Product Change approval where our synthetic authority was ambiguous. That governance friction remained part of the result.

The comparison failed its predefined benefit threshold. Completed cases reached the benchmark’s finite-case ceiling, while blocked trajectories remained unknown. With approval confounding, dependent observations and no matched human-effort measurements, I could neither claim a PDaC benefit nor draw a general superiority or inferiority conclusion. Ordinary agents passing the same finite cases also told me little about the broader guarantees of formal verification: our benchmark lacked the discriminatory capacity to answer that question.

We preserved both attempts and narrowed the work to smaller executable examples. I wanted to see which specific failures the mechanisms could expose before making any further claim about their value.

A proof can answer the wrong question

In the booking model, confirmation consumes capacity. The arithmetic includes:

Invariant: capacity > 0, footprint > 0, 0 <= used <= capacity
Guard:     used + footprint <= capacity
Effect:    nextUsed = used + footprint

With the model’s other guards held fixed, Z3 and cvc5 found no counterexample to capacity preservation. Once I removed the capacity guard, however, they produced one: capacity = 1, used = 1, nextUsed = 2. A satisfiable failure query means there is a permitted execution that breaks the invariant; an unsatisfiable one establishes preservation under the encoded assumptions.

Even with a preservation result, I still had to question the assumptions: I could obtain unsat by making the transition guard false, because confirmation could then never happen. A separate reachability query exposed that vacuity. Structured Behaviours gave us concrete examples of what should happen, and Domain Lifecycles supplied states and transitions, but I still had to interpret the guards, effects and assumptions. Our successful booking example continued to pass after a guard was removed because it never exercised full capacity, whereas the symbolic counterexample did. The models and raw results retain these probes.

From there, the implementation bridge connected handwritten Dafny contracts to verified methods, compilation to Python and execution through the generated code. Among the actual postconditions were:

ensures accepted == Enabled(capacity, used, state, days, footprint, lead, op)
ensures Inv(capacity, nextUsed, nextState, footprint)
ensures nextOwner == owner

Removing the last obligation from both the method and wrapper allowed the ownership mutation in the opening example, since changing the owner no longer violated their remaining contracts. For the intended implementations, the baseline and reduced-lead wrappers each matched 922 public runtime calls, and the two-slot wrapper matched 886. We obtained the same demonstrated mathematical verification capabilities with conventional formal tooling: a control using identical final source and inputs matched all 886 cases too.

The architectural prototypes likewise reconstructed identical SMT by construction, which checked their consistency without establishing that every possible architecture was equivalent. A wrong but well-formed association between a formula and its source artefact also survived the tested mechanisms. Attaching formulas to product knowledge still left someone responsible for checking that they represented the intended decisions.

A proof can also outlive its purpose

The original wrapper permitted confirmation within 60 days. After we applied a Product Change reducing that limit to 30, the old executable still accepted a booking at day 31: its proof remained valid for the old contract, even though it no longer matched current intent. Testing the historical wrapper against the new rule found 18 mismatches, so we retained it and verified a new wrapper.

A Product Change reduces the booking limit from 60 to 30 days. The old wrapper and proof remain valid for their historical contract, but accepting day 31 conflicts with current intent.

The research fixture separates historical proof validity from current applicability; it adds no normative PDaC mechanism.

A subsequent change made bookings consume two slots, against which the old wrapper produced 103 mismatches on valid inputs. Even that count needed scrutiny: the first checker reported 104 because it continued after a bad output left the current precondition. We corrected the checker and preserved the original result, along with a mixed-revision reproduction that remains qualified in the assurance record.

Following those changes forced me to separate checks I might otherwise have bundled into “verified”:

  • Structural impact identifies the neighbourhood requiring review under PDaC’s Product Change contract.
  • Citation freshness checks recorded source bytes.
  • Formal dependencies declare which definitions and assumptions an obligation uses.
  • Mathematical validity concerns what follows from the model.
  • Applicability asks whether that result supports current intent and implementation.

An editorial edit can stale a citation without falsifying a proposition, just as a changed domain assumption can alter a contract’s meaning while a direct citation to an unchanged Use Case remains current. ProductShape checked and applied the research changes using explicitly scoped synthetic approval receipts, but real products still need human approval. PDaC recorded the decisions without deciding whether an old proof could be reused.

What I kept

The executable reference connects product intent, formal properties, implementation contracts, compiled code, evidence and subsequent changes. If you want to try it, the public integration guide provides pinned setup and reproduction commands; after that setup, you can audit retained output with:

python3 docs/research/v0.4.0/experiments/13-implementation-bridge/audit.py /path/to/run

Once the interpretation is supplied, validation, verification, compilation, execution and evidence checks run without an LLM. Approving the interpretation and its assumptions still requires semantic judgement, and the resulting guarantees concern a bounded atomic component with explicit preconditions and an assumed already authorised caller. We did not verify persistence, concurrency, identity services or a production application, and the runtime checks do not prove the compiler correct. Fresh agent reviews were useful but shared provider and infrastructure trust, so they were not independent human expert validation and did not establish complete intent fidelity.

That division of responsibility is what I mean by:

Formalize with AI. Verify without AI. Govern the evolution with PDaC.

Our accepted final recommendation was to retain PDaC v0.3.0 unchanged, because native formal semantics had demonstrated insufficient additional value to justify an extension, formal profile or v0.4.0 release. Scalability research was deferred and the larger study omitted, so neither supplies positive evidence; future work might reach a different conclusion.

I began by asking what PDaC should gain, and finished with an integration engineers can inspect and reproduce without a demonstrated need to enlarge the specification. Keeping that workflow while leaving the language alone was the simpler engineering decision.

Comments

Comments are stored in GitHub Discussions and shown through giscus. Loading them contacts giscus.app and GitHub, which may set their own cookies.