Repository navigation
feat: episodes as rounds: the environments statesEnv and episodeEnv from an initial law - #299
Conversation
…rom an initial law Co-Authored-By: Claude Code <noreply@github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0196ftMV379vy48QfzHBVNvo
There was a problem hiding this comment.
🟡 proof-quality — request_changes claude/claude-opus-5-5
Earlier findings on duplicated setup and on proofs closing by unstated definitional equality are fixed. One proof still relies on a long chain of named kernel rewrites.
LMLExplore/MarkovDecisionProcess/Episodic/EpisodeEnv.lean:150—comap_map_fst_snd_compProd_augmentedstill rewrites withKernel.map_apply',Kernel.snd_apply',Kernel.compProd_applyandKernel.comp_apply'in onerw, each with hand-built measurability arguments (measurable_fst ht,measurable_snd (measurable_fst ht)), before a 9-lemmasimp. This breaks on any Mathlib rename or signature change. Fix: Letsimpunfold the kernels (e.g.simp [Kernel.map_apply', Kernel.snd_apply', Kernel.compProd_apply, Kernel.comp_apply', ht, …]withmeasurability/fun_propdischarging the side goals). Or split it into small lemmas giving(κ ⊗ₖ η).snd.map Prod.fstapplied at a point.
Reply in this thread to contest a finding; that re-runs only this rubric and posts an answer here. (To fix it, just push a commit — that re-reviews on its own. To contest again after an answer, post a NEW reply rather than editing an old one.)
claude/claude-opus-5-5 · 25s · 59.6k in (32.7k cache read, 26.9k cache write) / 1.9k out tokens · reviewing this diff · rubric
AI review — changes requestedEach rubric is judged independently by multiple review agents; the PR merges only once every rubric is green — any rubric that is not green (changes requested, blocked, errored, stale, or not yet run) blocks the merge. See the rubrics.
♻️ = approved on an earlier commit, re-run before merge. Reviewing this diff at head |
- mark `statesKernel_apply` and `episodeKernel_apply` `@[simp]`; - rename `value_toKernel_of_lt` to `value_toKernel_fin`, as it takes `h : Fin H` and no `h < H` hypothesis; - factor the almost-sure step `0` and the run of the episode trajectories into private lemmas used at every site; - replace the closes by definitional unfolding in `map_fst_episodeLaw`, `hasLaw_statesLaw_zero` and `hasCondDistrib_statesLaw` by `simp` proofs, and shorten the rewrite chain of `comap_map_fst_snd_compProd_augmented`. Co-Authored-By: Claude Code <noreply@github.com>
This PR adds the episode-level environments of ReinforcementLearning Layer 7.7 "Episodes as rounds". Each round of the interaction is a whole episode of an episodic MDP
Mwith horizonH, started from an initial lawμ.LMLExplore/MarkovDecisionProcess/Episodic/Policy.leanadds the deterministicH-step policiesPolicy 𝓢 𝓐 H = Fin H → 𝓢 → 𝓐of Layer 7.6, with measurability as a separate hypothesis. It also addsPolicy.extend(the policy extended beyond the horizon),Policy.measurable_extend,Policy.extend_injectiveandPolicy.toKernel π hπ, the deterministic Markov policy ofπ.EpisodicMDP.value_toKernel_finconnects these to the values on main.LMLExplore/MarkovDecisionProcess/Episodic/EpisodeEnv.leancontains the rest:π : ℕ → Kernel 𝓢 𝓐is the run ofaugMarkovPolicy πinM.augmentedfromμ.map (·, 0).M.statesLaw H μ πis the law of its state sequence andM.episodeLaw H μ πthe joint law of its states and rewards, withmap_fst_episodeLaw. Every run has these laws (hasLaw_statesLaw,hasLaw_episodeLaw);hasCondDistrib_obs_fst_add_one_states: along every run ofπstarted at the steph₀, the state of roundn + 1has conditional law∫ P_{h₀+n}(· | s_n, a) dπ_{h₀+n}(a | s_n)given all the past statess_0, …, s_n. This is the new mathematical content. It is proved from the run lemmas on main, by gluing the action and next-state kernels with LML'sHasCondDistrib.compProdand integrating out the action;M.statesLaw H μ π, the first state has lawμ(hasLaw_statesLaw_zero), and the state of steph + 1has the conditional law above givens_0, …, s_h(hasCondDistrib_statesLaw). The expected return of an episode is∫ V^π_0 dμ(integral_sum_episodeLaw, fromintegral_sum_feedback_eq_integral_value);𝓢and countable𝓐: the kernelsstatesKernel M H μandepisodeKernel M H μfromH-step policies, and the environmentsstatesEnv M H μandepisodeEnv M H μ, bothEnvironment.banditof those kernels. LML at the pinned version has nostationaryEnv;Environment.bandit νis LML's stationary environment without observations. Alsomap_fst_episodeKernel("forgetting the rewards maps its episode laws to those ofstatesEnv M H μ"), the run lemmashasCondDistrib_feedback_statesEnvandhasCondDistrib_feedback_episodeEnv, andBPIAlg 𝓢 𝓐 H(Layer 19.1: anIdentAlginstatesEnvwith anH-step policy as output).Milestone: ReinforcementLearning Layer 7.7 "Episodes as rounds". This PR delivers its first three bullets:
statesEnv M H μ,episodeEnv M H μand the forgetting map. It generalizes the source'sstatesEnv M H s₁to an initial law. Consumers: the open PR #298 (Layer 14.1) says that restating its episodic counts "insidestatesEnv/episodeEnvwaits for those environments (Layer 7.7)". Layer 14.2 ("InstatesEnv, every round containsHvisits") and Layer 14.6 (the KL decomposition instatesEnv) consume them too, andhasCondDistrib_statesLawis the within-episode law that 14.2 and 14.6 read the visits from. What remains of 7.7 after this PR is its fourth bullet: for finite𝓐, a stochastic Markov policy has the episode law of a randomH-step policy.Relation to the paper project and to open work. This is item R7 of the paper project. It also includes the
PolicyandPolicy.extendpart of R6, because R7 needs it. The rest of R6 is the iterated Markov property along an episode (stepLaw,hasCondDistrib_shiftRounds_stepLaw), which builds on the open PRs #295 and #297, so it is not here. For the same reason, the source's backward recursionstateSeqLaw_succis not ported. The source deriveshasCondDistrib_statesLawfrom that iterated Markov property; here it is proved directly from the run lemmas on main, for stochastic Markov policies instead of deterministic ones, so it needs neither open PR. The transfer of a conditional law to an image measure is done inline inhasCondDistrib_statesLaw, not as a public lemma, because #297 adds that lemma (HasCondDistrib.of_comp_hasLaw). No open PR touchesMarkovDecisionProcess/Episodic/. No public declaration is removed or renamed.Source: adapted from the paper project RemyDegenne/Essakine2026Tight at commit 8fb2a20561a128c83e61e9fc0245b85b7d8d6ce4 (Apache 2.0), files
Essakine2026Tight/ForLMLExplore/MarkovDecisionProcess/Episodic/Basic.leanandStepLaw.lean:Policy,Policy.extend,statesLaw,statesKernel,statesEnv,BPIAlg. Following the paper roadmap's note on R7, the environments take an initial lawμinstead of a fixed initial state, andstatesLawis defined for Markov policies throughaugMarkovPolicyandAlgorithm.markovinstead of the source'saugPolicyandpolicyMeasure. Both module docstrings credit the source.Roadmap: ReinforcementLearning
Paper: RemyDegenne/Essakine2026Tight
Item: R7
🤖 Prepared with Claude Code