← Back to Pull requests

feat(CCS): trace equivalence of Milner's vending machines #1263

Open
unknown opened this pull request with 314 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 19, 2026 17:05 UTC
Author

The module doc of Cslib/Algorithms/CCS/VendingMachine.lean ended with "Future work on proving that the two vending machines are trace equivalent would be welcome." This PR proves it and updates the module doc.

Main statement, placed after vm_ltsD_ltsND_not_bisim and stated in the same shape, with the library's heterogeneous TraceEq:

theorem vm_ltsD_ltsND_traceEq : vm ~tr[ltsD, ltsND] vm

It is assembled from two inclusion lemmas, each proved by induction on the trace using LTS.mem_traces_cons_iff and case analysis on the CCS transition:

  • traces_ltsD_subset_traces_ltsND: a trace of vm in ltsD is a trace of vm in ltsND. The induction needs a statement about the state after the coin as well: a trace of tea.VM + coffee.VM in ltsD is a trace of tea.VM or of coffee.VM in ltsND. The disjunction is where the nondeterministic machine's early commitment shows up, and it is the reason this direction cannot be obtained from a simulation.

  • traces_ltsND_subset_traces_ltsD: the converse, generalised to the two post-coin states tea.VM and coffee.VM of ltsND, each of whose traces are traces of tea.VM + coffee.VM in ltsD. This direction also follows from a simulation via IsSimulation.traces_subset; I kept it as an induction so that the two lemmas read the same way. Happy to switch if you prefer the simulation.
  • No new imports and no changes to existing declarations. The two inclusion lemmas are private, since their statements carry the induction generalisation; only vm_ltsD_ltsND_traceEq is new public API.

    Checked locally (Lean v4.36.0, Mathlib from cache):

  • lake build Cslib.Algorithms.CCS.VendingMachine succeeds with no warnings.

  • #print axioms vm_ltsD_ltsND_traceEq gives [propext, Classical.choice, Quot.sound], and the same for the two lemmas.

  • #lint in Cslib.Algorithms.CCS.VendingMachine reports 0 errors in 20 declarations with 15 linters.

  • lake exe mk_all --check reports "No update necessary".
  • Not run locally: a full lake build, lake test, lake exe checkInitImports and lake shake, since they need the whole library built. The imports of the file are unchanged.

    AI use. This PR was prepared with an AI agent (Claude). The agent read VendingMachine.lean, LTS/TraceEq.lean, the trace definitions in LTS/Basic.lean and CCS/Semantics.lean, wrote the statements and proofs, and ran the build, axiom and lint checks listed above. The proof contains no sorry, no native_decide and no new axioms.

    Diff: 314 lines (+235 / -79) across 3 files Reviewer: thomaskwaring Review duration: 7038m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 314 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.344
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1263"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.3% (MEDIUM) · Higher = larger blast radius
    40.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%