feat(coinductive): wire PolyFun responders into IND-CPA - #483
Conversation
🤖 PR SummaryThe PR body accurately describes the additions, and the per-file summaries confirm the code changes. No Statistics
Lean Declarations ✏️ Added: 41 declaration(s)
📋 **Additional Analysis**The diff largely adheres to the contributing guidelines, with one notable violation: the copyright year in both new files is 2026, but the current year is 2025. The project's instructions require 📄 **Per-File Summaries**
Last updated: 2026-07-13 06:47 UTC. |
🤖 AI ReviewOverall Summary: Errors during review:
🔗 **Cross-File Analysis**Cross-file analysis failed: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'API key not valid. Please pass a valid API key.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'API_KEY_INVALID', 'domain': 'googleapis.com', 'metadata': {'service': 'generativelanguage.googleapis.com'}}, {'@type': 'type.googleapis.com/google.rpc.LocalizedMessage', 'locale': 'en-US', 'message': 'API key not valid. Please pass a valid API key.'}]}} 📄 **Review for `VCVio.lean`**An error occurred while analyzing 📄 **Review for `VCVio/CryptoFoundations/AsymmEncAlg/INDCPA/Oracle.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/Coinductive/Responder.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/Coinductive/WiredRun.lean`**An error occurred while analyzing |
Build Timing Report
Incremental Rebuild Signal
This compares a clean project build against an incremental rebuild in the same CI job; it is a lightweight variability signal, not a full cross-run benchmark. Slowest Current Clean-Build FilesShowing 20 slowest of 388 repo targets parsed from the current clean build log.
|
|
Closing as a reference draft rather than reworking in place. This was stacked on #482, whose PolyFun pin (the #29 |
…the IND-CPA responder presentation (#499) Reintroduce the responder layer over current PolyFun, replacing the closed reference draft #483: - ProbResponder: stateful probabilistic challengers as SPMF Kleisli-Mealy coalgebras, definitionally interchangeable with stateful QueryImpls; smart constructors are reducible so responder State spellings stay interchangeable during unification. - Strategy wiring stepAgainst/iterateAgainst as PolyFun stepWith/iterWith at SPMF (renamed from the legacy wireK* family, whose runK namesake no longer exists). - OracleMachine.runAgainst: fuelled machine-vs-responder runs, with the wrap/pullback interface adjunction factored through the new DynComputation.unroll_wrap and ProbResponder.liftM_mapLens_pullback rather than fuel induction. - IND-CPA: the cached LR oracle as a responder, the machine-level distribution bridge, and message swapping as a lens with the reduction a one-line instance of the generic adjunction. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Stack
This PR is based on and should be reviewed after #482.
Motivation
#482 supplies the machine/program correspondence. This PR exercises it on an existing
cryptographic construction without moving protocol semantics into VCVio-specific machine types.
The guiding principle is that cryptography in VCVio should be a thin probabilistic and
oracle-specific layer over PolyFun interaction. The existing cached IND-CPA oracle remains the
source of truth; this PR only gives it a PolyFun-compatible responder presentation via lenses.
Probabilistic responders
The primitive data stored by
ProbResponder specis an actual PolyFun handler:Thus a response is an effectful Mealy transition in the Kleisli category of
SPMF: for a query itjointly samples an answer and the next private responder state.
ProbRespondercontributes onlythe existential state packaging and the specialization to VCVio's probability monad.
The new bridges include:
ofQueryImplfor an existingStateT σ SPMFPolyFun handler;ofStateQueryImplfor an existingStateT σ ProbCompimplementation, transported byStateT.mapHom (MonadHom.ofLift ProbComp SPMF);ofResponderfor a deterministicPFunctor.Responder σ q, usingResponder.toStateHandlerand the pure monad morphism;pullbackalong aPFunctor.Lens.The distributional bridge is an instance of PolyFun fold naturality rather than a fresh induction
over
OracleComp:Wired machine execution
The finite responder/strategy run is directly PolyFun's stateful Kleisli execution:
Similarly, pointed-machine execution is based on
PointedMachine.runWith. The importantone-step law for an unresolved machine state is inherited from PolyFun:
wireKRun R (k + 1) (r, s) = wireKStep machine.toDynSystem R (r, s) >>= fun p => wireKRun R k pLenses as reductions
For a lens
wrapping the querying machine and pulling back the responder are observationally the same:
This is the concrete reduction principle exercised by the IND-CPA example.
IND-CPA application
The existing cached implementation
encAlg.IND_CPA_queryImpl' pk b : QueryImpl encAlg.IND_CPA_oracleSpec (StateT encAlg.IND_CPA_Cache ProbComp)is wrapped as
encAlg.IND_CPA_responder pk b. A machine satisfyingthen has the same joint result/cache distribution as the existing
simulateQexecution. Nosecond IND-CPA semantics is introduced.
The left/right message transformation is represented by a PolyFun lens:
It leaves uniform-sampling queries and oracle responses unchanged. The corresponding machine
reduction theorem is a one-line specialization of the generic wrap/pullback law, replacing a
protocol-specific run induction.
Proposed PolyFun follow-up
The remaining existential wrapper points to a useful generic PolyFun notion:
Useful accompanying theory would include:
PFunctor.Lens;MonadHom;stepWith/iterWithlaws;The last item would express conjugacies between responder states—for example, swapping the keys
of the cached IND-CPA oracle—without a VCVio-specific induction. Once this exists upstream,
ProbRespondercan become an even thinner specialization or alias.Deliberately out of scope
Review guide
VCVio/OracleComp/Coinductive/Responder.lean— the thin handler-backed wrapper;VCVio/OracleComp/Coinductive/WiredRun.lean— generic machine/responder wiring;VCVio/CryptoFoundations/AsymmEncAlg/INDCPA/Oracle.lean— the existing-protocol application.Validation
lake buildgit diff --check dtumad/oracle-machine-implements..dtumad/polyfun-indcpa-respondersorrydeclarations