Add executable finite rational probability laws - #37
Open
lyw-ops wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add exact finite probability laws to the stable library.
FiniteLaw αstores nonnegative rational weights on a finite list, somap,bind, and expectation execute without requiring the outcome carrier to be finite or decidably equal. Zero-mass conditioning returnsnone; a valid posterior with zero expected payoff remains a successful result.The foundation includes independent products, partial conditioning, relational couplings, and equivalence of pre-sampling and on-demand fresh queries. Scoped variables and explicit hypotheses precede private helper lemmas and main results. Coupling composition reuses its two marginal arguments; independent-coordinate conditioning separates the probability and product identities; deferred sampling concludes with a short structural induction.
Scope
Math/Probability/FiniteLawmodules, registered inEconCSLib.lean.This is the independent probability foundation extracted from EFG development. It introduces no EFG strategy, history, or compiler changes and constructs no general measure-theoretic kernels or infinite path measures.
Verification
lake build— 8,601 jobs. The finite-law modules emit no warnings; existing main modules still emit warnings.lake build EconCSLib.Examples— 1,608 jobs.lake env lean tests/FiniteLawSmoke.lean— 22 executable guards and four theorem instances covering infinite function carriers, repeated atoms, impossible conditioning, products, composed couplings, and fresh queries.lake env lean tests/FiniteLawAudit.lean— 380 declarations, zero noncomputable declarations, only standard logical axiom dependencies; 376 safe declarations replayed in the kernel. Four compiler recursion helpers are counted separately and excluded from replay.partial def.python3 scripts/check_lean_placeholders.py EconCSLib.git diff --cached --check.docs/knowledge/is unchanged.The style-refactoring comparison preserves all 112 handwritten public declarations, including their elaborated parameter order, universe generality, and axiom dependencies. All 97 canonical definition bodies match; an additional Lean definitional-equality check passes for all 93 safe definitions. The refactor adds ten private proof lemmas, removes one compiler-generated
_simp_1proof helper, and changes the types of two compiler-generated_proof_helpers; these implementation details are not counted as handwritten API.Notes
Products enumerate finite combinations; this is an exact execution API, with no claim of efficient enumeration for large products. Fresh-query applications must supply the indexed tree and its freshness evidence. The original EFG worktree was checked against its content hashes and left unchanged.