Skip to content

(WIP) Prove some probabilistic properties about our generators - #30

Draft
ngernest wants to merge 1 commit into
spmf-refactorfrom
prob-props
Draft

ngernest wants to merge 1 commit into
spmf-refactorfrom
prob-props

Conversation

@ngernest

@ngernest ngernest commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

(Note: this PR is stacked on top of #29, please review #29 first -- thanks!)

This PR proves some probabilistic properties about our generators:

  1. The expected no. of loops in a sequence of statements produced by the statement generator (genStmt_expect_numLoops_le)
  2. Expected no. of factory function applications in a randomly generated LExpr
  3. Probability of generating a loop in a statement sequence

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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 ngernest changed the title Add expectation and coverage proofs for the generators (WIP) Prove some probabilistic properties about our generators Sep 24, 2026
@ngernest
ngernest added this pull request to stack #31 September 24, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant