Conversation
Read a generator as a measure (SPMF.expect, SPMF.prob) rather than as a support. Three results, in StrataGenerators/Expectations.lean: 1. genStmt_expect_numLoops_le: the expected number of loops in a draw of genStmt at `size` is at most loopBound size, where loopBound (n+1) = 2/17 + (5*(n+1)/17) * loopBound n. Both constants come off genStmt's frequency list; the mean body length (size+1)/2 enters through expect_choose_mul (Gauss' formula in ENNReal). 2. genLExprBase_prob_rootFactoryOp_ge and _rootFactoryApp_ge: at a declared-type-constructor position, 2/14 of the draws are a factory operator at the root, and 4/14 * mass of the Indir branch are a factory operator applied to arguments. 3. genStmt_prob_rootLoop_ge and _pos: the loop branch's weight share 2/17, times that branch's mass, bounds the probability that a draw is a single loop statement from below, and that probability is positive. Every result is an inequality. A leaf generator can fail, so a sub-draw carries mass < 1 and each composition step loses mass; an exact expectation would need IsPMF for each leaf generator, which is the acceptance-rate question. SPMF.admissible_expect_le also only admits `expect ... <= B`, so the upper bound is the direction fixpoint reasoning supports.
ngernest
added this pull request to stack #31
September 24, 2026 01:01
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.
(Note: this PR is stacked on top of #29, please review #29 first -- thanks!)
This PR proves some probabilistic properties about our generators:
genStmt_expect_numLoops_le)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.