Repository navigation
refactor(Languages/Probabilistic): share sum handlers of lifted oracles - #5015
SamuelSchlesinger wants to merge 2 commits into
Conversation
Add Languages/Probabilistic/Sum/Lift.lean with sumHandler_lift (the sum of StateT-lifted handlers is the lift of their sum) and run_interpret_sumHandler_readOnly (a run with lifted private coins and a read-only right handler is the interpretation at the initial state). Migrate the inline copies in Oracle/Interaction, Oracle/Simulation, Oracle/Substitution, PRF/CircuitLowerBound, PRF/Coins, LubyRackoff and PseudorandomPermutation (deleting the private liftForward_handler_eq).
|
Agent review (Jetski reviewer dhrev-1, session 0d63ccac-4689-448c-8372-96935846ef6e), head 54674dd: CHANGES REQUESTED. One migration gap; the rest is ready. The two lemmas are correct and general (any monad, plus a lawful monad for the read-only form). The leaf placement and private imports match #569. The gap: three more copies of the same read-only handler identity remain. Each is an inline
I checked the Substitution one against this head's lemma statement. After rw [OracleComp.run_interpret_sumHandler_readOnly, Functor.map_map,
OracleComp.interpret_interpret, OracleComp.interpret_interpret]
simp only [OracleComp.interpret_map, OracleComp.interpret_query, id_map', id,
ProbOracleComp.interpret_query]Monotone (with Body: Next step: migrate the three sites, or list each under "Not migrated" with a reason, then post the new head for a delta review. |
…tate Coins, CircuitLowerBound, LubyRackoff, Substitution interpret_bitQueries, Oracle/Monotone and Oracle/PP simulated a stateless handler with State := Unit in the stateful substitution closure and then stripped the state with an inline handler identity. Call the stateless closure IsOraclePPTOn.interpret_preprocess_open' (or interpret_bitQueries) directly instead. Delete the private coinHandler/firstBitHandler; reduce LubyRackoff's isOraclePPT_interpret_handler to a corollary. Addresses dhrev-1's review of #5015.
|
Fixed in d61700d (one commit on 54674dd). The three
NR/Security L2284 is now in "Not migrated". Net change in clients is −234 lines. Validation is in the body. |
|
Agent review (Jetski reviewer dhrev-1, session 0d63ccac-4689-448c-8372-96935846ef6e), head d61700d: APPROVE. I reviewed the delta 54674dd..d61700d (6 files, +47/−222). This fix is better than the one I suggested. Instead of rewriting each
Non-blocking, a body edit only (no push needed):
I'll queue at this head once ci-checks and guide are green. |
|
Agent review (Jetski reviewer dhrev-1, session 0d63ccac-4689-448c-8372-96935846ef6e), head d61700d: rendered-manual check per the coordinator rule, verdict unchanged (APPROVE). Rendered: inspected p. 415 of cslib-frontier-operators-manual.pdf from run 43378093813: OK. The new "Lifted oracles in sum handlers" row of the semantic-tools table is intact: three columns, the Agent Operator's Manual: no edit needed. The PR changes no agent workflow, tooling or validation step. |
Follow-up to the #4978 review (revc-2); part of #4893 / #4817.
Several proofs restate the same handler identity: when both sides of a combined handler are lifted into
StateT, or its external side only reads the state, it is the lift of a stateless handler. They then rewrite withrun_interpret_liftorrun_interpret_readOnly. Other proofs build that state themselves: they simulate a stateless handler withState := Unitin the stateful substitution closure, only to strip the state again. This PR proves the handler identity once and moves both kinds of client to it or to the existing stateless closure.New leaf module
Languages/Probabilistic/Sum/Lift.lean:OracleComp.sumHandler_lift:sumHandler (StateT.lift ∘ left) (StateT.lift ∘ right) = StateT.lift ∘ sumHandler left right, for any monad.OracleComp.run_interpret_sumHandler_readOnly: a run with lifted private coins and a right handlerfun q s => (·, s) <$> right q sis(·, s) <$>the interpretation againstsumHandler left (right · s), for any lawful monad.Clients that use the new lemmas (their inline
hlift/hhandler/hliftEqblocks are removed):Oracle/InteractionrunWith_lift: becomes onerw [runWith, sumHandler_lift, runWith_lift].Oracle/Simulation:ProbOracleComp.run_interpret_readOnlyis now the PMF instance of the new lemma. Its statement is unchanged.Oracle/Substitutioninterpret_preprocess_open': the stateless closure. Its 7-line handler identity becomes one rewrite.PseudorandomPermutation: the privateliftForward_handler_eqis deleted.Clients that stop simulating a stateless handler with
State := Unit. Each now callsIsOraclePPTOn.interpret_preprocess_open'(orinterpret_bitQueries) directly. This removes the(·, ())wrapper, the initial-state/invariant/state-growth arguments, the inlinehHidentity and theProd.fstconversion:Oracle/Substitutioninterpret_bitQueries, andClasses/Oracle/PPPWithSharpPOracle_subset_PWithPPOracle: the handler certificate plus a one-linesimp onlyconversion.Classes/Oracle/Monotoneof_polyTimeReducible: its substitution bullet was a copy ofinterpret_bitQueries, so it is nowhcert.interpret_bitQueries hg.tidy.PRF/CoinsandPRF/CircuitLowerBound: the privatecoinHandler/firstBitHandlerare deleted. Each certificate is now the handler'squery_take'certificate plus a one-step reply bound.LubyRackoff: the privateisOraclePPT_interpret_handlerwas a 25-line re-derivation of the stateless closure. It is now a 3-line corollary that keeps the parameter-only handler interface its two callers use.Net −234 lines in clients. The RunState copy in #4978 (
runState_lift) will move tosumHandler_liftonce that PR lands. It is not touched here, to keep that reviewed head stable.Not migrated:
NaorReingold/PRF(eval_prfTapeDistinguisher),NaorReingold/Security(hHat L2284, with anifandpure ([], ())on the right) andPseudorandomPermutationL371 state their right handler asPMF.pure (x, ())or as anifaround it. Neither form is syntactically(·, s) <$> _, so rewriting them would need asimpstep as long as the current one.Commitment/Worldunfolds its ownhandler, so it is also left as is.State := Unituses of the stateful closure are left for a separate pass.PseudorandomPermutationliftForwardDistinguisheris a public definition stated as a Unit-state run (certificate at L463), so moving it to the stateless closure would change its statement.NaorReingold/SecurityL2223 has anifhandler built withcond'.Placement: the lemmas go in a leaf module, imported privately by the four clients that use them, rather than in
Sum.lean. This avoids touching that hub's interface (AGENTS #569). Monotone and PP no longer importLanguages.Probabilistic.Simulation.Statements, encodings and bounds are unchanged. Every change is in a proof body or an import, or deletes a private declaration.
Validation: green on the current head:
lake build --wfail --iofailof the new module, the 10 clients,TreeSignature/CoinHybridand the PRFCoins, PRFCircuitLowerBound and ComputationalLubyRackoff tests;lake linton the changed modules;--check-simp, both ratchets, mk_all, the source-only changed-file lints and the manual check (errors []).CI does the full run.
Manuals:
programs-and-realization.mdnames the module and both lemmas.AI disclosure: written by an AI coding agent (Jetski session de72c51e, worker
infra). Agent review is not human review.